Class: Nostr::Events::EncryptedDirectMessage
- Inherits:
-
Nostr::Event
- Object
- Nostr::Event
- Nostr::Events::EncryptedDirectMessage
- Defined in:
- lib/nostr/events/encrypted_direct_message.rb
Overview
An event whose content
is encrypted. It can only be decrypted by the owner of the private key that pairs the event’s pubkey
.
Instance Attribute Summary
Attributes inherited from Nostr::Event
#content, #created_at, #id, #kind, #pubkey, #sig, #tags
Instance Method Summary collapse
-
#initialize(plain_text:, sender_private_key:, recipient_public_key:, previous_direct_message: nil) ⇒ EncryptedDirectMessage
constructor
Instantiates a new encrypted direct message.
Methods inherited from Nostr::Event
#==, #add_event_reference, #add_pubkey_reference, #serialize, #sign, #to_h, #verify_signature
Constructor Details
#initialize(plain_text:, sender_private_key:, recipient_public_key:, previous_direct_message: nil) ⇒ EncryptedDirectMessage
Instantiates a new encrypted direct message
conversation or a message we are explicitly replying to (such that contextual, more organized conversations may happen
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/nostr/events/encrypted_direct_message.rb', line 36 def initialize(plain_text:, sender_private_key:, recipient_public_key:, previous_direct_message: nil) crypto = Crypto.new keygen = Keygen.new encrypted_content = crypto.encrypt_text(sender_private_key, recipient_public_key, plain_text) sender_public_key = keygen.extract_public_key(sender_private_key) super( pubkey: sender_public_key, kind: Nostr::EventKind::ENCRYPTED_DIRECT_MESSAGE, content: encrypted_content, ) add_pubkey_reference(recipient_public_key) add_event_reference() if end |