Class: Nis::Keypair
- Inherits:
-
Object
- Object
- Nis::Keypair
- Defined in:
- lib/nis/keypair.rb
Instance Attribute Summary collapse
-
#private ⇒ Object
readonly
Returns the value of attribute private.
-
#public ⇒ Object
readonly
Returns the value of attribute public.
Instance Method Summary collapse
-
#initialize(private_key, public_key: nil) ⇒ Keypair
constructor
A new instance of Keypair.
- #sign(data) ⇒ Object
Constructor Details
#initialize(private_key, public_key: nil) ⇒ Keypair
Returns a new instance of Keypair.
5 6 7 8 |
# File 'lib/nis/keypair.rb', line 5 def initialize(private_key, public_key: nil) @private = private_key @public = public_key || calc_public_key end |
Instance Attribute Details
#private ⇒ Object (readonly)
Returns the value of attribute private.
3 4 5 |
# File 'lib/nis/keypair.rb', line 3 def private @private end |
#public ⇒ Object (readonly)
Returns the value of attribute public.
3 4 5 |
# File 'lib/nis/keypair.rb', line 3 def public @public end |
Instance Method Details
#sign(data) ⇒ Object
10 11 12 13 14 |
# File 'lib/nis/keypair.rb', line 10 def sign(data) bin_data = data.scan(/../).map(&:hex).pack('C*') bin_signed = Nis::Util::Ed25519.signature_hash_unsafe(bin_data, @bin_secret, @bin_public) bin_signed.unpack('H*').first end |