NostrElixir.Nip04 (nostr_elixir v0.2.0)
View SourceNIP-04: Encrypted Direct Messages (AES-256-CBC)
This module provides functions to encrypt and decrypt messages using NIP-04.
Examples
iex> alias NostrElixir.Nip04
iex> sk = "...hex secret key..."
iex> pk = "...hex public key..."
iex> ciphertext = Nip04.encrypt(sk, pk, "hello!")
iex> is_binary(ciphertext)
true
iex> Nip04.decrypt(sk, pk, ciphertext)
"hello!"
Summary
Functions
Decrypt a NIP-04 message.
Parameters
secret_key- hex string of recipient's secret keypublic_key- hex string of sender's public keypayload- base64-encoded payload string ("{ciphertext}?iv=..." format)
Returns
- plaintext message (string)
Encrypt a message using NIP-04.
Parameters
secret_key- hex string of sender's secret keypublic_key- hex string of recipient's public keycontent- plaintext message
Returns
- base64-encoded payload string ("{ciphertext}?iv=..." format)