Class: Nostr::KeyPair
- Inherits:
-
Object
- Object
- Nostr::KeyPair
- Defined in:
- lib/nostr/key_pair.rb
Overview
A pair of public and private keys
Instance Attribute Summary collapse
-
#private_key ⇒ PrivateKey
readonly
32-bytes hex-encoded private key.
-
#public_key ⇒ PublicKey
readonly
32-bytes hex-encoded public key.
Instance Method Summary collapse
-
#initialize(private_key:, public_key:) ⇒ KeyPair
constructor
Instantiates a key pair.
-
#to_ary ⇒ Array<PrivateKey, PublicKey>
Allows array destructuring of the KeyPair, enabling the extraction of
PrivateKey
andPublicKey
separately.
Constructor Details
#initialize(private_key:, public_key:) ⇒ KeyPair
Instantiates a key pair
44 45 46 47 48 49 |
# File 'lib/nostr/key_pair.rb', line 44 def initialize(private_key:, public_key:) validate_keys(private_key, public_key) @private_key = private_key @public_key = public_key end |
Instance Attribute Details
#private_key ⇒ PrivateKey (readonly)
32-bytes hex-encoded private key
15 16 17 |
# File 'lib/nostr/key_pair.rb', line 15 def private_key @private_key end |
#public_key ⇒ PublicKey (readonly)
32-bytes hex-encoded public key
26 27 28 |
# File 'lib/nostr/key_pair.rb', line 26 def public_key @public_key end |
Instance Method Details
#to_ary ⇒ Array<PrivateKey, PublicKey>
Allows array destructuring of the KeyPair, enabling the extraction of PrivateKey
and PublicKey
separately
71 72 73 |
# File 'lib/nostr/key_pair.rb', line 71 def to_ary [private_key, public_key] end |