Skip to content

Commit

Permalink
Public key to_s (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
jshawl authored Feb 7, 2024
1 parent a7dbf32 commit f073fea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/minisign/public_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def verify(sig, message)
"Signature and comment signature verified\nTrusted comment: #{sig.trusted_comment}"
end

def to_s
data = Base64.strict_encode64("Ed#{@decoded[2..9]}#{@public_key}")
"untrusted comment: minisign public key #{key_id}\n#{data}\n"
end

private

def ensure_matching_key_ids(key_id1, key_id2)
Expand Down
3 changes: 3 additions & 0 deletions spec/minisign_spec.rb → spec/minisign/public_key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@
@pk.verify(@signature, @message)
end.to raise_error("Signature key id is 4CB7A94FABA329A6\nbut the key id in the public key is F15F69C58B18A08")
end
it 'can be written to a file' do
expect(@pk.to_s).to eq(File.read('test/minisign.pub'))
end
end

0 comments on commit f073fea

Please sign in to comment.