A place to cache linked articles (think custom and personal wayback machine)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.md 11KB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. title: nostr - Notes and Other Stuff Transmitted by Relays
  2. url: https://github.com/fiatjaf/nostr
  3. hash_url: af26cb6361904f154ea71e2c5b2271cc
  4. The simplest open protocol that is able to create a censorship-resistant global "social" network once and for all.
  5. It doesn't rely on any trusted central server, hence it is resilient; it is based on cryptographic keys and signatures, so it is tamperproof; it does not rely on P2P techniques, therefore it works.
  6. This is a work-in-progress. [Join the Telegram group!](https://t.me/nostr_protocol)
  7. ## Very short summary of how it works, if you don't plan to read anything else:
  8. Everybody runs a client. It can be a native client, a web client, etc. To publish something, you write a post, sign it with your key and send it to multiple relays (servers hosted by someone else, or yourself). To get updates from other people, you ask multiple relays if they know anything about these other people. Anyone can run a relay. A relay is very simple and dumb. It does nothing besides accepting posts from some people and forwarding to others. Relays don't have to be trusted. Signatures are verified on the client side.
  9. ## This is needed because other solutions are broken:
  10. ### The problem with Twitter
  11. - Twitter has ads;
  12. - Twitter uses bizarre techniques to keep you addicted;
  13. - Twitter doesn't show an actual historical feed from people you follow;
  14. - Twitter bans people;
  15. - Twitter shadowbans people.
  16. - Twitter has a lot of spam.
  17. ### The problem with Mastodon and similar programs
  18. - User identities are attached to domain names controlled by third-parties;
  19. - Server owners can ban you, just like Twitter;
  20. - Migration between servers is an afterthought and can only be accomplished if servers cooperate. It doesn't work in an adversarial environment (all followers are lost);
  21. - There are no clear incentives to run servers, therefore they tend to be run by enthusiasts and people who want to have their name attached to a cool domain. Then, users are subject to the despotism of a single person, which is often worse than that of a big company like Twitter, and they can't migrate out;
  22. - Since servers tend to be run amateurishly, they are often abandoned after a while — which is effectively the same as banning everybody;
  23. - It doesn't make sense to have a ton of servers if updates from every server will have to be painfully pushed (and saved!) to a ton of other servers. This point is exacerbated by the fact that servers tend to exist in huge numbers, therefore more data has to be passed to more places more often;
  24. - For the specific example of video sharing, ActivityPub enthusiasts realized it would be completely impossible to transmit video from server to server the way text notes are, so they decided to keep the video hosted only from the single instance where it was posted to, which is similar to the Nostr approach.
  25. ### The problem with SSB (Secure Scuttlebutt)
  26. - It doesn't have many problems. I think it's great. In fact, I was going to use it as a basis for this, but
  27. - its protocol is too complicated because it wasn't thought about being an open protocol at all. It was just written in JavaScript in probably a quick way to solve a specific problem and grew from that, therefore it has weird and unnecessary quirks like signing a JSON string which must strictly follow the rules of [_ECMA-262 6th Edition_](https://www.ecma-international.org/ecma-262/6.0/#sec-json.stringify);
  28. - It insists on having a chain of updates from a single user, which feels unnecessary to me and something that adds bloat and rigidity to the thing — each server/user needs to store all the chain of posts to be sure the new one is valid. Why? (Maybe they have a good reason);
  29. - It is not as simple as Nostr, as it was primarily made for P2P syncing, with "pubs" being an afterthought;
  30. - Still, it may be worth considering using SSB instead of this custom protocol and just adapting it to the client-relay server model, because reusing a standard is always better than trying to get people in a new one.
  31. ### The problem with other solutions that require everybody to run their own server
  32. - They require everybody to run their own server;
  33. - Sometimes people can still be censored in these because domain names can be censored.
  34. ## How does Nostr work?
  35. - There are two components: __clients__ and __relays__. Each user runs a client. Anyone can run a relay.
  36. - Every user is identified by a public key. Every post is signed. Every client validates these signatures.
  37. - Clients fetch data from relays of their choice and publish data to other relays of their choice. A relay doesn't talk to another relay, only directly to users.
  38. - For example, to "follow" someone a user just instructs their client to query the relays it knows for posts from that public key.
  39. - On startup, a client queries data from all relays it knows for all users it follows (for example, all updates from the last day), then displays that data to the user chronologically.
  40. - A "post" can contain any kind of structured data, but the most used ones are going to find their way into the standard so all clients and relays can handle them seamlessly.
  41. ## How does it solve the problems the networks above can't?
  42. - **Users getting banned and servers being closed**
  43. - A relay can block a user from publishing anything there, but that has no effect on them as they can still publish to other relays. Since users are identified by a public key, they don't lose their identities and their follower base when they get banned.
  44. - Instead of requiring users to manually type new relay addresses (although this should also be supported), whenever someone you're following posts a server recommendation, the client should automatically add that to the list of relays it will query.
  45. - If someone is using a relay to publish their data but wants to migrate to another one, they can publish a server recommendation to that previous relay and go;
  46. - If someone gets banned from many relays such that they can't get their server recommendations broadcasted, they may still let some close friends know through other means with which relay they are publishing now. Then, these close friends can publish server recommendations to that new server, and slowly, the old follower base of the banned user will begin finding their posts again from the new relay.
  47. - All of the above is valid too for when a relay ceases its operations.
  48. - **Censorship-resistance**
  49. - Each user can publish their updates to any number of relays.
  50. - A relay can charge a fee (the negotiation of that fee is outside of the protocol for now) from users to publish there, which ensures censorship-resistance (there will always be some Russian server willing to take your money in exchange for serving your posts).
  51. - **Spam**
  52. - If spam is a concern for a relay, it can require payment for publication or some other form of authentication, such as an email address or phone, and associate these internally with a pubkey that then gets to publish to that relay — or other anti-spam techniques, like hashcash or captchas. If a relay is being used as a spam vector, it can easily be unlisted by clients, which can continue to fetch updates from other relays.
  53. - **Data storage**
  54. - For the network to stay healthy, there is no need for hundreds of active relays. In fact, it can work just fine with just a handful, given the fact that new relays can be created and spread through the network easily in case the existing relays start misbehaving. Therefore, the amount of data storage required, in general, is relatively less than Mastodon or similar software.
  55. - Or considering a different outcome: one in which there exist hundreds of niche relays run by amateurs, each relaying updates from a small group of users. The architecture scales just as well: data is sent from users to a single server, and from that server directly to the users who will consume that. It doesn't have to be stored by anyone else. In this situation, it is not a big burden for any single server to process updates from others and having amateur servers is not a problem.
  56. - **Video and other heavy content**
  57. - It's easy for a relay to reject large content, or to charge for accepting and hosting large content. When information and incentives are clear, it's easy for the market forces to solve the problem.
  58. - **Techniques to trick the user**
  59. - Each client can decide how to best show posts to users, so there is always the option of just consuming what you want in the manner you want — from using an AI to decide the order of the updates you'll see to just reading them in chronological order.
  60. ## FAQ
  61. - **This is very simple. Why hasn't anyone done it before?**
  62. I don't know, but I imagine it has to do with the fact that people making social networks are either companies wanting to make money or P2P activists who want to make a thing completely without servers. They both fail to see the specific mix of both worlds that Nostr uses.
  63. - **Can I know how many people are following me?**
  64. No, but you can get some estimates if relays cooperate in an extra-protocol way.
  65. ## Protocol specification
  66. See the [NIPs](nips) and especially [NIP-01](nips/01.md) for a reasonably-detailed explanation of the protocol spec (hint: it is very short and simple).
  67. ## Small list of software that implement the Nostr protocol somehow
  68. ### Relays
  69. - [NNostr](https://github.com/Kukks/NNostr), a C# Nostr relay.
  70. - [nostr-rs-relay](https://sr.ht/~gheartsfield/nostr-rs-relay/), a minimalistic relay written in Rust that saves data on SQLite.
  71. - [Relayer Basic](https://github.com/fiatjaf/relayer/tree/master/basic), a simple relay based on _relayer_ backed by Postgres.
  72. - [rsslay](https://github.com/fiatjaf/rsslay), a bridge that puts RSS feeds into Nostr.
  73. - [nodestr](https://github.com/Dolu89/nodestr-relay), A Node.js implementation.
  74. ### Clients
  75. - [branle](https://github.com/fiatjaf/branle), a Twitter-like client also with chat.
  76. - [noscl](https://github.com/fiatjaf/noscli), a basic command-line client written in Go.
  77. - [nostr-chat](https://github.com/emeceve/nostr-chat), a desktop app written in Rust for direct encrypted chat.
  78. - [chastr](https://github.com/dolu89/chastr), a mobile directed encrypted chat app written in Xamarin.
  79. - [nostr-twitter](https://github.com/arcbtc/nostr), a Twitter-like UI that also implements private direct messages.
  80. ### Libraries
  81. - [NNostr.Client](https://github.com/Kukks/NNostr), a C# Nostr library for use by clients.
  82. - [nostr-tools](https://github.com/fiatjaf/nostr-tools), a JavaScript client that abstracts the relay management code for use by clients.
  83. - [go-nostr](https://github.com/fiatjaf/go-nostr), a Go library that implements relay management, plus event encoding and signing utils.
  84. - [nostr-rs](https://github.com/futurepaul/nostr-rs), a Rust implementation of the nostr protocol.
  85. - [relayer](https://github.com/fiatjaf/relayer), a server framework for writing custom relays.
  86. ### Tools
  87. - [nostr relay registry](https://nostr-registry.netlify.app/), real-time checking of status of some known relays.
  88. - [nostr registry](https://codeberg.org/rsbondi/nostr-registry), a database of known relays with their uptime and NIP support tables.
  89. - [nostr-launch](https://codeberg.org/rsbondi/nostr-launch), a tool for launching a bunch of relays and clients locally for development and testing.
  90. ## License
  91. Public domain.