Class: Nostr::User
- Inherits:
-
Object
- Object
- Nostr::User
- Defined in:
- lib/nostr/user.rb
Overview
Each user has a keypair. Signatures, public key, and encodings are done according to the Schnorr signatures standard for the curve secp256k1.
Instance Attribute Summary collapse
-
#keypair ⇒ KeyPair
readonly
A pair of private and public keys.
Instance Method Summary collapse
-
#create_event(event_attributes) ⇒ Event
Builds an Event.
-
#initialize(keypair: nil, keygen: Keygen.new) ⇒ User
constructor
Instantiates a user.
Constructor Details
#initialize(keypair: nil, keygen: Keygen.new) ⇒ User
Instantiates a user
36 37 38 |
# File 'lib/nostr/user.rb', line 36 def initialize(keypair: nil, keygen: Keygen.new) @keypair = keypair || keygen.generate_key_pair end |
Instance Attribute Details
#keypair ⇒ KeyPair (readonly)
A pair of private and public keys
21 22 23 |
# File 'lib/nostr/user.rb', line 21 def keypair @keypair end |
Instance Method Details
#create_event(event_attributes) ⇒ Event
Builds an Event
59 60 61 62 |
# File 'lib/nostr/user.rb', line 59 def create_event(event_attributes) event = Event.new(**event_attributes.merge(pubkey: keypair.public_key)) event.sign(keypair.private_key) end |