NIP-44, the encrypted payloads of Nostr, in its version 2, on both platforms. Nostr Wallet Connect sends its requests and its answers in such payloads.
Two owners of keys share a conversation key, under which each payload between them is encrypted. A payload is base64 text: a version, a nonce, the encrypted text and a check of the two.
The text is encrypted with ChaCha20 (RFC 8439), which is here since the Web Crypto API of the browsers lacks it, and the check is an HMAC with SHA-256 (RFC 2104). The keys of one payload come from the conversation key and the nonce by HKDF (RFC 5869). The text gets padding, so that the payload tells little of its length.
NIP-44 asks that a payload is in a signed event, and that a reader checks the signature before it reads the payload.
NIP-44, the encrypted payloads of Nostr, in its version 2, on both platforms. Nostr Wallet Connect sends its requests and its answers in such payloads. Two owners of keys share a conversation key, under which each payload between them is encrypted. A payload is base64 text: a version, a nonce, the encrypted text and a check of the two. The text is encrypted with ChaCha20 (RFC 8439), which is here since the Web Crypto API of the browsers lacks it, and the check is an HMAC with SHA-256 (RFC 2104). The keys of one payload come from the conversation key and the nonce by HKDF (RFC 5869). The text gets padding, so that the payload tells little of its length. NIP-44 asks that a payload is in a signed event, and that a reader checks the signature before it reads the payload.
(conversation-key secret-key public-key)The key that the owner of secret-key shares with the owner of
public-key, as hexadecimal text of 32 bytes. It's nil for a text that
isn't a key, and for a public key that isn't a point of the curve.
The owner of the other secret key gets the same key with the public key of this one. The key is for each payload between the two, so an app computes it once. It's as secret as the secret key, so it's a hidden text of dk.simongray.wary-fetch.secret.
The section Encryption of NIP-44 defines it: the x coordinate of the point that the two keys share on secp256k1, extracted by HKDF with the salt nip44-v2.
The key that the owner of `secret-key` shares with the owner of `public-key`, as hexadecimal text of 32 bytes. It's nil for a text that isn't a key, and for a public key that isn't a point of the curve. The owner of the other secret key gets the same key with the public key of this one. The key is for each payload between the two, so an app computes it once. It's as secret as the secret key, so it's a hidden text of dk.simongray.wary-fetch.secret. The section Encryption of NIP-44 defines it: the x coordinate of the point that the two keys share on secp256k1, extracted by HKDF with the salt nip44-v2.
(decrypt payload conversation-key)(decrypt payload conversation-key opts)The text of the payload under conversation-key, with opts, or nil
for a payload that the key doesn't open:
opts or
of default-limitsThe section Decryption of NIP-44 defines the steps. The check of the payload comes before the text is read, and takes the same time for each wrong check.
The text of the `payload` under `conversation-key`, with `opts`, or nil for a payload that the key doesn't open: - a payload of another version - a payload that somebody changed - a payload of another key - a payload with a text of more bytes than the :max-bytes of `opts` or of default-limits The section Decryption of NIP-44 defines the steps. The check of the payload comes before the text is read, and takes the same time for each wrong check.
The limits of a payload that the options don't set.
The :max-bytes is the most bytes of a text, as UTF-8. NIP-44 allows 2^32 - 1 bytes, and asks each reader for a limit of its own. The limit here is a choice: the most bytes that a payload holds with a length of two bytes.
The limits of a payload that the options don't set. The :max-bytes is the most bytes of a text, as UTF-8. NIP-44 allows 2^32 - 1 bytes, and asks each reader for a limit of its own. The limit here is a choice: the most bytes that a payload holds with a length of two bytes.
(encrypt plaintext conversation-key nonce)(encrypt plaintext conversation-key nonce opts)The payload of the text plaintext under conversation-key, with
nonce and opts. The key and the nonce are hexadecimal text of 32
bytes.
It's nil for a text without a byte, and for a text with more bytes than
the :max-bytes of opts or of default-limits. The nonce is 32 random
bytes that nobody can guess, new for each payload. The section
Encryption of NIP-44 defines the steps.
The payload of the text `plaintext` under `conversation-key`, with `nonce` and `opts`. The key and the nonce are hexadecimal text of 32 bytes. It's nil for a text without a byte, and for a text with more bytes than the :max-bytes of `opts` or of default-limits. The nonce is 32 random bytes that nobody can guess, new for each payload. The section Encryption of NIP-44 defines the steps.
(payload-version payload)The version of the payload, a number, or nil for a text that isn't a
payload of NIP-44. It's nil too for a payload in a form after version 2,
which starts with a number sign.
This namespace reads version 2. With another version, an app can tell the user that the other side has a later version of NIP-44.
The version of the `payload`, a number, or nil for a text that isn't a payload of NIP-44. It's nil too for a payload in a form after version 2, which starts with a number sign. This namespace reads version 2. With another version, an app can tell the user that the other side has a later version of NIP-44.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |