Skip to content
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

Add NIP-4A Event Onion Routing #1713

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions 4A.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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.

```
<Alice> --> [Relay-1] --> <Router> --> [Relay-2] --> <Bob>
```

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 `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.

```
{
"kind": 20444,
"content": nip44_encrypt("[
[ "event", "<event-as-json-string>" ], // required event to publish
[ "relay", "wss://example1.com" ] // required relay to target
]")
"tags": [
[ "p", "<pubkey-of-router>" ]
]
}
```

Multiple `event`s and `relays` MAY be provided. Every given `event` SHOULD be published to every given `relay`.

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`.

```
{
"kind": 10690,
"tags": [
[ "relay", "wss://example1.com" ],
[ "relay", "wss://example2.com" ],
],
"pubkey": <pubkey-of-router>
}
```