module Neb::Secp256k1
Constants
- A
- B
- G
- Gx
- Gy
- N
- P
Elliptic curve parameters
- SECP256K1
Public Class Methods
priv_to_pub(priv)
click to toggle source
# File lib/neb/secp256k1.rb, line 37 def priv_to_pub(priv) priv = PrivateKey.new(priv) privkey = ::Secp256k1::PrivateKey.new(privkey: priv.encode(:bin), raw: true) pubkey = privkey.pubkey PublicKey.new(pubkey.serialize).encode(priv.format) end
sign(msg, priv)
click to toggle source
# File lib/neb/secp256k1.rb, line 22 def sign(msg, priv) priv = PrivateKey.new(priv) privkey = ::Secp256k1::PrivateKey.new(privkey: priv.encode(:bin), raw: true) signature = privkey.ecdsa_recoverable_serialize( privkey.ecdsa_sign_recoverable(msg, raw: true) ) # v = signature[1] # r = Utils.bin_to_hex(signature[0][0,32]) # s = Utils.bin_to_hex(signature[0][32,32]) # puts v, r, s signature[0] << signature[1] end