Introduction To nostr

Preface

By @AtropineTears with NightshadeLabs | 2 April 2022

Introduction

We live in a period of time where security and privacy are slowly eroding while censorship is becoming increasingly more prevalent. We live in a time where social media spies on us, selling our information to the world and top-bidding advertisers. We live in a time where you may get banned on twitter for just stating your beliefs. We already know the power of the internet and how much of an effect it can have on the world around us, but many of us are blissfully unaware of the problems inherent in the internet and social media as a whole.

Introducing nostr, a simple and easy to use platform for decentralized, censorship-resistant communications similar to twitter but with privacy, security, and censorship-resistant properties.

Features of nostr

Decentralization and Censorship-Resistance Proof

"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." - 1

Basically, every relay is independent and makes choices by itself. A relay can choose to block someone but then that person can easily just go to another relay that will not block them. Relays do not speak to each other. Instead, they only speak to users.

"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." - 1

No comment.

How Does It Work

Basics

Nostr works by using cryptographic keys and digital signatures so that posts are tamperproof and their integrity is intact. It uses two types of software, client and relay. The client is used to send events while the relay is used to get updates from other people. To publish something, you write the post, sign it with your key, and send it to multiple relays.

Every user is identified by their public key as opposed to usernames. Clients validate signatures for themselves as opposed to having relays verify them.

Clients fetch data from a relay of their choosing and publish data to the relay(s) of their choosing.

The interesting part about nostr is that any relay can choose how to best serve content to the user like using AI to better serve content in a more personalized manner.

Client

"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." - 1

A client is used to get resources from a relay.

Relays

Anyone can run a relay. - 1

A relay is very simple and dumb - 1

Relays expose a websocket endpoint to which clients can connect (using wss://). They can send three types of messages (but must be JSON Arrays).

A relay only talks to a user, not other relays.


Event.id

The Event ID is the SHA256 serialized event over UTF-8 JSON-serialized string

Event (Object)

The only object type that exists is the event. It contains:



Behind The Cryptography

Nostr uses Schnorr Signatures over secp256k1 curve using SHA256 hash function.[3] This is the same algorithm used by Bitcoin.

Schnorr signatures are provably secure, non-malleable, and linear.

Encoding and Serialization

Nostr uses UTF-8 JSON for serialization.

Types of Software

There are two types of software.

The client is run by everyone. The client can be a native client, web client, or other.

The relay is used to get updates from other people and is simplistic in design. In other word

Client

A Client can send 3 types of messages (must be JSON arrays) as specified in NIP-01 and which is extendable by other NIPS. The following 3 types of messages are:

[Message] Event

"The only object type that exists is the event" - 2

The event contains the following:

Summary of Important Information

Web API

Serialization

Cryptography

Communication Components

[Events] From Client-To-Relay (NIP-01)

[Events] From Relay-To-Client (NIP-01)

References

1. [Github] nostr

2. [Github] nostr - nip1

3. BIP340