diff options
| -rw-r--r-- | 27.md | 76 |
1 files changed, 41 insertions, 35 deletions
| @@ -1,37 +1,33 @@ | |||
| 1 | NIP-27 | 1 | NIP-27 |
| 2 | ====== | 2 | ====== |
| 3 | 3 | ||
| 4 | Multicasting | 4 | Restricted Tags |
| 5 | ------------ | 5 | --------------- |
| 6 | 6 | ||
| 7 | `draft` `optional` `author:cameri` | 7 | `draft` `optional` `author:cameri` |
| 8 | 8 | ||
| 9 | A new tag `m` meaning `multicast group` allow for events to be addressed to a | 9 | This NIP extends the `<filters>` object described in `NIP-01` to contain |
| 10 | group of clients simultaneously. Multicast in this scenario can be one-to-many | 10 | arbitrary two-letter tags (known as restricted tags) prefixed by `#`, allowing |
| 11 | or many-to-many. | 11 | for events with restricted tags to be queried. Any two-letter key prefixed by |
| 12 | `#` is a restricted tag query and must be an array of strings. | ||
| 12 | 13 | ||
| 13 | A relay MUST forward events containing `m` tags strictly to clients subscribed | 14 | The filter condition matches an event if and only if all of the restricted tags |
| 14 | with a tag filter `#m` containing at least one of the values of such tags and | 15 | in the event are also present in a `<filters>` object. As such, relays should not |
| 15 | refrain from forwarding such events to clients without such filter. The value | 16 | forward events with restricted tags to clients without a strictly matching filter. |
| 16 | of an `m` tag is case-sensitive. | ||
| 17 | 17 | ||
| 18 | A client SHOULD send events containing `m` tags only to relays that explicitly | 18 | A client wishing to use restricted tags should only send events with restricted |
| 19 | support NIP-27. A NIP-16 supporting client MAY test for the capability by | 19 | tags to relays that explicitly support NIP-27. |
| 20 | subscribing twice to a relay with and without the tag filter `#m` respectively | ||
| 21 | and sending an ephemeral event with a random `m` tag of equal value and assert | ||
| 22 | it was only received by the right subscription. | ||
| 23 | 20 | ||
| 24 | ## Events | 21 | ## Events |
| 25 | 22 | ||
| 26 | Clients targeting a multicast group MAY include an `m` tag with a value set to | 23 | Clients wishing to send an event with a restricted tag may include one or more |
| 27 | an arbitrary string representing the multicast group. | 24 | two-letter tags with a value set to an arbitrary string. |
| 28 | 25 | ||
| 29 | Suppose that Alice wants to multicast an event to a very special multicast group | 26 | Suppose that Alice wants to send an event with the restricted tag `#ch`. The value |
| 30 | that covers specific topics. The multicast group is identified by the following | 27 | of the `#ch` restricted tag is the following string: `/nostr/social` |
| 31 | string: `00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048` | ||
| 32 | 28 | ||
| 33 | Alice would construct the following message and send it to her favorite relay | 29 | Alice would construct the following message and send it to her favorite relay |
| 34 | which happens to support multicasting: | 30 | which happens to support restricted events: |
| 35 | 31 | ||
| 36 | ```json | 32 | ```json |
| 37 | [ | 33 | [ |
| @@ -42,7 +38,7 @@ which happens to support multicasting: | |||
| 42 | "created_at": 1231469640, | 38 | "created_at": 1231469640, |
| 43 | "content": "Let's get the conversation started", | 39 | "content": "Let's get the conversation started", |
| 44 | "tags": [ | 40 | "tags": [ |
| 45 | ["m", "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"], | 41 | ["ch", "/nostr/social"], |
| 46 | ], | 42 | ], |
| 47 | "sig": "<sig>" | 43 | "sig": "<sig>" |
| 48 | } | 44 | } |
| @@ -51,8 +47,8 @@ which happens to support multicasting: | |||
| 51 | 47 | ||
| 52 | ## Subscriptions | 48 | ## Subscriptions |
| 53 | 49 | ||
| 54 | Clients subscribing to a multicast group MUST include an `#m` tag filter with | 50 | Clients wishing to subscribe to events with restricted tags MUST include a filter |
| 55 | an array of multicast groups as values. | 51 | that matches all of the restricted tags in said events. |
| 56 | 52 | ||
| 57 | Suppose that Bob and Charlie both share Alice's interest and would like to stay | 53 | Suppose that Bob and Charlie both share Alice's interest and would like to stay |
| 58 | up to date. Both would construct the following message to subscribe: | 54 | up to date. Both would construct the following message to subscribe: |
| @@ -62,24 +58,34 @@ up to date. Both would construct the following message to subscribe: | |||
| 62 | "REQ", | 58 | "REQ", |
| 63 | "<subscriptionId>", | 59 | "<subscriptionId>", |
| 64 | { | 60 | { |
| 65 | "#m": ["00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"] | 61 | "#ch": ["/nostr/social"] |
| 66 | } | 62 | } |
| 67 | ] | 63 | ] |
| 68 | ``` | 64 | ``` |
| 69 | 65 | ||
| 70 | # Use Cases | 66 | # Use Cases |
| 71 | 67 | ||
| 72 | 1. Subreddit/IRC-like channels (e.g. `{ "#m": ["#newbies", "r/nostr", "#mp3s", "r/oldschoolcool"] }`) over Nostr. | 68 | 1. Subreddit/IRC-like channels (e.g. `{ "#ch": ["r/oldschoolcool"] }`) over Nostr. |
| 73 | 2. Forums over Nostr. (e.g. `{ "#m": ["itguys.com/IT/Support/Hardware", "itguys.com/General/Announcements", "itguys.com/General/New Users", "itguys.com/Social/Memes"] }`) | 69 | 2. Forums. (e.g. General/Support subforum at itguys.com forum |
| 74 | 3. Clients wishing to filter out all the noise from public events may choose to only subscribe to multicast groups. Apps/games/bots leveraging Nostr may prefer communicating over a multicast group to avoid collision with the broader public. | 70 | `{ "#fr": ["itguys.com"], "#sb": ["General/Support"] }`) |
| 75 | 4. A hard-to-guess multicast group can be used for increased (but not total) privacy over a trusted relay. A "channel-hopping" algorithm shared by clients may improve privacy in this scenario where a channel is a multicast group. | 71 | 3. Clients wishing to filter out all the noise from the broad public events may |
| 76 | 5. Two or more parties may initiate contact publicly using Direct Messaging and agree privately on a hard-to-guess multicast group before continuing their exchange hiding further metadata from being leaked to the public. Parties can re-negotiate a new hard-to-guess multicast group at any point. | 72 | choose to only subscribe to events with restricted tags. Apps/games/bots leveraging |
| 77 | 6. Live events can take advantage of ephemeral events and previously-shared multicast group for communication during the event. | 73 | Nostr may prefer communicating using NIP-27 to namespace their communications. |
| 78 | 7. Smart contracts may communicate in privacy-preserving way with individual clients using unique short-lived multicast groups. | 74 | 4. A restricted tag with a hard-to-guess value can be used for increased isolation |
| 79 | 8. Clients interested in Bitcoin prices in USD may subscribe to the multicast group "prices:btc:usd". Many providers may publish their events to the same multicast groups. | 75 | in communications without the expectation of privacy. A "channel-hopping" algorithm |
| 80 | 9. Testnet-like multicast group for debugging in Nostr. | 76 | shared by clients may improve isolation in this scenario. |
| 77 | 5. Two or more parties may initiate contact publicly using Direct Messaging to then | ||
| 78 | upgrade their communications to using events with restricted tags with a hard-to-guess | ||
| 79 | value before continuing their exchange. Parties can re-negotiate a new hard-to-guess | ||
| 80 | value at any point. | ||
| 81 | 6. Live events can take advantage of ephemeral events and events with restricted | ||
| 82 | tags for exclusivity during the event. | ||
| 83 | 7. Smart contracts may communicate with individual clients using events with | ||
| 84 | restricted tags. | ||
| 85 | 8. Developers debugging in Nostr can use events with restricted tags to avoid spamming | ||
| 86 | others in public relays. | ||
| 87 | |||
| 81 | 88 | ||
| 82 | # Notes | 89 | # Notes |
| 83 | 90 | ||
| 84 | 1. Events sent to multicast groups should be considered public, after all they are readable by relays and can also be reshared by any client subscribed to the multicast group. | 91 | 1. Events with restricted tags are public and offer no privacy. |
| 85 | 2. Multicast groups are not a replacement for encrypted direct messages but can work in conjunction. | ||