nostr-protocol / nips

Nostr Implementation Possibilities
2.31k stars 563 forks source link

Publish by peers #411

Open motorina0 opened 1 year ago

motorina0 commented 1 year ago

TL;DR:

One way to increase the privacy of Encrypted Direct Messages is for peers to derive new keys when they communicate. See this (draft) issue for more details.

Not all relays can be trusted

However, the relay(s) that Alice and Bob are connected to can learn that Alice and Bob are chatting.

The relay can see that Bob is subscribed to public keys to which Alice sends messages. Therefore it is trivial to deduce that Alice and Bob are having a private conversation.

Re-publisher

The concept is similar with that of a remailer [1]:

Cross relay re-publisher

The privacy can be increased even more if Alice uses one relay to communicate with Carol (Relay X), but Carol uses a different relay (Relay Y) to forwards the nostr event to Bob.

Notes:

References

[1] Untraceable Electronic Mail, Return Addresses, and Digital Pseudonyms [2] Time to live [3] cashu spec

fiatjaf commented 1 year ago

I like this a lot. I see a possible NIP for this as having a standardized very generic republish event with kind 20001 (ephemeral) in the form

{
  "kind": 20001,
  "content": "<encrypted JSON of the event that is to be republished>",
  "tags": [
    ["p", "<pubkey of the person that is chosen to republish this>"],
    ["relays", "wss://relay.com", "wss://otherrelay.com", "and so on, there could be many of these"]
  ]
}

Then whenever the chosen republisher sees a note like that they automatically decrypt it using NIP-04 method and publish it to the chosen relays.

People can easily run very lightweight republish services for free and provide anonymity for everybody else.

motorina0 commented 1 year ago

What is "encrypted-secret" used for in:

["p", "<pubkey of the person that is chosen to republish this>", "encrypted-secret"],
fiatjaf commented 1 year ago

Something that shouldn't have been present in that comment. I'll remove that.

motorina0 commented 1 year ago

NIP PR: https://github.com/nostr-protocol/nips/pull/430 Preview here

ghost commented 1 year ago

Very interesting, but how do we avoid sybil attacks on the "republisher" network? If a large entity just wanted to host tons of republishers, it could read the metadata of most forwarded messages.

And as Michael Hayden said, we kill people based on metadata, so I think we should first look into scrubbing the metadata from NIP-4 before implementing this

Also, what's there to stop the republishers from simply accepting, then dropping the events? Or what about trying to manipulate the event data? Or the ciphertext? Since it's encrypted using AES-256-CBC, rather than some Authenticated mode, it's hard to verify

Imo, we grant the republishers a lot of power, since you have to trust them with the entire event. Who says they're going to keep the public key and signature the same?

motorina0 commented 1 year ago

Very interesting, but how do we avoid sybil attacks on the "republisher" network? If a large...

  • the republish only makes sense in the context of DMs (encrypted data). For public data the identity of the publisher must be public.

it could read the metadata of most forwarded messages.

  • that is true if the events are published in the current NIP-04 form
  • however, there is a proposal (by me) here such that no metadata is revealed to the world

Also, what's there to stop the republishers from simply accepting, then dropping the events?

  • nothing, a re-publisher can do that
  • a re-publisher is not necessary a 3rd party service. It can be any of your peers (friend list) that signals that it wants to be a re-publishers
  • a user can choose many re-publishers (public ones, or a random subset of its friend list)
  • a client-side application (like coracle, iris, etc) can be a re-publisher while online. You too can be a re-publisher for your peers.

Or what about trying to manipulate the event data...

  • the content of the write event is encrypted with the shared secret
  • the wrapped event is hashed and signed
  • so the cryptographic functions (hash, sign and encrypt) guarantee that the data is not manipulated

Imo, we grant the republishers a lot of power, since you have to trust them with the entire event...

  • we do not, it is trustless
  • the same question can be asked of relays trying to manipulate data
earonesty commented 1 year ago

nip-59 gift-wrap dm's effectively scrub metadata. we should probably "bake that in" as an optional way to dm someone for security-minded people.