From 2e4823fa02f9baf7666f4253a55079d4fb0bcd40 Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Thu, 23 Jan 2025 13:22:52 -0800 Subject: [PATCH 1/4] Add NIP-4A Event Onion Routing --- 4A.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 4A.md diff --git a/4A.md b/4A.md new file mode 100644 index 0000000000..a552638bd6 --- /dev/null +++ b/4A.md @@ -0,0 +1,41 @@ +NIP-4A +====== + +Event Onion Routing +------------------- + +`draft` `optional` + +This NIP defines a way for a client to indirectly publish events to a relay by onion routing the event through peers willing to route it. This helps preserve the privacy of a client's network metadata. + +``` + --> [Relay-1] --> --> [Relay-2] --> +``` + +Alice wants to send an event to *Bob*, but not reveal her IP address to *Relay-2*. Another client, *Router*, has offered to provide an onion routing service. This allows Alice to encrypt her message to *Router* and send it through *Relay-1*. *Router* decrypts the message and publishes it to *Relay-2* for *Bob*. + +This is not perfect network privacy. There is a chance that the relays are operated by the same party or two colluding parties. Alice may choose to introduce different routers on the path to increase the difficulty of detection, at the cost of performance. + +## Routing an Event + +Kind `20444` is an onion route request event. The event MUST include a `p` tag specifying the router to route the event. The `content` is encrypted for the router using [NIP-44](44.md) encryption. The `content` MUST contain an `event` to publish as well as at least one `relay` to target. + +``` +{ + "kind": 20444, + "content": nip44_encrypt("[ + [ "event", "" ], // required event to publish + [ "relay", "wss://example1.com" ] // required relay to target + [ "ecash", "" ], // optional ecash incentive with ecash proof and mint info + ]") + "tags": [ + [ "p", "" ] + ] +} +``` + +Multiple `event`s and `relays` MAY be provided. Every given `event` SHOULD be published to every gieven `relay`. + +OPTIONAL `ecash` may be provided as incentive for the router. + +The routing event could use a [NIP-59](59.md) gift wrap to hide that it is a routing request, but the effectiveness would vary depending on if a router's pubkey is well known as an onion router. From d0a0c4b4ea80c90219e344a4b597aafa2dc0921c Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Thu, 23 Jan 2025 14:38:50 -0800 Subject: [PATCH 2/4] Add regular event --- 4A.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/4A.md b/4A.md index a552638bd6..5856e4cb9f 100644 --- a/4A.md +++ b/4A.md @@ -18,7 +18,9 @@ This is not perfect network privacy. There is a chance that the relays are opera ## Routing an Event -Kind `20444` is an onion route request event. The event MUST include a `p` tag specifying the router to route the event. The `content` is encrypted for the router using [NIP-44](44.md) encryption. The `content` MUST contain an `event` to publish as well as at least one `relay` to target. +Kind `2444` and `20444` are onion route request events. They are the exact same except `2444` is regular while `20444` is ephemeral. Regular events give another dimension for the sender to manipulate in order to disrupt time-based deanonymization attempts. + +The event MUST include a `p` tag specifying the router to route the event. The `content` is encrypted for the router using [NIP-44](44.md) encryption. The `content` MUST contain an `event` to publish as well as at least one `relay` to target. ``` { @@ -34,8 +36,8 @@ Kind `20444` is an onion route request event. The event MUST include a `p` tag s } ``` -Multiple `event`s and `relays` MAY be provided. Every given `event` SHOULD be published to every gieven `relay`. +Multiple `event`s and `relays` MAY be provided. Every given `event` SHOULD be published to every given `relay`. -OPTIONAL `ecash` may be provided as incentive for the router. +An OPTIONAL `ecash` tag containing a token proof and mint information may be provided as incentive for the router. The routing event could use a [NIP-59](59.md) gift wrap to hide that it is a routing request, but the effectiveness would vary depending on if a router's pubkey is well known as an onion router. From bab3b03be138771da26a71f5ef6dcd755f5146f6 Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Fri, 24 Jan 2025 11:20:36 -0800 Subject: [PATCH 3/4] Add replaceable announcement event --- 4A.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/4A.md b/4A.md index 5856e4cb9f..65f33068db 100644 --- a/4A.md +++ b/4A.md @@ -41,3 +41,22 @@ Multiple `event`s and `relays` MAY be provided. Every given `event` SHOULD be pu An OPTIONAL `ecash` tag containing a token proof and mint information may be provided as incentive for the router. The routing event could use a [NIP-59](59.md) gift wrap to hide that it is a routing request, but the effectiveness would vary depending on if a router's pubkey is well known as an onion router. + +## Router Announcement + +Kind `10690` are replaceable router announcement events which allow routers to be discovered by senders. The `relay` tag is a relay where the router listens for onion routing requests. The event MUST include at least one `relay`. + +The event MAY include fee requirements. The `ecash` tag contains a supported ecash protocol. The `fee` tag gives the amount and denomination per event per relay. For example, if a one sat fee is set and a routing request contains two events and three relays, the total fee required is six sats. + +``` +{ + "kind": 10690, + "tags": [ + [ "relay", "wss://example1.com" ], + [ "relay", "wss://example2.com" ], + [ "fee", "1", "sat" ], + [ "ecash", "cashu" ] + ], + "pubkey": +} +``` From 44decb768772be53cd6ffa8438c39f4df0d86ad1 Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Fri, 24 Jan 2025 14:52:00 -0800 Subject: [PATCH 4/4] Remove optional ecash --- 4A.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/4A.md b/4A.md index 65f33068db..d67bb740c8 100644 --- a/4A.md +++ b/4A.md @@ -28,7 +28,6 @@ The event MUST include a `p` tag specifying the router to route the event. The ` "content": nip44_encrypt("[ [ "event", "" ], // required event to publish [ "relay", "wss://example1.com" ] // required relay to target - [ "ecash", "" ], // optional ecash incentive with ecash proof and mint info ]") "tags": [ [ "p", "" ] @@ -38,24 +37,18 @@ The event MUST include a `p` tag specifying the router to route the event. The ` Multiple `event`s and `relays` MAY be provided. Every given `event` SHOULD be published to every given `relay`. -An OPTIONAL `ecash` tag containing a token proof and mint information may be provided as incentive for the router. - The routing event could use a [NIP-59](59.md) gift wrap to hide that it is a routing request, but the effectiveness would vary depending on if a router's pubkey is well known as an onion router. ## Router Announcement Kind `10690` are replaceable router announcement events which allow routers to be discovered by senders. The `relay` tag is a relay where the router listens for onion routing requests. The event MUST include at least one `relay`. -The event MAY include fee requirements. The `ecash` tag contains a supported ecash protocol. The `fee` tag gives the amount and denomination per event per relay. For example, if a one sat fee is set and a routing request contains two events and three relays, the total fee required is six sats. - ``` { "kind": 10690, "tags": [ [ "relay", "wss://example1.com" ], [ "relay", "wss://example2.com" ], - [ "fee", "1", "sat" ], - [ "ecash", "cashu" ] ], "pubkey": }