Skip to content

Commit

Permalink
v0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
jshawl committed May 30, 2022
1 parent 7043701 commit d698be3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
coverage
doc
.yardoc
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.5] - 2022-05-30

### Added
- Documentation for YARD (https://www.rubydoc.info/gems/minisign/)

## [0.0.4] - 2022-05-30

### Added
- This CHANGELOG file to hopefully serve as an evolving example of a
standardized open source project CHANGELOG.

[Unreleased]: https://github.com/jshawl/minisign/compare/v0.0.4...HEAD
[Unreleased]: https://github.com/jshawl/minisign/compare/v0.0.5...HEAD
[0.0.5]: https://github.com/jshawl/minisign/compare/v0.0.4...v0.0.5
[0.0.4]: https://github.com/jshawl/minisign/releases/tag/v0.0.4
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
minisign (0.0.4)
minisign (0.0.5)
ed25519 (~> 1.3)

GEM
Expand Down
24 changes: 24 additions & 0 deletions lib/minisign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@
require 'base64'
require 'openssl'

# `minisign` is a rubygem for verifying {https://jedisct1.github.io/minisign minisign} signatures.
# @author Jesse Shawl
module Minisign
# Parse a .minisig file's contents
class Signature
attr_reader :signature, :comment, :comment_signature

# @!attribute [r] signature
# @return [String] the ed25519 verify key
# @!attribute [r] comment_signature
# @return [String] the signature for the trusted comment
# @!attribute [r] comment
# @return [String] the trusted comment

# @param str [String] The contents of the .minisig file
# @example
# Minisign::Signature.new(File.read('test/example.txt.minisig'))
def initialize(str)
lines = str.split("\n")
@signature = Base64.decode64(lines[1])[10..]
Expand All @@ -19,11 +31,23 @@ def initialize(str)

# Parse ed25519 verify key from minisign public key
class PublicKey
# Parse the ed25519 verify key from the minisign public key
#
# @param str [String] The minisign public key
# @example
# Minisign::PublicKey.new('RWTg6JXWzv6GDtDphRQ/x7eg0LaWBcTxPZ7i49xEeiqXVcR+r79OZRWM')
def initialize(str)
@public_key = Base64.strict_decode64(str)[10..]
@verify_key = Ed25519::VerifyKey.new(@public_key)
end

# Verify a message's signature
#
# @param sig [Minisign::Signature]
# @param message [String] the content that was signed
# @return [String] the trusted comment
# @raise Ed25519::VerifyError on invalid signatures
# @raise RuntimeError on tampered trusted comments
def verify(sig, message)
blake = OpenSSL::Digest.new('BLAKE2b512')
@verify_key.verify(sig.signature, blake.digest(message))
Expand Down
2 changes: 1 addition & 1 deletion minisign.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |s|
s.name = 'minisign'
s.version = '0.0.4'
s.version = '0.0.5'
s.summary = 'Minisign, in Ruby!'
s.description = 'Verify minisign signatures'
s.authors = ['Jesse Shawl']
Expand Down

0 comments on commit d698be3

Please sign in to comment.