We are beginning the development process for transmitting Nostr events in a peer-to-peer fashion, away from relays. This will start with Gift-wrapped DMs, Private Attachments, Private zaps, Private Text Notes, and Private Reactions; and will be the preferred transmission choice if both users are online, falling back to relays when they are not. Our Push Notification system already transmitted over 500,000 GiftWrapped Nostr events that relays will never see. With a full P2P this will get even better and will open the doors for voice and video calls directly inside Amethyst. Side-stepping relays won't be easy or quick. And I am sure we will get strong pushback from relay operators. But we will get there. And while this might start as an Amethyst feature, it will be a NIP and other clients will be able to join the privacy train. Nostr is just starting.

Replies (134)

But it’s the difference between a distributed and decentralised network. Distributed is P2P and it has even more trade offs than decentralised networks. There are no free lunches
nostr is already distributed and not p2p except for relays trade offs are being worked on, we also have more compute and network resoirces than ever
I could see P2P transmission as being super neat for near-instant messaging. Not sure if it is a good idea for broadcasting notes to all followers, but there are definitively use cases where I would love that. Please do consider documenting it - even if not in the nips repo - for easier referencing when developing something based on this! ^^ IMO Nostr lives and dies from it's documentation. It is why there are so few Matrix clients, because the Matrix docs are a PITA...
then you either dont understand nostr or distributed i am not going to bother with that silly article btw tho it likely agrees with me 'To distribute is to disperse widely, hand out, or spread around' how are nostr notes distributed? how can nostr notes be distributed? are nostr notes on a wide variety of servers? are nostr notes handed out widely to relays? can i put nostr notes on a usb stick and give them to a friend? can that friend send those notes from that usb stick to a relay? can 500 other relays download those notes from that relay? can 1million people download those notes from those relays? how is nostr distributed?
many mobile networks work p2p, mobiles also have wifi, starlink lol there will be nsa datacenter peers to use, its what american tax victims pay for
someone's avatar
someone 2 years ago
Relays are public and shouldn't involve with private things yes. I support this. What if I use both Amethyst (mobile) and Primal (desktop)? Primal will not be in sync with my private communications.
This is why I think we can succeed. The relay infrastructure will always be there to be a fallback. The P2P stuff is an additional layer of privacy to be used when 2 phones are able to reliably connect with one another.
So, passing over Bluetooth and internal WIFI is very easy (which was my first test a few weeks ago). I just started doing some WebRTC tests and looking at some server alternatives and signaling needs. It works but I am very early in this whole adventure. I looked at Rendez-vouz as well and I was wondering can't we just pass the signaling through our usual relays instead? Maybe we still need some type of STUN server to get the phone's IP and as long as two users can use different STUN servers, it could work. What I want to avoid is replacing our replays with a different "relay". If we need to use a server to transfer some info we can just use our regular relays instead to avoid another dependency/attacking point.
User 1 sends the event to User 2 via P2P instead of pushing through a relay. Then User 2 can send to any relay it wants for backup and to share with other clients the same user uses. Amethyst would just send it to your own write relays for backup for now. And we could have an option to turn that off for the privacy-conscious users. In that case, no event received via P2P ever leaves the phone.
The point of simplex is the async queues which you can’t replace with p2p tech. Nostr is missing the ephemeral push-pull queue idea
No, I am just testing things out for now. WebRtc seems to work, but I want to get rid of these servers they use for signaling and use giftWrapped msgs in Nostr for that. I'm might have multiple layers. Bluetooth, WIFI for those physically close to one another and some version of WebRtc for the rest.
Let me get this straight, will only private events be p2p? Because in your initial note you say that this movement starts with private events, which made me understand that in the future all events would be p2p. If only private p2p events and public notes continue to be transmitted via relays, at this point I support the idea. I believe that this way the scroll feed experience does not change.
I think I understand now. So I really don't see any problem for the relay operators, nor for the feed experience 🤷‍♂️ Looking forward to the new private events 🚀
Probably will at least create more confusion in the clients that already causes issues. What other clients are already planing this with yours?
Sounds like combining the best of both decentralized approaches, great take. I think Nostr should stay open to innovations like this.
> How do you decide which peers to sync with on Amethyst P2P? There are so many users. It can be done, here's just an example: It should be possible to generate an onion address keypair algorithmically from the recipient's Nostr keypair, in a manner that is reproducible on sender-side using only the public key. Roughly similar to how Bitcoin HD wallets (xprv/xpub) work. There are probably some privacy footnotes with this method, but would give you 100% accurate peer discovery without an intermediary. Just to be clear, none of this exists. It's only an example of how it could be done.
All for Nostr privacy improvements. This will probably be one of those fundamental design choices which look obvious in hindsight and baffling that it wasn't included in the first or second drafts of the protocol. Then again this could fail spectacularly with users' phones filling up to the brim or connections almost always falling back to relays, with months and months of dev hours wasted for basically nothing. But what do I know, I'm just your friendly hoodlum in these cyphers. Interested to see how all this unwinds. View quoted note →
We will need to go binary for voice and video calls. But for the messages that are just simple nostr events, I am not sure if it makes sense since the event is already in text.🤔
Haha's avatar
Haha 2 years ago
🤔🤔🤔🤔🤔
This is a big challenge, support. Nostr now allows anyone to see who you're talking to through your public key, even if you can't see what we're talking about. It's not nice to have a private chat party in a glass room in the square where everyone can see. Better protection of privacy would be a huge step forward.💜🫂
pjv's avatar
pjv _@pjv.me 2 years ago
You must look at veilid. https://veilid.com/docs/overview/ "Veilid is an open-source, peer-to-peer, mobile-first, networked application framework. The framework is conceptually similar to IPFS and Tor, but faster and designed from the ground-up to provide all services over a privately routed network. The framework enables development of fully-distributed applications without a 'blockchain' or a 'transactional layer' at their base. The framework can be included as part of user-facing applications or run as a 'headless node' for power users who wish to help build the network."
0xDEADC0DE's avatar
0xDEADC0DE 2 years ago
Is this available in China? Push service against GFW…
does anyone know they should save their data themselves ? This is the only point that bother me in this 😉
View quoted note → Nostr is about censorship resistance and at least for me, the most challenging mode of censorship resistance is censorship resistant broadcast. Avoiding meta data leak in encrypted transmission is a different problem to solve and nostr trying to solve the former would have to compromise on that to solve the latter. Therefore I believe Gift-wrapped DMs and "full P2P" is potentially harming nostr.
Async queues could fit nicely into relays. The queues are a really interesting solution in my opinion and I wonder where is that applicable in Bitcoin or Nostr space...
DZC's avatar
DZC 2 years ago
So, would your IP be shared with your peers? That doesn't initially look too good for privacy. Looking forward to learning more about this 'protocol'. 🫂
I understand. But I don't have a use for that yet. It's a nice to have in my bucket. P2P is a must though. The whole point of p2p is to transfer private content without any servers involved.
You pretty much always need servers to holepunch connections at the very least. Not to mention its also pretty rare to have two clients online at the same time to establish p2p comms. Even in that case you may still need bridge servers.
Given these difficulties a temporary queue of messages would be much more reliable and just as private, if auth was required from the get go.
You need servers for P2P signaling, yes. But that signaling doesn't need async queues. I also question the assumption that two users are not online. They might not start online, but as soon as one messages the other, both stay online for the length of the conversation. And if you do push notifications, like we do, you can get the other user online in seconds. If both are online they don't need relays at all.
Hmm. How are you going to achieve this and stay interoperable with other clients? I assume the fallback transmission you mentioned? Also, would this be utilizing nostrdb, so that users essentially use their own relay and communicate to other's via their own local relays? Is there a gossip model being used? So many questions. Is there an external discussion that I can see and randomly yell into?
I think it’s fair to say amethyst is not going to be very compatible with other clients going forward. I highly doubt anyone would build around his centralized push server as a core protocol mechanism.
Simple, if two users are using compatible P2P implementations, they can transfer their events via P2P, if not it goes through relays as usual. On a conversation via DMs for instance, I would assume the first DM comes in via relays and then moves to P2P when the person replies. The likelyhood of the two users being online is higher there. Then no additional DM goes through relays anymore, increasing privacy. Of course, each user can receive the message via P2P and still send to relays for backup, but that is the receving user's choice, not the sender.
Two peers behind nats need a server to coordinate/holepunch connections. This is pretty standard knowledge when building p2p stuff. What is this magic serverless tech you are using? Establishing p2p connections is a very hard problem with many nat variations to get around.
Usually yes, but not in a DM conversation. After the first messages, its more likely that both are online. And we will need both online for voice and video calls anyway.. so..
Default avatar
nobody 2 years ago
Man I need someone to explain this to me like I’m 5
And we already have push notifications if we need to wake them up again. But our tests suggest that people don't leave amethyst when waiting for a DM. They just move to the feed. Which is perfect for this.
Well I don’t wish your idea ill anyways. I’d be doing a disservice if I didn’t voice my concerns, but working code trumps theory. We will see. As long as it doesn’t break compatibility with other clients (fallback).
It shouldnt break, just open a new way for exchanging events. But I still have lots to test. I will likely be doing Bluetooh, WIFI and WebRTC implementations, so there will be 3 new ways to share the event. But one at a time.
Wow, respect! This sounds amazing! really looking forward to the future of #NOSTR Means we can take over everything in communication with any possible device that has access to the inet. Sounds like fun. View quoted note →
The general principle is there is a server that both parties rendesvouz through. It gets packets from both parties that connect to it. It can see in the packets the IP address, port, and other header junk needed for NAT in order to talk back to both parties. It sends that data to the parties themselves so they can talk directly to each other using those same NAT holes that were punched outbound to the server, while the server holds that open. This works everywhere including over CGNAT, double NAT, etc.
Ok, this is what I am testing.. Dont take this as a final solution. First: IPv6. On IPv4, you have to deal with NAT travel + firewall holepunch. With IPv6, the NAT stuff is gone. All you need is a simple STUN server to open the connection. Second: We can use Nostr to signal people's IPv6+port to one another. Once that is done, both sides start sendind UDP messages over IPv6 to each other. The first 2 messages should be rejected because of the firewall, but after that the door is open. We try this until we hear a package back. Now, the beauty of Nostr is that somebody is always online. Which means other phones can behave as STUN servers to open people's firewals more easily. The goal is to use network effects to avoid the need for central servers. Market participants can add their computers or phones to the pool by just replying the Nostr signaling requests. It's like a STUN server as a DVM. Lots to test, but that was the idea.
what if.. forget about STUN for a second, it isn't gonna work for most peers (esp mobile carrier networks). You could support ipv* by 'relays' running coturn and forcing the use of the turn server vs. stun would not expose IP info between the peers. Coturn has all the stun options, so if a peer was willing, they could opt in to the IP disclosure and achieve a true P2P connection. multi hops could also be implemented, by using wireguard networks with relays being a 'hop' server.
Yeah that's the easy way to do it. But I think we can do it without coturn. Most of what coturn implements is for the old nat stuff. There days everyone has an IPv6. Só it should be easier.
"These days everyone has an IPv6" - don't think that's the case at all. Most countries seem to be running at around 50-60% deployment, and that's only showing allocated IPv6 that doesn't mean configured and in use.
I have implemented the calling service in 0xchat, but using the traditional technical solution: Relay signaling+WebRTC+STUN+TURN. I’m looking forward to your experimental results. :)
Google’s STUN and our own built STUN/TURN service, followed by support users to input their owned services, similar to the approach of Simplex
Let's hope you can. It's been in deployment for ~20 years! Maybe you're mixing cellular and fixed line services. On cellular, the figures are likely higher but on fixed line they're also likely lower. Mobile users aren't, most the time, using a cellular connection though, they're using WiFi. https://ipv6-test.com/stats/