Class: DbchainClient::PrivateKey
- Inherits:
-
Object
- Object
- DbchainClient::PrivateKey
- Defined in:
- lib/dbchain_client/key.rb
Instance Method Summary collapse
-
#initialize(private_key_hex) ⇒ PrivateKey
constructor
A new instance of PrivateKey.
- #public_key ⇒ Object
- #sign(message) ⇒ Object
Constructor Details
#initialize(private_key_hex) ⇒ PrivateKey
Returns a new instance of PrivateKey.
38 39 40 41 |
# File 'lib/dbchain_client/key.rb', line 38 def initialize(private_key_hex) raw_key = Secp256k1::Utils.decode_hex(private_key_hex) @private_key = Secp256k1::PrivateKey.new(privkey: raw_key) end |
Instance Method Details
#public_key ⇒ Object
43 44 45 |
# File 'lib/dbchain_client/key.rb', line 43 def public_key @public_key ||= PublicKey.new(@private_key.pubkey) end |
#sign(message) ⇒ Object
47 48 49 50 |
# File 'lib/dbchain_client/key.rb', line 47 def sign() raw_sig = @private_key.ecdsa_sign() Signature.new(raw_sig) end |