Class: NKEYS::KeyPair
- Inherits:
-
Object
- Object
- NKEYS::KeyPair
- Defined in:
- lib/nkeys/keypair.rb
Instance Attribute Summary collapse
-
#private_key ⇒ Object
readonly
Returns the value of attribute private_key.
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
-
#seed ⇒ Object
readonly
Returns the value of attribute seed.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ KeyPair
constructor
A new instance of KeyPair.
-
#sign(input) ⇒ String
Sign will sign the input with KeyPair’s private key.
-
#verify(input, sig) ⇒ Bool
Verify the input againt a signature utilizing the public key.
- #wipe ⇒ Object (also: #wipe!)
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_key ⇒ Object (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_key ⇒ Object (readonly)
Returns the value of attribute public_key.
29 30 31 |
# File 'lib/nkeys/keypair.rb', line 29 def public_key @public_key end |
#seed ⇒ Object (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.
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.
51 52 53 54 |
# File 'lib/nkeys/keypair.rb', line 51 def verify(input, sig) # TODO return end |
#wipe ⇒ Object 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 |