A Zig library for the Nostr protocol.
| NIP | Description | Implementation |
|---|---|---|
| 01 | Basic Protocol | Events, filters, client/relay messages |
| 04 | Encrypted Direct Messages | nip04 module (deprecated, use NIP-17) |
| 05 | DNS Identifiers | nip05 module |
| 06 | Basic Key Derivation | nip06.keypairFromMnemonic |
| 09 | Event Deletion | isDeletion, getDeletionIds |
| 10 | Text Notes and Threads | nip10 module |
| 11 | Relay Information Document | nip11 module |
| 13 | Proof of Work | pow module |
| 16 | Replaceable Events | Replaceable, kindType (includes addressable) |
| 17 | Private Direct Messages | nip17 module |
| 18 | Reposts | nip18 module |
| 19 | bech32 Entities | npub, nsec, nprofile, nevent, naddr |
| 21 | nostr: URI Scheme | nip21 module |
| 25 | Reactions | nip25 module |
| 27 | Text Note References | nip27 module |
| 28 | Public Chat | nip28 module |
| 29 | Relay-based Groups | relay_groups module |
| 30 | Custom Emoji | custom_emoji module |
| 39 | External Identities | external_identities module |
| 40 | Expiration Timestamp | isExpired |
| 42 | Authentication | Auth utilities, AUTH message |
| 43 | Relay Access Metadata | nip43 module |
| 44 | Encrypted Payloads | crypto.nip44Encrypt, crypto.nip44Decrypt |
| 45 | Event Counts | COUNT message |
| 46 | Remote Signing | nip46 module |
| 47 | Wallet Connect | nwc module |
| 49 | Private Key Encryption | nip49 module |
| 50 | Search | Filter search field |
| 57 | Lightning Zaps | nip57 module |
| 58 | Badges | badges module |
| 59 | Gift Wrap | nip59 module |
| 63 | Index Keys | IndexKeys utilities |
| 65 | Relay List Metadata | relay_metadata module |
| 70 | Protected Events | isProtected |
| 75 | Zap Goals | zap_goal module |
| 77 | Negentropy | Full protocol support |
| 86 | Relay Management API | nip86 module |
| 94 | File Metadata | file_metadata module |
| 98 | HTTP Auth | http_auth module |
| 99 | Classified Listings | classified_listing module |
| 2022 | Joinstr Coinjoin Pools | joinstr module |
| CLINK | Common Lightning Interface for Nostr Keys | clink module |
| DLC | Discreet Log Contract Oracles | dlc_oracle module |
zig buildzig build testconst nostr = @import("nostr");
// Initialize crypto
try nostr.init();
defer nostr.cleanup();
// Generate keypair
const keypair = nostr.Keypair.generate();
// Or derive from mnemonic (NIP-06)
const mnemonic = "leader monkey parrot ring guide accident before fence cannon height naive bean";
const derived = try nostr.nip06.keypairFromMnemonic(mnemonic, "", 0);
// Build and sign an event
var builder = nostr.EventBuilder{};
_ = builder.setKind(1).setContent("Hello Nostr!");
try builder.sign(&keypair);
var buf: [4096]u8 = undefined;
const json = try builder.serialize(&buf);
// Parse an event
var event = try nostr.Event.parse(json);
defer event.deinit();
try event.validate();
// Parse client messages
var msg = try nostr.ClientMsg.parse(raw_json);
defer msg.deinit();
// Create relay responses
const response = try nostr.RelayMsg.ok(event.id(), true, "", &buf);
// Connect to a single relay
var relay = try nostr.Relay.init(allocator, "wss://relay.example.com", .{});
defer relay.deinit();
try relay.connect();
// Or use a pool for multiple relays
var pool = nostr.Pool.init(allocator);
defer pool.deinit();
try pool.addRelay("wss://relay1.example.com");
try pool.addRelay("wss://relay2.example.com");
_ = try pool.connectAll();- wisp - Fast, lightweight nostr relay
- nostr-bench - Nostr relay benchmark tool
- puck - NIP-47 Wallet Connect server with LNbits backend
MIT - See LICENSE
Powered by noscrypt for cryptographic operations.