Nostr. Event. DirectMessage
(Nostr Lib v0.2.1)
(event)
(nip04)
View Source
Direct encrypted message
DEPRECATED in favor of NIP-17 (Private Direct Messages)
Defined in NIP 04 https://github.com/nostr-protocol/nips/blob/master/04.md
Summary
Functions
Create a new encrypted direct message (kind 4) event.
Decrypts the message content using the provided secret key.
Parses a kind 4 event into a DirectMessage struct. Message remains encrypted. Logs a deprecation warning.
Types
@type t() :: %Nostr.Event.DirectMessage{ cipher_text: binary(), event: Nostr.Event.t(), from: <<_::32, _::_*8>>, plain_text: :not_decrypted | String.t(), to: <<_::32, _::_*8>> }
Functions
@spec create( message :: String.t(), seckey :: binary(), recipient :: binary(), opts :: Keyword.t() ) :: t()
Create a new encrypted direct message (kind 4) event.
DEPRECATED: Use NIP-17 Private Direct Messages instead.
Arguments:
message- plaintext message to encryptseckey- sender's secret key (hex string)recipient- recipient's public key (hex string)opts- optional event arguments (:reply_tofor threading, plus standard opts)
Decrypts the message content using the provided secret key.
Works whether you're the sender or recipient - automatically determines which pubkey to use for ECDH shared secret derivation.
Returns the message with plain_text populated, or :not_decrypted if
the secret key doesn't match sender or recipient.
@spec parse(event :: Nostr.Event.t()) :: t()
Parses a kind 4 event into a DirectMessage struct. Message remains encrypted. Logs a deprecation warning.