diff options
| author | water <130329555+water783@users.noreply.github.com> | 2025-02-12 01:28:17 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-11 12:28:17 -0500 |
| commit | 6e7a618e7f873bb91e743caacc3b09edab7796a0 (patch) | |
| tree | f0818add82eb94a24b2530d2b2d9e3aad03a4069 /17.md | |
| parent | 60c6404bd1a7ab7d78fca905928c83987846ca13 (diff) | |
Add Kind 15 for Encrypted File message (#1537)
Diffstat (limited to '17.md')
| -rw-r--r-- | 17.md | 42 |
1 files changed, 41 insertions, 1 deletions
| @@ -35,6 +35,46 @@ Tags that mention, quote and assemble threading structures MUST follow [NIP-10]( | |||
| 35 | 35 | ||
| 36 | Kind `14`s MUST never be signed. If it is signed, the message might leak to relays and become **fully public**. | 36 | Kind `14`s MUST never be signed. If it is signed, the message might leak to relays and become **fully public**. |
| 37 | 37 | ||
| 38 | ## File Message Kind | ||
| 39 | |||
| 40 | ```jsonc | ||
| 41 | { | ||
| 42 | "id": "<usual hash>", | ||
| 43 | "pubkey": "<sender-pubkey>", | ||
| 44 | "created_at": "<current-time>", | ||
| 45 | "kind": 15, | ||
| 46 | "tags": [ | ||
| 47 | ["p", "<receiver-1-pubkey>", "<relay-url>"], | ||
| 48 | ["p", "<receiver-2-pubkey>", "<relay-url>"], | ||
| 49 | ["e", "<kind-14-id>", "<relay-url>", "reply"], // if this is a reply | ||
| 50 | ["subject", "<conversation-title>"], | ||
| 51 | ["file-type", "<file-mime-type>"], | ||
| 52 | ["encryption-algorithm", "<encryption-algorithm>"], | ||
| 53 | ["decryption-key", "<decryption-key>"], | ||
| 54 | ["decryptiion-nonce", "<decryption-nonce>"], | ||
| 55 | ["x", "<the SHA-256 hexencoded string of the file>"], | ||
| 56 | // rest of tags... | ||
| 57 | ], | ||
| 58 | "content": "<file-url>" | ||
| 59 | } | ||
| 60 | ``` | ||
| 61 | |||
| 62 | Kind 15 is used for sending encrypted file event messages: | ||
| 63 | |||
| 64 | - `file-type`: Specifies the MIME type of the attached file (e.g., `image/jpeg`, `audio/mpeg`, etc.). | ||
| 65 | - `encryption-algorithm`: Indicates the encryption algorithm used for encrypting the file. Supported algorithms may include `aes-gcm`, `chacha20-poly1305`,`aes-cbc` etc. | ||
| 66 | - `decryption-key`: The decryption key that will be used by the recipient to decrypt the file. | ||
| 67 | - `decryption-nonce`: The decryption nonce that will be used by the recipient to decrypt the file. | ||
| 68 | - `content`: The URL of the file (`<file-url>`). | ||
| 69 | - `x` containing the SHA-256 hexencoded string of the file. | ||
| 70 | - `size` (optional) size of file in bytes | ||
| 71 | - `dim` (optional) size of file in pixels in the form `<width>x<height>` | ||
| 72 | - `blurhash`(optional) the [blurhash](https://github.com/woltapp/blurhash) to show while the file is being loaded by the client | ||
| 73 | - `thumb` (optional) url of thumbnail with same aspect ratio | ||
| 74 | - `fallback` (optional) zero or more fallback file sources in case `url` fails | ||
| 75 | |||
| 76 | Just like kind 14, kind `15`s MUST never be signed. | ||
| 77 | |||
| 38 | ## Chat Rooms | 78 | ## Chat Rooms |
| 39 | 79 | ||
| 40 | The set of `pubkey` + `p` tags defines a chat room. If a new `p` tag is added or a current one is removed, a new room is created with clean message history. | 80 | The set of `pubkey` + `p` tags defines a chat room. If a new `p` tag is added or a current one is removed, a new room is created with clean message history. |
| @@ -45,7 +85,7 @@ An optional `subject` tag defines the current name/topic of the conversation. An | |||
| 45 | 85 | ||
| 46 | ## Encrypting | 86 | ## Encrypting |
| 47 | 87 | ||
| 48 | Following [NIP-59](59.md), the **unsigned** `kind:14` chat message must be sealed (`kind:13`) and then gift-wrapped (`kind:1059`) to each receiver and the sender individually. | 88 | Following [NIP-59](59.md), the **unsigned** `kind:14` & `kind:15` chat message must be sealed (`kind:13`) and then gift-wrapped (`kind:1059`) to each receiver and the sender individually. |
| 49 | 89 | ||
| 50 | ```jsonc | 90 | ```jsonc |
| 51 | { | 91 | { |