Class: Ciri::Key
- Inherits:
-
Object
- Object
- Ciri::Key
- Defined in:
- lib/ciri/key.rb
Overview
Instance Attribute Summary collapse
-
#ec_key ⇒ Object
readonly
Returns the value of attribute ec_key.
Class Method Summary collapse
Instance Method Summary collapse
- #ecdsa_signature(data) ⇒ Object
- #ecies_decrypt(data, shared_mac_data = '') ⇒ Object
- #ecies_encrypt(message, shared_mac_data = '') ⇒ Object
-
#initialize(ec_key: nil, raw_public_key: nil, raw_private_key: nil) ⇒ Key
constructor
initialized from ec_key or raw keys ec_key is a OpenSSL::PKey::EC object, raw keys is bytes presented keys.
-
#raw_public_key ⇒ Object
raw public key.
- #to_address ⇒ Object
Constructor Details
#initialize(ec_key: nil, raw_public_key: nil, raw_private_key: nil) ⇒ Key
initialized from ec_key or raw keys ec_key is a OpenSSL::PKey::EC object, raw keys is bytes presented keys
57 58 59 |
# File 'lib/ciri/key.rb', line 57 def initialize(ec_key: nil, raw_public_key: nil, raw_private_key: nil) @ec_key = ec_key || Ciri::Utils.create_ec_pk(raw_privkey: raw_private_key, raw_pubkey: raw_public_key) end |
Instance Attribute Details
#ec_key ⇒ Object (readonly)
Returns the value of attribute ec_key.
53 54 55 |
# File 'lib/ciri/key.rb', line 53 def ec_key @ec_key end |
Class Method Details
Instance Method Details
#ecdsa_signature(data) ⇒ Object
66 67 68 |
# File 'lib/ciri/key.rb', line 66 def ecdsa_signature(data) Crypto.ecdsa_signature(secp256k1_key, data) end |
#ecies_decrypt(data, shared_mac_data = '') ⇒ Object
74 75 76 |
# File 'lib/ciri/key.rb', line 74 def ecies_decrypt(data, shared_mac_data = '') Crypto.ecies_decrypt(data, ec_key, shared_mac_data) end |
#ecies_encrypt(message, shared_mac_data = '') ⇒ Object
70 71 72 |
# File 'lib/ciri/key.rb', line 70 def ecies_encrypt(, shared_mac_data = '') Crypto.ecies_encrypt(, ec_key, shared_mac_data) end |
#raw_public_key ⇒ Object
raw public key
62 63 64 |
# File 'lib/ciri/key.rb', line 62 def raw_public_key @raw_public_key ||= ec_key.public_key.to_bn.to_s(2) end |