Class: AsymmetricKey

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

Overview

SignatureAlgorithm =

Ed25519: 'ed25519',
Secp256K1: 'secp256k1'

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



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_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>



52
53
54
55
56
57
58
59
60
# File 'lib/crypto/00_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



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

def (public_key)
   = @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_pemObject

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_keyCLPublicKey



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

def get_public_key
  @public_key
end

#get_public_key_hexString

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_algorithmObject



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(message)
end

#verify(signature, message) ⇒ Boolean



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

def verify(signature, message) 
end