Module: Bitcoin::Util

Defined in:
lib/coin-op/bit.rb

Instance Method Summary collapse

Instance Method Details

#verify_signature(hash, signature, public_key) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/coin-op/bit.rb', line 149

def verify_signature(hash, signature, public_key)
  key  = bitcoin_elliptic_curve
  key.public_key = ::OpenSSL::PKey::EC::Point.from_hex(key.group, public_key)
  signature = Bitcoin::OpenSSL_EC.repack_der_signature(signature)
  if signature
    key.dsa_verify_asn1(hash, signature)
  else
    false
  end
rescue OpenSSL::PKey::ECError, OpenSSL::PKey::EC::Point::Error
  false
end