Sha256: 648f9c07c8176ee5c2cc2a056d1c41682ce46168b218a1213c647428f3b47119

Contents?: true

Size: 969 Bytes

Versions: 9

Compression:

Stored size: 969 Bytes

Contents

class ::ECDSA::Signature
  # convert signature to der string.
  def to_der
    ECDSA::Format::SignatureDerString.encode(self)
  end

  def ==(other)
    return false unless other.is_a?(ECDSA::Signature)
    r == other.r && s == other.s
  end
end

class ::ECDSA::Point
  def to_hex(compression = true)
    ECDSA::Format::PointOctetString.encode(self, compression: compression).bth
  end
end

module ::ECDSA::Format::PointOctetString

  class << self
    alias_method :base_decode, :decode
  end

  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

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bitcoinrb-1.4.0 lib/bitcoin/ext/ecdsa.rb
bitcoinrb-1.3.0 lib/bitcoin/ext/ecdsa.rb
bitcoinrb-1.2.1 lib/bitcoin/ext/ecdsa.rb
bitcoinrb-1.2.0 lib/bitcoin/ext/ecdsa.rb
bitcoinrb-1.1.1 lib/bitcoin/ext/ecdsa.rb
bitcoinrb-1.1.0 lib/bitcoin/ext/ecdsa.rb
bitcoinrb-1.0.0 lib/bitcoin/ext/ecdsa.rb
bitcoinrb-0.9.0 lib/bitcoin/ext/ecdsa.rb
bitcoinrb-0.8.0 lib/bitcoin/ext/ecdsa.rb