upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhodlbod <jstaab@protonmail.com>2025-10-30 12:53:24 -0700
committerGitHub <noreply@github.com>2025-10-30 15:53:24 -0400
commit3ec830cd2331ba0ed3113fc05a44c87deb9785be (patch)
treeeaada278efdc4472902c6ceb23d8170d9cd1c116
parentcc77619af8f38f858a488a962358498a9dbc6250 (diff)
refine wording of nip 17, include kind 7 reactions (#2098)
Co-authored-by: Jon Staab <shtaab@gmail.com>
-rw-r--r--17.md36
1 files changed, 15 insertions, 21 deletions
diff --git a/17.md b/17.md
index 2e0aabb..900b6dd 100644
--- a/17.md
+++ b/17.md
@@ -6,9 +6,15 @@ Private Direct Messages
6 6
7`draft` `optional` 7`draft` `optional`
8 8
9This NIP defines an encrypted direct messaging scheme using [NIP-44](44.md) encryption and [NIP-59](59.md) seals and gift wraps. 9This NIP defines an encrypted chat scheme which uses [NIP-44](44.md) encryption and [NIP-59](59.md) seals and gift wraps.
10 10
11## Direct Message Kind 11Any event sent to an encrypted chat MUST NOT be signed, and MUST be encrypted as described in [NIP-59](./59.md) and illustrated below. Omitting signatures makes messages deniable in case they are accidentally or maliciously leaked, while still allowing the recipient to authenticate them.
12
13By convention, `kind 14` direct messages, `kind 15` file messages, and [`kind 7` reactions](./25.md) may be sent to an encrypted chat.
14
15## Kind Definitions
16
17### Chat Message
12 18
13Kind `14` is a chat message. `p` tags identify one or more receivers of the message. 19Kind `14` is a chat message. `p` tags identify one or more receivers of the message.
14 20
@@ -31,7 +37,7 @@ Kind `14` is a chat message. `p` tags identify one or more receivers of the mess
31 37
32`.content` MUST be plain text. Fields `id` and `created_at` are required. 38`.content` MUST be plain text. Fields `id` and `created_at` are required.
33 39
34An `e` tag denotes the direct parent message this post is replying to. 40An `e` tag denotes the direct parent message this post is replying to.
35 41
36`q` tags MAY be used when citing events in the `.content` with [NIP-21](21.md). 42`q` tags MAY be used when citing events in the `.content` with [NIP-21](21.md).
37 43
@@ -39,9 +45,7 @@ An `e` tag denotes the direct parent message this post is replying to.
39["q", "<event-id> or <event-address>", "<relay-url>", "<pubkey-if-a-regular-event>"] 45["q", "<event-id> or <event-address>", "<relay-url>", "<pubkey-if-a-regular-event>"]
40``` 46```
41 47
42Kind `14`s MUST never be signed. If it is signed, the message might leak to relays and become **fully public**. 48## File Message
43
44## File Message Kind
45 49
46```jsonc 50```jsonc
47{ 51{
@@ -80,8 +84,6 @@ Kind `15` is used for sending encrypted file event messages:
80- `thumb` (optional) URL of thumbnail with same aspect ratio (encrypted with the same key, nonce) 84- `thumb` (optional) URL of thumbnail with same aspect ratio (encrypted with the same key, nonce)
81- `fallback` (optional) zero or more fallback file sources in case `url` fails (encrypted with the same key, nonce) 85- `fallback` (optional) zero or more fallback file sources in case `url` fails (encrypted with the same key, nonce)
82 86
83Just like kind `14`, kind `15`s MUST never be signed.
84
85## Chat Rooms 87## Chat Rooms
86 88
87The 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 a clean message history. 89The 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 a clean message history.
@@ -92,7 +94,7 @@ An optional `subject` tag defines the current name/topic of the conversation. An
92 94
93## Encrypting 95## Encrypting
94 96
95Following [NIP-59](59.md), the **unsigned** `kind:14` & `kind:15` chat messages must be sealed (`kind:13`) and then gift-wrapped (`kind:1059`) to each receiver and the sender individually. 97Following [NIP-59](59.md), the **unsigned** chat messages must be sealed (`kind:13`) and then gift-wrapped (`kind:1059`) to each receiver and the sender individually.
96 98
97```js 99```js
98{ 100{
@@ -127,7 +129,7 @@ Clients SHOULD randomize `created_at` in up to two days in the past in both the
127 129
128The gift wrap's `p` tag can be the receiver's main pubkey or an alias key created to receive DMs without exposing the receiver's identity. 130The gift wrap's `p` tag can be the receiver's main pubkey or an alias key created to receive DMs without exposing the receiver's identity.
129 131
130Clients CAN offer disappearing messages by setting an `expiration` tag in the gift wrap of each receiver or by not generating a gift wrap to the sender's public key 132Clients MAY offer disappearing messages by setting an `expiration` tag in the gift wrap of each receiver or by not generating a gift wrap to the sender's public key. This tag SHOULD be included on the `kind 13` seal as well, in case it leaks.
131 133
132## Publishing 134## Publishing
133 135
@@ -145,15 +147,13 @@ Kind `10050` indicates the user's preferred relays to receive DMs. The event MUS
145} 147}
146``` 148```
147 149
148Clients SHOULD publish the gift-wrapped kind 1059 events that contain the sealed kind 14 (text) or kind 15 (file) rumors to the relays listed in the recipient’s kind 10050 event. If that is not found that indicates the user is not ready to receive messages under this NIP and clients shouldn't try. 150Clients SHOULD publish the gift-wrapped `kind 1059` events that contain the sealed rumors to the relays listed in the recipient’s kind 10050 event. If that is not found that indicates the user is not ready to receive messages under this NIP and clients shouldn't try.
149 151
150## Relays 152## Relays
151 153
152It's advisable that relays do not serve `kind:1059` to clients other than the ones tagged in them. 154Relays MAY protect message metadata by only serving `kind:1059` events to users p-tagged on the event (enforced using [NIP 42 AUTH](./42.md)).
153 155
154It's advisable that users choose relays that conform to these practices. 156Clients SHOULD guide users to keep `kind:10050` lists small (1-3 relays) and SHOULD spread them to as many relays as viable.
155
156Clients SHOULD guide users to keep `kind:10050` lists small (1-3 relays) and SHOULD spread it to as many relays as viable.
157 157
158## Benefits & Limitations 158## Benefits & Limitations
159 159
@@ -170,12 +170,6 @@ This NIP offers the following privacy and security features:
170 170
171The main limitation of this approach is having to send a separate encrypted event to each receiver. Group chats with more than 100 participants should find a more suitable messaging scheme. 171The main limitation of this approach is having to send a separate encrypted event to each receiver. Group chats with more than 100 participants should find a more suitable messaging scheme.
172 172
173## Implementation
174
175Clients implementing this NIP should by default only connect to the set of relays found in their `kind:10050` list. From that they should be able to load all messages both sent and received as well as get new live updates, making it for a very simple and lightweight implementation that should be fast.
176
177When sending a message to anyone, clients must then connect to the relays in the receiver's `kind:10050` and send the events there but can disconnect right after unless more messages are expected to be sent (e.g. the chat tab is still selected). Clients should also send a copy of their outgoing messages to their own `kind:10050` relay set.
178
179## Examples 173## Examples
180 174
181This example sends the message `Hola, que tal?` from `nsec1w8udu59ydjvedgs3yv5qccshcj8k05fh3l60k9x57asjrqdpa00qkmr89m` to `nsec12ywtkplvyq5t6twdqwwygavp5lm4fhuang89c943nf2z92eez43szvn4dt`. 175This example sends the message `Hola, que tal?` from `nsec1w8udu59ydjvedgs3yv5qccshcj8k05fh3l60k9x57asjrqdpa00qkmr89m` to `nsec12ywtkplvyq5t6twdqwwygavp5lm4fhuang89c943nf2z92eez43szvn4dt`.