Skip to content

Commit

Permalink
Implement FROST::Signature#decode
Browse files Browse the repository at this point in the history
  • Loading branch information
azuchi committed Feb 15, 2024
1 parent 1255a7b commit 07c234b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/frost/signature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,16 @@ def encode
ECDSA::Format::PointOctetString.encode(r, compression: true) +
ECDSA::Format::IntegerOctetString.encode(s, 32)
end

# Decode hex value to FROST::Signature.
# @param [String] hex_value Hex value of signature.
# @param [ECDSA::Group] group Group of elliptic curve.
# @return [FROST::Signature]
def self.decode(hex_value, group)
data = [hex_value].pack("H*")
r = ECDSA::Format::PointOctetString.decode(data[0...33], group)
s = ECDSA::Format::IntegerOctetString.decode(data[33..-1])
Signature.new(r,s )
end
end
end

0 comments on commit 07c234b

Please sign in to comment.