aboutsummaryrefslogtreecommitdiffstats
path: root/website/index.html
blob: 194841d6f96f6c0546a2ff8dcf3a1a778af23e00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="A minimal Go library for Nostr. 1 dependency.">
  <meta name="go-import" content="code.northwest.io/nostr git https://code.northwest.io/nostr.git">
  <title>nostr — minimal Go library</title>
  <style>
    :root {
      --bg: #f5f2eb;
      --fg: #2c2c2c;
      --muted: #6b6b6b;
      --border: #d4d0c8;
      --code-bg: #eae7e0;
    }

    @media (prefers-color-scheme: dark) {
      :root {
        --bg: #1c1c1c;
        --fg: #e8e4dc;
        --muted: #888;
        --border: #333;
        --code-bg: #252525;
      }
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    body {
      font-family: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;
      font-size: 15px;
      line-height: 1.6;
      background: var(--bg);
      color: var(--fg);
      padding: 3rem 1.5rem;
      max-width: 680px;
      margin: 0 auto;
    }

    h1 {
      font-size: 1.5rem;
      font-weight: 600;
      margin-bottom: 0.5rem;
    }

    .tagline {
      color: var(--muted);
      margin-bottom: 2rem;
    }

    .install {
      background: var(--code-bg);
      padding: 0.75rem 1rem;
      border: 1px solid var(--border);
      margin-bottom: 2.5rem;
      font-size: 14px;
    }

    h2 {
      font-size: 1rem;
      font-weight: 600;
      margin-top: 2rem;
      margin-bottom: 0.75rem;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    p {
      margin-bottom: 1rem;
    }

    ul {
      list-style: none;
      margin-bottom: 1.5rem;
    }

    li {
      padding-left: 1rem;
      position: relative;
      margin-bottom: 0.25rem;
    }

    li::before {
      content: "—";
      position: absolute;
      left: 0;
      color: var(--muted);
    }

    pre {
      background: var(--code-bg);
      padding: 1rem;
      border: 1px solid var(--border);
      overflow-x: auto;
      font-size: 13px;
      margin-bottom: 1.5rem;
    }

    code {
      font-family: inherit;
    }

    a {
      color: var(--fg);
      text-decoration: underline;
      text-underline-offset: 2px;
    }

    a:hover {
      color: var(--muted);
    }

    .dep {
      background: var(--code-bg);
      padding: 0.5rem 0.75rem;
      border: 1px solid var(--border);
      display: inline-block;
      font-size: 13px;
      margin-bottom: 1.5rem;
    }

    footer {
      margin-top: 3rem;
      padding-top: 1.5rem;
      border-top: 1px solid var(--border);
      color: var(--muted);
      font-size: 13px;
    }

    footer a {
      color: var(--muted);
    }
  </style>
</head>
<body>
  <h1>nostr</h1>
  <p class="tagline">A minimal Go library for the Nostr protocol.</p>

  <div class="install">go get code.northwest.io/nostr</div>

  <h2>Why</h2>
  <p><strong>1 dependency.</strong> Other Nostr libraries pull in 30+. This one has exactly one:</p>
  <div class="dep">btcec/v2 — Schnorr signatures (required by protocol)</div>
  <p>No WebSocket libraries, no logging frameworks, no kitchen sink. Just the core protocol, stdlib only.</p>

  <h2>What's Included</h2>
  <ul>
    <li><strong>Keys</strong> — generate, parse, sign, verify (hex + bech32)</li>
    <li><strong>Events</strong> — create, serialize, sign NIP-01 events</li>
    <li><strong>Filters</strong> — build and match subscription filters</li>
    <li><strong>Relay</strong> — WebSocket pub/sub (stdlib net/http)</li>
    <li><strong>Tags</strong> — parse and build event tags</li>
    <li><strong>Envelopes</strong> — protocol message parsing</li>
  </ul>

  <h2>Example</h2>
  <pre><code>key, _ := nostr.GenerateKey()
fmt.Println("npub:", key.Npub())

event := &nostr.Event{
    Kind:    nostr.KindTextNote,
    Content: "Hello Nostr!",
}
key.Sign(event)

relay, _ := nostr.Connect(ctx, "wss://relay.damus.io")
relay.Publish(ctx, event)</code></pre>

  <h2>What's Not Included</h2>
  <p>This is a minimal core library. It implements NIP-01 and the basics. It doesn't implement every NIP, handle connection pooling, or manage relay discovery. Build that yourself, or don't.</p>

  <footer>
    <a href="https://code.northwest.io/nostr.git/">source</a> · MIT
  </footer>
</body>
</html>