Method: FROST::Signature.decode
- Defined in:
- lib/frost/signature.rb
.decode(context, hex_value) ⇒ FROST::Signature
Decode hex value to FROST::Signature.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/frost/signature.rb', line 45 def self.decode(context, hex_value) raise ArgumentError, "context must be FROST::Context" unless context.is_a?(FROST::Context) raise ArgumentError, "hex value must be String" unless hex_value.is_a?(String) data = [hex_value].pack("H*") data = [0x02].pack('C') + data if context.taproot? len = context.group.byte_length + 1 r = ECDSA::Format::PointOctetString.decode(data[0...len], context.group) s = ECDSA::Format::IntegerOctetString.decode(data[len..-1]) Signature.new(context, r, s) end |