Class: AsymmetricKey
- Inherits:
-
Object
- Object
- AsymmetricKey
- Includes:
- Utils::HashUtils
- Defined in:
- lib/crypto/asymmetric_key.rb,
lib/crypto/00_asymmetric_key.rb
Direct Known Subclasses
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_hash ⇒ Array<Integer>
-
#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, private_key, signature_algorithm) ⇒ 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, private_key, signature_algorithm) ⇒ AsymmetricKey
Returns a new instance of AsymmetricKey.
22 23 24 25 26 27 |
# File 'lib/crypto/asymmetric_key.rb', line 22 def initialize(public_key, private_key, signature_algorithm) @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_hash ⇒ Array<Integer>
52 53 54 55 56 57 58 59 60 |
# File 'lib/crypto/asymmetric_key.rb', line 52 def account_hash @tag = @public_key.get_cl_public_key_tag key_name = CLPublicKeyTag.key(@tag).to_s prefix = key_name.downcase.unpack("C*") + [0] bytes = prefix + @public_key.get_value result_array = Utils::HashUtils.byte_hash(bytes) @public_key.get_value.length == 0 ? [] : result_array # @public_key.to_account_hash_byte_array end |
#account_hex(public_key) ⇒ String
Returns account_hex.
47 48 49 |
# File 'lib/crypto/asymmetric_key.rb', line 47 def account_hex(public_key) account_hex = @public_key.to_hex end |
#create_from_private_key_file(path_to_private_key) ⇒ Object
63 64 |
# File 'lib/crypto/asymmetric_key.rb', line 63 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
67 68 |
# File 'lib/crypto/asymmetric_key.rb', line 67 def export_public_key_in_pem end |
#get_public_key ⇒ CLPublicKey
30 31 32 |
# File 'lib/crypto/asymmetric_key.rb', line 30 def get_public_key @public_key end |
#get_public_key_hex ⇒ String
Get public hex-encoded string
41 42 43 |
# File 'lib/crypto/asymmetric_key.rb', line 41 def get_public_key_hex "0#{@tag}" + Utils::Base16.encode16(@public_key.get_value) end |
#get_signature_algorithm ⇒ Object
34 35 36 |
# File 'lib/crypto/asymmetric_key.rb', line 34 def get_signature_algorithm @signature_algorithm end |
#sign(message) ⇒ String
72 73 |
# File 'lib/crypto/asymmetric_key.rb', line 72 def sign() end |
#verify(signature, message) ⇒ Boolean
79 80 |
# File 'lib/crypto/asymmetric_key.rb', line 79 def verify(signature, ) end |