Class: NKEYS::KeyPair

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ KeyPair

Returns a new instance of KeyPair.



31
32
33
34
35
36
# File 'lib/nkeys/keypair.rb', line 31

def initialize(opts={})
  @seed = opts[:seed]
  @public_key = opts[:public_key]
  @private_key = opts[:private_key]
  @keys = opts[:keys]
end

Instance Attribute Details

#private_keyObject (readonly)

Returns the value of attribute private_key.



29
30
31
# File 'lib/nkeys/keypair.rb', line 29

def private_key
  @private_key
end

#public_keyObject (readonly)

Returns the value of attribute public_key.



29
30
31
# File 'lib/nkeys/keypair.rb', line 29

def public_key
  @public_key
end

#seedObject (readonly)

Returns the value of attribute seed.



29
30
31
# File 'lib/nkeys/keypair.rb', line 29

def seed
  @seed
end

Instance Method Details

#sign(input) ⇒ String

Sign will sign the input with KeyPair’s private key.

Parameters:

  • input (String)

Returns:

  • (String)

    signed raw data

Raises:



41
42
43
44
45
# File 'lib/nkeys/keypair.rb', line 41

def sign(input)
  raise ::NKEYS::Error, "nkeys: Missing keys for signing" if @keys.nil?

  @keys.sign(input)
end

#verify(input, sig) ⇒ Bool

Verify the input againt a signature utilizing the public key.

Parameters:

  • input (String)
  • sig (String)

Returns:

  • (Bool)

    the result of verifying the signed input.



51
52
53
54
# File 'lib/nkeys/keypair.rb', line 51

def verify(input, sig)
  # TODO
  return
end

#wipeObject Also known as: wipe!



83
84
85
86
87
88
# File 'lib/nkeys/keypair.rb', line 83

def wipe
  @seed.clear if @seed
  @public_key.clear if @public_key
  @private_key.clear if @private_key
  @keys = nil
end