Class: AsymmetricKey
- Inherits:
-
Object
- Object
- AsymmetricKey
- Includes:
- Utils::HashUtils
- Defined in:
- lib/crypto/asymmetric_key.rb
Overview
SignatureAlgorithm =
Ed25519: 'ed25519',
Secp256K1: 'secp256k1'
Instance Attribute Summary collapse
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
-
#signature_algorithm ⇒ Object
readonly
Returns the value of attribute signature_algorithm.
Instance Method Summary collapse
-
#account_hex(public_key) ⇒ String
Account_hex.
- #create_from_private_key_file(path_to_private_key) ⇒ Object
-
#export_public_key_in_pem ⇒ Object
Get public key which is stored in pem.
- #get_public_key ⇒ CLPublicKey
-
#get_public_key_hex ⇒ String
Get public hex-encoded string.
- #get_signature_algorithm ⇒ Object
-
#initialize(public_key = CLPublicKey.new([204, 238, 25, 54, 110, 175, 3, 72, 124, 184, 17, 151, 174, 142, 220, 177, 180, 127, 33, 76, 238, 0, 214, 89, 115, 128, 9, 107, 159, 132, 99, 193], 1), private_key = nil, signature_algorithm = nil) ⇒ AsymmetricKey
constructor
A new instance of AsymmetricKey.
- #sign(message) ⇒ String
- #verify(signature, message) ⇒ Boolean
Methods included from Utils::HashUtils
account_hash_from_byte_to_hex, byte_hash
Constructor Details
#initialize(public_key = CLPublicKey.new([204, 238, 25, 54, 110, 175, 3, 72, 124, 184, 17, 151, 174, 142, 220, 177, 180, 127, 33, 76, 238, 0, 214, 89, 115, 128, 9, 107, 159, 132, 99, 193], 1), private_key = nil, signature_algorithm = nil) ⇒ AsymmetricKey
Returns a new instance of AsymmetricKey.
22 23 24 25 26 27 28 |
# File 'lib/crypto/asymmetric_key.rb', line 22 def initialize(public_key = CLPublicKey.new([204, 238, 25, 54, 110, 175, 3, 72, 124, 184, 17, 151, 174, 142, 220, 177, 180, 127, 33, 76, 238, 0, 214, 89, 115, 128, 9, 107, 159, 132, 99, 193], 1), private_key = nil, signature_algorithm = nil) @public_key = public_key @private_key = private_key @signature_algorithm = signature_algorithm @tag = @public_key.get_cl_public_key_tag end |
Instance Attribute Details
#public_key ⇒ Object (readonly)
Returns the value of attribute public_key.
17 18 19 |
# File 'lib/crypto/asymmetric_key.rb', line 17 def public_key @public_key end |
#signature_algorithm ⇒ Object (readonly)
Returns the value of attribute signature_algorithm.
17 18 19 |
# File 'lib/crypto/asymmetric_key.rb', line 17 def signature_algorithm @signature_algorithm end |
Instance Method Details
#account_hex(public_key) ⇒ String
Returns account_hex.
48 49 50 |
# File 'lib/crypto/asymmetric_key.rb', line 48 def account_hex(public_key) account_hex = @public_key.to_hex end |
#create_from_private_key_file(path_to_private_key) ⇒ Object
64 65 |
# File 'lib/crypto/asymmetric_key.rb', line 64 def create_from_private_key_file(path_to_private_key) end |
#export_public_key_in_pem ⇒ Object
Get public key which is stored in pem
68 69 |
# File 'lib/crypto/asymmetric_key.rb', line 68 def export_public_key_in_pem end |
#get_public_key ⇒ CLPublicKey
31 32 33 |
# File 'lib/crypto/asymmetric_key.rb', line 31 def get_public_key @public_key end |
#get_public_key_hex ⇒ String
Get public hex-encoded string
42 43 44 |
# File 'lib/crypto/asymmetric_key.rb', line 42 def get_public_key_hex "0#{@tag}" + Utils::Base16.encode16(@public_key.get_value) end |
#get_signature_algorithm ⇒ Object
35 36 37 |
# File 'lib/crypto/asymmetric_key.rb', line 35 def get_signature_algorithm @signature_algorithm end |
#sign(message) ⇒ String
73 74 |
# File 'lib/crypto/asymmetric_key.rb', line 73 def sign() end |
#verify(signature, message) ⇒ Boolean
80 81 |
# File 'lib/crypto/asymmetric_key.rb', line 80 def verify(signature, ) end |