-
Notifications
You must be signed in to change notification settings - Fork 7
docs: protocol v2 (NIP-44 direct) transport — Phase 3 #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c5d61d0
docs: protocol v2 (NIP-44 direct) transport — Phase 3
grunch 8cda773
docs: rename info tag protocol_versions -> protocol_version
grunch 6bcc566
docs: address review — NIP-40 expiration wording + clarify inner-null…
grunch 2d9faa3
Merge pull request #49 from MostroP2P/fix/protocol-version-singular
grunch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Transport migration (v1 → v2) | ||
|
|
||
| Mostro is moving its wire transport from **protocol v1** (NIP-59 gift wrap, | ||
| kind `1059`) to **protocol v2** (NIP-44 direct message, kind `14`). This | ||
| page is the practical guide for **client developers**: what changes, how to | ||
| detect which transport a node speaks, and how to support both during the | ||
| transition. | ||
|
|
||
| The logical messages, key derivation, indexing and rotation rules are | ||
| unchanged — only the envelope differs. The two formats are documented | ||
| side by side in [Keys management](./key_management.md) (the v2 wire format | ||
| is under *Protocol v2 — NIP-44 direct messages*) and the message tuples in | ||
| [Overview](./overview.md#the-content-array-v1-vs-v2). | ||
|
|
||
| ## Why the change | ||
|
|
||
| Gift wraps give strong metadata privacy, but their outer event is signed by | ||
| a random throwaway key, so neither relays nor the daemon can tell legitimate | ||
| traffic from garbage without paying the full NIP-44 decrypt cost — a spam | ||
| flood ("Gift Wrap Apocalypse") cannot be rate-limited by sender. Protocol v2 | ||
| makes the **trade key** the visible author of the event. Because trade keys | ||
| are already single-trade and rotated, exposing one leaks little, while | ||
| enabling relay-side rate limiting by sender and cheap daemon-side | ||
| pre-validation before decryption. See the threat model in | ||
| [issue #626](https://github.com/MostroP2P/mostro/issues/626). | ||
|
|
||
| ## Capability discovery | ||
|
|
||
| A node speaks **exactly one** transport — there is no dual mode. It | ||
| advertises which in its [instance-info event](./other_events.md#mostro-instance-status) | ||
| (kind `38385`) via the `protocol_version` tag: | ||
|
|
||
| - `["protocol_version", "1"]` → gift wrap (kind `1059`) | ||
| - `["protocol_version", "2"]` → NIP-44 direct (kind `14`) | ||
|
|
||
| A client should read this tag **before** sending anything and use the | ||
| matching wire format. Old daemons that predate the tag emit nothing; treat | ||
| their absence as v1. | ||
|
|
||
| ## What a client must change | ||
|
|
||
| 1. **Read `protocol_version`** from the node's kind-`38385` event and | ||
| branch on it. | ||
| 2. **Subscribe to the right kind**: `1059` for v1, `14` for v2 (authored by | ||
| the node, `#p`-tagged to your trade keys for node replies). | ||
| 3. **Wrap/unwrap with the matching path.** `mostro-core` **0.13.0** ships | ||
| both — `wrap_message_with(transport, …)` / `unwrap_incoming(event, …)` | ||
| dispatch on the transport (or event kind), so a client holding both | ||
| paths needs only to pass the node's transport. | ||
| 4. **Set `version: 2`** in the message on the v2 transport (`1` on v1). | ||
| 5. **On v2, build the 3-element content tuple** — message, trade signature | ||
| (or `null`), identity proof `["<identity pubkey>", "<identity sig>"]` (or | ||
| `null` for full-privacy mode). The identity proof is a signature over the | ||
| domain-tagged payload `mostro-transport-v2-identity:<trade pubkey hex>:<message JSON>`; | ||
| see [Keys management → Identity proof](./key_management.md#identity-proof). | ||
| 6. **On v2, add a NIP-40 `expiration` tag** to outgoing events. Mostro fills | ||
| a default (the node's `dm_days`, 30 days) on its own messages when none | ||
| is supplied. | ||
|
|
||
| Full-privacy mode and reputation mode work the same way as in v1: omit the | ||
| identity key (proof and trade signature both `null`) for full privacy, or | ||
| include them to maintain reputation. | ||
|
|
||
| ## Release timeline | ||
|
|
||
| - **v0.18.0** — protocol v2 ships. Default `transport = "gift-wrap"`, so | ||
| nothing changes for existing clients. **Protocol v1 is DEPRECATED.** | ||
| Client developers have the 0.18.x cycle to ship v2 support. | ||
| - **v0.19.0** — protocol v2 becomes the **default and only** protocol. | ||
| mostrod removes the v1 path entirely. `mostro-core` keeps its gift-wrap | ||
| helpers so clients can still migrate at their own pace, but nodes will no | ||
| longer accept kind-`1059` traffic. | ||
|
|
||
| The recommendation is therefore: **keep both wrap paths now** and select per | ||
| node from `protocol_version`. A client that supports both will work against | ||
| every node throughout the transition, and against v2-only nodes after the | ||
| v0.19.0 cutover with no further change. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.