Back to Blockchain

Nostr Protocol Overview

October 10, 20256 min read

Nostr Protocol Overview

Nostr (Notes and Other Stuff Transmitted by Relays) is a simple, open protocol for decentralized social networking.

Core Concepts

Unlike traditional blockchain-based systems, Nostr takes a different approach:

Events and Messages

Everything in Nostr is an event. Events are signed JSON objects:

{
  "id": "event_id",
  "pubkey": "author_public_key",
  "created_at": 1234567890,
  "kind": 1,
  "content": "Hello, Nostr!",
  "sig": "signature"
}

Relays

Relays are simple WebSocket servers that:

  • Accept events from clients
  • Store events (optional)
  • Forward events to other clients
  • Filter events based on subscriptions

Why Nostr?

Simplicity: No blockchain, no mining, no consensus Censorship resistance: Multiple relays mean no single point of failure Identity: Public/private key pairs instead of usernames

Technical Implementation

Setting up a basic relay:

func handleWebSocket(w http.ResponseWriter, r *http.Request) {
    conn, _ := upgrader.Upgrade(w, r, nil)
    defer conn.Close()
    
    for {
        var msg Message
        conn.ReadJSON(&msg)
        
        if msg.Type == "EVENT" {
            if verifySignature(msg.Event) {
                storeEvent(msg.Event)
                broadcastEvent(msg.Event)
            }
        }
    }
}

Challenges and Trade-offs

  • Spam prevention: Without proof-of-work, relays must implement their own filters
  • Data persistence: Users rely on relays to keep their data
  • Discovery: Finding the right relays can be challenging

The Future

Nostr demonstrates that decentralized social media doesn't require complex blockchain infrastructure—simple protocols can be powerful.