Module: ECDSA::Format::PointOctetString

Defined in:
lib/bitcoin/ext/ecdsa.rb

Class Method Summary collapse

Class Method Details

.base_decodeObject



16
# File 'lib/bitcoin/ext/ecdsa.rb', line 16

alias_method :base_decode, :decode

.decode(string, group, allow_hybrid: false) ⇒ Object

Raises:

  • (ECDSA::Format::DecodeError)


19
20
21
22
23
24
25
26
27
28
# File 'lib/bitcoin/ext/ecdsa.rb', line 19

def self.decode(string, group, allow_hybrid: false)
  string = string.dup.force_encoding('BINARY')
  raise ECDSA::Format::DecodeError, 'Point octet string is empty.' if string.empty?
  if [6, 7].include?(string[0].ord)
    raise ECDSA::Format::DecodeError, 'Unrecognized start byte for point octet string: 0x%x' % string[0].ord unless allow_hybrid
    decode_uncompressed string, group if allow_hybrid
  else
    base_decode(string, group)
  end
end