Class: Nem::Keypair

Inherits:
Object
  • Object
show all
Defined in:
lib/nem/keypair.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(private_key) ⇒ Keypair



8
9
10
11
# File 'lib/nem/keypair.rb', line 8

def initialize(private_key)
  @private = private_key
  @public  = calc_public_key
end

Instance Attribute Details

#privateObject (readonly)

Returns the value of attribute private.



5
6
7
# File 'lib/nem/keypair.rb', line 5

def private
  @private
end

#publicObject (readonly)

Returns the value of attribute public.



5
6
7
# File 'lib/nem/keypair.rb', line 5

def public
  @public
end

Class Method Details

.generate(seed = SecureRandom.hex(64)) ⇒ Object



22
23
24
# File 'lib/nem/keypair.rb', line 22

def self.generate(seed = SecureRandom.hex(64))
  new(seed)
end

Instance Method Details

#sign(data) ⇒ String



15
16
17
18
19
# File 'lib/nem/keypair.rb', line 15

def sign(data)
  bin_data = Nem::Util::Convert.hex2bin(data)
  bin_signed = Nem::Util::Ed25519.signature_hash_unsafe(bin_data, bin_secret, bin_public)
  bin_signed.unpack('H*').first
end