Class: Bitcoin::Key
- Inherits:
-
Object
- Object
- Bitcoin::Key
- Defined in:
- lib/coin-op/bit.rb
Instance Method Summary collapse
-
#sign(data) ⇒ Object
Sign
data
with the key. -
#verify(data, sig) ⇒ Object
Verify signature
sig
fordata
.
Instance Method Details
#sign(data) ⇒ Object
167 168 169 170 171 172 173 174 |
# File 'lib/coin-op/bit.rb', line 167 def sign(data) sig = @key.dsa_sign_asn1(data) if Script::is_low_der_signature?(sig) sig else Bitcoin::OpenSSL_EC.signature_to_low_s(sig) end end |
#verify(data, sig) ⇒ Object
179 180 181 182 183 184 185 186 187 |
# File 'lib/coin-op/bit.rb', line 179 def verify(data, sig) regenerate_pubkey unless @key.public_key sig = Bitcoin::OpenSSL_EC.repack_der_signature(sig) if sig @key.dsa_verify_asn1(data, sig) else false end end |