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(kind:, content:, created_at: Time.now.to_i, tags: []) ⇒ Event
Builds an Event.
-
#initialize(keypair: nil, keygen: Keygen.new) ⇒ User
constructor
Instantiates a user.
Constructor Details
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(kind:, content:, created_at: Time.now.to_i, tags: []) ⇒ Event
Builds an Event
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/nostr/user.rb', line 57 def create_event( kind:, content:, created_at: Time.now.to_i, tags: [] ) event = Event.new( pubkey: keypair.public_key, kind:, content:, created_at:, tags: ) event.sign(keypair.private_key) end |