aboutsummaryrefslogtreecommitdiffstats
path: root/website/index.html
blob: be6609510aebce6bcd3b06057368a622191699fd (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
<!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 zero-dependency Go library for Nostr. Rolls its own crypto.">
  <meta name="go-import" content="code.northwest.io/nostr git https://code.northwest.io/nostr.git">
  <title>nostr — zero-dependency 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);
    }

    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 zero-dependency Go library for Nostr.</p>

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

  <h2>Why</h2>
  <p>You probably shouldn't use this.</p>
  <p>This library rolls its own secp256k1 crypto in pure Go. No CGO, no external dependencies, no nothing. I built it to see if it was possible to implement Nostr with truly zero dependencies. It is. But that doesn't mean it's a good idea.</p>
  
  <p><strong>What you get:</strong> zero deps, auditable code, passes all BIP-340 test vectors, works fine for normal usage.</p>
  <p><strong>What you give up:</strong> constant-time operations, performance (~10x slower than btcec), battle-tested code.</p>
  <p>If you're building something serious, use a library backed by btcec. If you're hacking on a side project or just want to read the code, welcome.</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 only)</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>

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