Class: AsymmetricKey

Inherits:
Object
  • Object
show all
Includes:
Utils::HashUtils
Defined in:
lib/crypto/asymmetric_key.rb,
lib/crypto/00_asymmetric_key.rb

Direct Known Subclasses

Ed25519Key

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Parameters:



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_keyObject (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_algorithmObject (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_hashArray<Integer>

Returns:

  • (Array<Integer>)


52
53
54
55
56
57
58
59
60
# File 'lib/crypto/asymmetric_key.rb', line 52

def 
  @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.

Parameters:

Returns:

  • (String)

    account_hex



47
48
49
# File 'lib/crypto/asymmetric_key.rb', line 47

def (public_key)
   = @public_key.to_hex
end

#create_from_private_key_file(path_to_private_key) ⇒ Object

Parameters:

  • path_to_private_key (String)


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_pemObject

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_keyCLPublicKey

Returns:



30
31
32
# File 'lib/crypto/asymmetric_key.rb', line 30

def get_public_key
  @public_key
end

#get_public_key_hexString

Get public hex-encoded string

Returns:

  • (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_algorithmObject



34
35
36
# File 'lib/crypto/asymmetric_key.rb', line 34

def get_signature_algorithm
  @signature_algorithm
end

#sign(message) ⇒ String

Parameters:

  • message (String)

Returns:

  • (String)


72
73
# File 'lib/crypto/asymmetric_key.rb', line 72

def sign(message)
end

#verify(signature, message) ⇒ Boolean

Parameters:

  • signature (String)
  • message (String)

Returns:



79
80
# File 'lib/crypto/asymmetric_key.rb', line 79

def verify(signature, message) 
end