mirror of
https://github.com/nostr-protocol/nips.git
synced 2025-12-08 16:18:50 +00:00
refine wording of nip 17, include kind 7 reactions (#2098)
Co-authored-by: Jon Staab <shtaab@gmail.com>
This commit is contained in:
34
17.md
34
17.md
@@ -6,9 +6,15 @@ Private Direct Messages
|
|||||||
|
|
||||||
`draft` `optional`
|
`draft` `optional`
|
||||||
|
|
||||||
This NIP defines an encrypted direct messaging scheme using [NIP-44](44.md) encryption and [NIP-59](59.md) seals and gift wraps.
|
This NIP defines an encrypted chat scheme which uses [NIP-44](44.md) encryption and [NIP-59](59.md) seals and gift wraps.
|
||||||
|
|
||||||
## Direct Message Kind
|
Any 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.
|
||||||
|
|
||||||
|
By convention, `kind 14` direct messages, `kind 15` file messages, and [`kind 7` reactions](./25.md) may be sent to an encrypted chat.
|
||||||
|
|
||||||
|
## Kind Definitions
|
||||||
|
|
||||||
|
### Chat Message
|
||||||
|
|
||||||
Kind `14` is a chat message. `p` tags identify one or more receivers of the message.
|
Kind `14` is a chat message. `p` tags identify one or more receivers of the message.
|
||||||
|
|
||||||
@@ -39,9 +45,7 @@ An `e` tag denotes the direct parent message this post is replying to.
|
|||||||
["q", "<event-id> or <event-address>", "<relay-url>", "<pubkey-if-a-regular-event>"]
|
["q", "<event-id> or <event-address>", "<relay-url>", "<pubkey-if-a-regular-event>"]
|
||||||
```
|
```
|
||||||
|
|
||||||
Kind `14`s MUST never be signed. If it is signed, the message might leak to relays and become **fully public**.
|
## File Message
|
||||||
|
|
||||||
## File Message Kind
|
|
||||||
|
|
||||||
```jsonc
|
```jsonc
|
||||||
{
|
{
|
||||||
@@ -80,8 +84,6 @@ Kind `15` is used for sending encrypted file event messages:
|
|||||||
- `thumb` (optional) URL of thumbnail with same aspect ratio (encrypted with the same key, nonce)
|
- `thumb` (optional) URL of thumbnail with same aspect ratio (encrypted with the same key, nonce)
|
||||||
- `fallback` (optional) zero or more fallback file sources in case `url` fails (encrypted with the same key, nonce)
|
- `fallback` (optional) zero or more fallback file sources in case `url` fails (encrypted with the same key, nonce)
|
||||||
|
|
||||||
Just like kind `14`, kind `15`s MUST never be signed.
|
|
||||||
|
|
||||||
## Chat Rooms
|
## Chat Rooms
|
||||||
|
|
||||||
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 a clean message history.
|
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 a clean message history.
|
||||||
@@ -92,7 +94,7 @@ An optional `subject` tag defines the current name/topic of the conversation. An
|
|||||||
|
|
||||||
## Encrypting
|
## Encrypting
|
||||||
|
|
||||||
Following [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.
|
Following [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.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
@@ -127,7 +129,7 @@ Clients SHOULD randomize `created_at` in up to two days in the past in both the
|
|||||||
|
|
||||||
The 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.
|
The 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.
|
||||||
|
|
||||||
Clients 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
|
Clients 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.
|
||||||
|
|
||||||
## Publishing
|
## Publishing
|
||||||
|
|
||||||
@@ -145,15 +147,13 @@ Kind `10050` indicates the user's preferred relays to receive DMs. The event MUS
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Clients 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.
|
Clients 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.
|
||||||
|
|
||||||
## Relays
|
## Relays
|
||||||
|
|
||||||
It's advisable that relays do not serve `kind:1059` to clients other than the ones tagged in them.
|
Relays MAY protect message metadata by only serving `kind:1059` events to users p-tagged on the event (enforced using [NIP 42 AUTH](./42.md)).
|
||||||
|
|
||||||
It's advisable that users choose relays that conform to these practices.
|
Clients SHOULD guide users to keep `kind:10050` lists small (1-3 relays) and SHOULD spread them to as many relays as viable.
|
||||||
|
|
||||||
Clients SHOULD guide users to keep `kind:10050` lists small (1-3 relays) and SHOULD spread it to as many relays as viable.
|
|
||||||
|
|
||||||
## Benefits & Limitations
|
## Benefits & Limitations
|
||||||
|
|
||||||
@@ -170,12 +170,6 @@ This NIP offers the following privacy and security features:
|
|||||||
|
|
||||||
The 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.
|
The 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.
|
||||||
|
|
||||||
## Implementation
|
|
||||||
|
|
||||||
Clients 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.
|
|
||||||
|
|
||||||
When 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.
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
This example sends the message `Hola, que tal?` from `nsec1w8udu59ydjvedgs3yv5qccshcj8k05fh3l60k9x57asjrqdpa00qkmr89m` to `nsec12ywtkplvyq5t6twdqwwygavp5lm4fhuang89c943nf2z92eez43szvn4dt`.
|
This example sends the message `Hola, que tal?` from `nsec1w8udu59ydjvedgs3yv5qccshcj8k05fh3l60k9x57asjrqdpa00qkmr89m` to `nsec12ywtkplvyq5t6twdqwwygavp5lm4fhuang89c943nf2z92eez43szvn4dt`.
|
||||||
|
|||||||
Reference in New Issue
Block a user