Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jshawl committed Feb 7, 2024
1 parent 6f0f5f0 commit 12126c3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/minisign/public_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ def initialize(str)
@decoded = Base64.strict_decode64(parts.last)
@public_key = @decoded[10..]
@verify_key = Ed25519::VerifyKey.new(@public_key)
if parts.length == 1
data = Base64.strict_encode64("Ed#{@decoded[2..9]}#{@public_key}")
@untrusted_comment = "minisign public key #{key_id}\n#{data}\n"
@untrusted_comment = if parts.length == 1
"minisign public key #{key_id}\n#{key_data}\n"
else
@untrusted_comment = parts.first.split("untrusted comment: ").last
parts.first.split("untrusted comment: ").last
end
end

Expand Down Expand Up @@ -48,9 +47,12 @@ def verify(sig, message)
"Signature and comment signature verified\nTrusted comment: #{sig.trusted_comment}"
end

def key_data
Base64.strict_encode64("Ed#{@decoded[2..9]}#{@public_key}")
end

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

private
Expand Down

0 comments on commit 12126c3

Please sign in to comment.