# Nostr From Scratch

Building Nostr in [Coax](../../coax/book/README.md).

This book builds Nostr in Coax, from protocol primitives to client and relay
programs. Nostr's cryptography is Bitcoin's: SHA-256, HMAC, HKDF, ChaCha20,
secp256k1, BIP-340 Schnorr signatures and Bech32 are built in its companion,
[Bitcoin From Scratch](../../bitcoin/book/README.md). This book starts from
there with x-only ECDH, NIP-19, the JSON that an event ID hashes and NIP-44,
and then builds the event model, a WebSocket transport, a client and a relay
on them. Part VI examines the NIP families in
[`nostr/nips/`](../nips/README.md): the official set, the OpenAgents set and
Block's Buzz set. Chapter 104 adds NIP-KEYS; its source-pin review remains
pending. Part VII checks the stack against published vectors and
other implementations, and Part VIII separates OpenAgents' current consumers
from offline integration examples and future deployments. Completing the full
protocol and production scope is the destination; the chapter labels below
describe the teaching profiles that exist today.

The C host may link one TLS library so native clients reach `wss://` relays.
Every protocol decision above the socket, including WebSocket framing, Nostr
messages, NIP-42 and NIP-44, is Coax code ([AGENTS.md](../../AGENTS.md)).
Money follows the repository's Bitcoin-only rule: Lightning and on-chain
Bitcoin are built; Cashu and Fedimint are recognized and never built
([chapter 74](ch074-cashu-and-fedimint-are-excluded.md)).

You need the Coax language (its book's Parts I–III) and Parts I–V of
[Bitcoin From Scratch](../../bitcoin/book/README.md). Chapters 1–13, 15 and
18 moved there; they keep their numbers here, marked moved. The
[plan](PLAN.md) gives the order and each chapter's dependencies, done
criteria and spec files. The [contents](SUMMARY.md) list every chapter.
The work to implement every chapter is tracked in [issue #12612](https://github.com/OpenAgentsInc/openagents/issues/12612).

## Start here

- **What you build.** A Nostr client and a relay, and readers for the NIPs
  that OpenAgents uses.
- **Why Nostr.** On Nostr a key is the identity. A person or an agent can
  sign work, publish it to any relay and be found by anyone, with no
  account that a platform can close. The same seed gives a Bitcoin wallet
  ([Bitcoin chapter 121](../../bitcoin/book/ch121-one-seed-for-nostr-and-bitcoin.md)).
- **What you need.** The Coax book's Parts I–III and Bitcoin From
  Scratch's Parts I–V.
- **The core path.** Parts I–V, chapters 14–44: shared secrets, the event
  model, transport, a client and a relay. Part VI is a reference: read the
  NIP you need.
- **The OpenAgents NIPs.** Chapters 76–92 are OpenAgents' own NIPs. Read
  together, they describe how an agent finds work, does it, proves it and
  is paid: [80](ch080-jobs-labor-and-markets.md) (jobs and markets),
  [82](ch082-pylons-environments-and-deploys.md) (Pylons),
  [83](ch083-attested-work-and-sealed-data.md) (attested work) and
  [86](ch086-lightning-payments-for-requests.md) (payments for requests).
  [Chapter 102](ch102-agents-on-nostr.md) runs one agent through all of it,
  offline.
- **Two protocols.** The OpenAgents Protocol is a set of protobuf schemas
  ([`proto/`](../../proto/README.md)) for messages between OpenAgents'
  own surfaces. The NIPs are the public form: signed events that anyone can
  read, verify and write without asking OpenAgents.
- **Where this book sits.** See [the OpenAgents books](../../docs/books/README.md) for the whole library.

## Status

Of the 89 chapters in this book, 88 are implemented and 1 is partly
implemented; 15 more numbers are marked moved. All 89 have runnable examples.
Chapter 103's production cutover to the Coax relay completed on 2026-11-12
(`#13361`) and the Rust fallback was retired on 2026-11-13 (`#13382`). Chapter
104 has teaching text, checked signing/recovery components in regtest and
private signet, and still requires a treasury spend broadcast on the public
signet.

An *implemented* chapter meets the promotion standard below for its stated
scope. It does not establish full support for every feature of a cited NIP.
For example, chapters 75–92 list protocol records and runtime paths they do
not build. Chapters 101 and 102 compose offline examples; their label does
not claim live Metaverse presence, wallet payment or a migrated hosted agent.
The [completion route](COMPLETION.md) keeps those exits separate.

The code is under `coax/lib/crypto/`, `coax/lib/nostr/` and `coax/lib/net/`,
with checks and dated evidence in `docs/verification/`. The registry claims
native CPU qualification for all 89 chapters and Wasm qualification for 8;
81 remain native-only. These are claims about each chapter's stated profile,
not about a complete client, relay or application running on both targets.

The [chapter registry](chapters.json) records each chapter's status (one of
*implemented*, *partly implemented*, *design draft* or *planned*), its
profile, its dependencies and three separate facts: its implemented source
(`source`), the targets with recorded evidence for its profile
(`qualified_targets`), and the code outside the book that uses it today
(`adopted_by`). The status table below, the contents and each chapter's
status marker must agree with it; `python3 psionic/tests/book.py --book nostr`
fails when they don't.

`adopted_by` lists reviewed direct consumers of a source component outside
the book. It is not an end-to-end qualification or approval to use production
keys. A client importing the shared event reader has not thereby adopted
every NIP-01 feature. An empty list means no direct consumer is recorded;
it does not rule out transitive use. The registry includes the API's Coax
NIP-98 bridge, public homepage reader, CLI and Pylon paths. The complete
agent exchange and Metaverse zaps remain offline examples. Chapter 97's runnable
report uses a pinned historical registry snapshot, rather than reading this
current registry.

| Direct consumer | Adopted component | Scope still outside that edge |
| --- | --- | --- |
| `coax/web/api/nostr.c` | Chapter 49's Coax NIP-98 verification through its generated C | Route-specific replay, sessions and account admission; other signers |
| `coax/web/project/landing-nostr.coax` | Public event verification, messages, filters, names and beacon checks | Complete relay history or trust in provider declarations |
| `apps/openagents-cli/main.coax`, `relay.coax`, `api.coax` | Identity derivation, event signing, relay and NIP-98 requests | The hosted runner's migration and rollback |
| `psionic/lib/pylon/run.coax` | NIP-42, signed events, NIP-44 and the Pylon queue | Production key custody and every deployment target |
| `apps/shared/host/apple/SparkWallet.swift`, `apps/openagents-desktop/Window+Wallet.swift` | Chapter 101's existing wallet rules and desktop Bitcoin Spark + NIP-06 wallet pane | NIP-MV presence, Metaverse zaps and Spark-backed Wallet Connect |

### What remains

Follow [Completion route](COMPLETION.md) in order: close recorded integration
and pin debt, qualify consumer profiles on their actual targets, finish relay
feature parity and production migration, connect the offline the OpenAgents Metaverse and agent
examples to applications, and finish treasury signing and independent recovery.
The route names each required result and the dependencies in the other books.

## Promoting a draft to a teaching chapter

A partly implemented or design draft chapter becomes a teaching chapter only
when it has all four of the following:

1. **A worked calculation or trace.** A small input whose result the chapter
   works out by hand, step by step, before the program runs.
2. **Runnable source.** The code and an example in `nostr/examples/`, listed
   in [examples.json](examples.json), with an exact transcript that the
   book's checks compare in debug and release.
3. **A deliberately broken case and its diagnostic.** An input or an edit
   that the code refuses, with the exact error or refusal shown and its exit
   status checked.
4. **An independent check.** A published test vector, a reference
   implementation or a hand-derived value that the checks compare with the
   code's result.

When all four exist, update the chapter's status in the same commit in four
places: the chapter's status marker, its entry in [chapters.json](chapters.json),
its label in the [contents](SUMMARY.md) and its row in the table below. The
registry check fails when they disagree.

To find a route through the books, see
[Paths through the books](../../docs/books/paths.md) and the shared
[completion milestones](../../docs/books/completion.md).

## Writing style

Write chapters to the
[Google developer documentation style guide](https://developers.google.com/style):

- Use short, plain sentences in active voice and present tense.
- Address the reader as "you".
- Say what the code does and what was measured. Don't use metaphors,
  personification, or literary phrasing.
- Use numbered lists for steps and bulleted lists for related items.
- Use code font for code, file names, and identifiers.

## Checking the book

Commands run from the repository root.

```shell
python3 psionic/tests/book.py --book nostr
python3 psionic/tests/book.py --book nostr --coax coax/bin/coax
```

The first checks structure: chapter files and headings, the contents, local
links, status markers, the chapter registry and the example inventory in
[examples.json](examples.json). The second also runs every example in
`nostr/examples/` in debug and release and compares its output and exit
status. It is the same checker as the Psionic and Metaverse Engine books'; build the
compiler once with `coax/build.sh`.

Coax listings, equations and short illustrative blocks use `jai` fences;
commands use `shell`.

## Chapters

### Moved to Bitcoin From Scratch (chapters 1–13, 15 and 18)

Bytes, big integers, constant time, SHA-256, HMAC, HKDF, ChaCha20, secp256k1,
BIP-340 and Bech32 are now chapters of
[Bitcoin From Scratch](../../bitcoin/book/README.md). The
[plan](PLAN.md#moved-to-bitcoin-from-scratch) maps each number here to its
Bitcoin chapter.

### Part I. Shared secrets, encodings and encryption (chapters 14, 16, 17, 19 and 20)

x-only ECDH for NIP-44 conversation keys, NIP-19 and `nostr:` URIs, the exact
JSON that a Nostr event ID hashes, the retired NIP-04 scheme and its
weaknesses, and NIP-44 v2 checked against its official vectors.

| Chapter | Status | Result |
| --- | --- | --- |
| [14. Shared secrets with ECDH](ch014-shared-secrets-with-ecdh.md) | Runnable: native C and wasm | x-only ECDH that validates the peer key and returns the raw shared x, checked against labelled Wycheproof secp256k1 inputs, for NIP-44 conversation keys. |
| [16. NIP-19 entities and nostr: URIs](ch016-nip-19-entities-and-nostr-uris.md) | Runnable: native C | `npub`, `nsec` and `note`, and the TLV forms `nprofile`, `nevent` and `naddr` with relay hints, plus the `nostr:` URI scheme of NIP-21. |
| [17. JSON you can sign](ch017-json-you-can-sign.md) | Runnable: native C | A bounded JSON reader and writer that keep original bytes, and the exact NIP-01 serialization `[0, pubkey, created_at, kind, tags, content]` with its escape rules, distinct from RFC 8785 JCS. |
| [19. NIP-04 and why it is retired](ch019-nip-04-and-why-it-is-retired.md) | Runnable: native C | NIP-04's AES-256-CBC with the shared x as key and its `?iv=` suffix, its weaknesses (no authentication, metadata in the clear, the key used as is), and a decrypt-only reader checked against FIPS-197, SP 800-38A and OpenSSL that refuses to encrypt. |
| [20. NIP-44 encrypted payloads](ch020-nip-44-encrypted-payloads.md) | Runnable: native C | NIP-44 version 2: conversation keys, padding, ChaCha20, HMAC over nonce‖ciphertext checked before decryption, and every valid and invalid vector in `nip44.vectors.json`. |

### Part II. The event model (chapters 21–25)

NIP-01 events, IDs and signatures, kinds and tags, filters, the relay messages
that carry them, and NIP-59 gift wrap built on all of them.

| Chapter | Status | Result |
| --- | --- | --- |
| [21. Events, IDs and signatures](ch021-events-ids-and-signatures.md) | Runnable: native C and wasm | The NIP-01 event: `id`, `pubkey`, `created_at`, `kind`, `tags`, `content`, `sig`; recomputing the ID, verifying the signature, and building signed events separately from reading them. |
| [22. Kinds and tags](ch022-kinds-and-tags.md) | Runnable: native C | Kind ranges (regular, replaceable 0, 3 and 10000–19999, ephemeral 20000–29999, addressable 30000–39999 by `d` tag) and the standard tags `e`, `p`, `a` and `d`. |
| [23. Filters](ch023-filters.md) | Runnable: native C and wasm | NIP-01 filters: `ids`, `authors`, `kinds`, `#<letter>` tags, `since`, `until` and `limit`; AND across fields, OR within a list, inclusive times, and absent lists distinct from empty ones. |
| [24. Relay messages](ch024-relay-messages.md) | Runnable: native C | Client frames `EVENT`, `REQ`, `CLOSE`, `AUTH` and `COUNT`, relay frames `EVENT`, `OK`, `EOSE`, `CLOSED`, `NOTICE` and `AUTH`, and the `OK`/`CLOSED` reason prefixes NIP-20 introduced. |
| [25. Gift wrap](ch025-gift-wrap.md) | Runnable: native C | NIP-59 rumors, kind-13 seals and kind-1059 gift wraps from one-time keys, with randomized timestamps, checked in both directions against an independent implementation. |

### Part III. Transport (chapters 26–28)

WebSocket framing as a client and a server in Coax, over the host's socket and
TLS.

| Chapter | Status | Result |
| --- | --- | --- |
| [26. WebSocket frames](ch026-websocket-frames.md) | Runnable: native C | RFC 6455 as a client: the opening handshake with `Sec-WebSocket-Accept` from SHA-1, masked client frames, fragmentation, ping, pong and close with status codes. |
| [27. A WebSocket server](ch027-a-websocket-server.md) | Runnable: native C | The server side of RFC 6455: accept the upgrade, refuse unmasked client frames, write unmasked frames, enforce frame and message limits and close cleanly. |
| [28. Sockets, TLS and relay URLs](ch028-sockets-tls-and-relay-urls.md) | Runnable: native C | The host boundary: the C host opens sockets and does TLS only; Coax parses `ws://` and `wss://` URLs, decides every frame and owns every protocol decision above the socket. |

### Part IV. A client (chapters 29–33)

A relay connection with generations and backoff, subscriptions and EOSE,
publishing with acknowledgements, the outbox model and a client that survives
restarts.

| Chapter | Status | Result |
| --- | --- | --- |
| [29. A relay connection](ch029-a-relay-connection.md) | Runnable: native C | The pure client state machine: OPEN, CONNECTING, CLOSED and BACKOFF, connection generations that make stale reports harmless, and capped jittered backoff. |
| [30. Subscriptions and EOSE](ch030-subscriptions-and-eose.md) | Runnable: native C | Subscription IDs that name a slot and its serial, EOSE as the end of stored events and never a completeness claim, NIP-67 completeness hints, and paginated catch-up. |
| [31. Publish and wait for OK](ch031-publish-and-wait-for-ok.md) | Runnable: native C | Publishing with acknowledgement deadlines, the distinction between published, acknowledged, refused and unknown, and requeue after AUTH. |
| [32. Many relays and the outbox model](ch032-many-relays-and-the-outbox-model.md) | Runnable: native C | NIP-65 relay lists (kind 10002 with `r` tags marked `read` or `write`), reading from an author's write relays, writing to your write relays and the tagged users' read relays. |
| [33. A client that survives restarts](ch033-a-client-that-survives-restarts.md) | Runnable: native C | A durable client journal that stores verified originals, an offline outbox that sends each event again after a restart without a second copy anywhere, subscriptions that resume with `since`, and deletions that are never resurrected on reconnect. |

### Part V. A relay (chapters 34–44)

Admission, durable storage, filter matching with indexes, NIP-11, NIP-42,
deletion and expiration, NIP-45 counts, NIP-50 search, NIP-70, NIP-77
negentropy, and limits.

| Chapter | Status | Result |
| --- | --- | --- |
| [34. Admit an event](ch034-admit-an-event.md) | Runnable: native C | The relay's EVENT admission: verify ID and signature, check size, tag and time limits, answer `OK` with the standard prefixes, and route each frame from one connection. |
| [35. Store events](ch035-store-events.md) | Runnable: native C | Verified originals with one copy per ID, replaceable and addressable replacement with the same-second lowest-ID rule, an fsync before `OK`, and crash recovery that cuts only a partial last write. |
| [36. Match filters with indexes](ch036-match-filters-with-indexes.md) | Runnable: native C | Answering REQ from the store newest first with query cost limits, then indexes by ID, author, kind and tag that never change which events match. |
| [37. NIP-11 relay information](ch037-nip-11-relay-information.md) | Runnable: native C | The relay information document served on `Accept: application/nostr+json`: name, pubkey, `supported_nips`, software, version and `limitation` fields that match what the relay enforces. |
| [38. NIP-42 authentication](ch038-nip-42-authentication.md) | Runnable: native C | Challenges bound to one connection and one relay URL, kind 22242 events with `relay` and `challenge` tags checked within a time window, and AUTH on both the client and the relay. |
| [39. Delete, expire and vanish](ch039-delete-expire-and-vanish.md) | Runnable: native C | NIP-40 `expiration` tags enforced at admission and query, NIP-09 kind-5 deletion requests from the same author with durable tombstones, and NIP-62 kind-62 requests to vanish. |
| [40. Count events](ch040-count-events.md) | Runnable: native C | NIP-45 `COUNT` requests and responses, `approximate` counts, and HyperLogLog with 256 registers whose offset comes from the filter. |
| [41. Search](ch041-search.md) | Runnable: native C | NIP-50's `search` filter field, a word index over the store, results ordered by a word-count score, `include:spam`, and every other `key:value` extension ignored. |
| [42. Protected events](ch042-protected-events.md) | Runnable: native C | Events tagged `["-"]` accepted only from their authenticated author, so a third party cannot republish them to this relay. |
| [43. Negentropy sync](ch043-negentropy-sync.md) | Runnable: native C | NIP-77's `NEG-OPEN`, `NEG-MSG`, `NEG-CLOSE` and `NEG-ERR`, and Negentropy protocol V1: range-based set reconciliation over `(created_at, id)` with fingerprints. |
| [44. Limits, policy and floods](ch044-limits-policy-and-floods.md) | Runnable: native C | Per-connection and global limits, rate limits with `rate-limited:` reasons, storage caps, slowloris timeouts and a write policy that is declared, not implicit. |

### Part VI. Every NIP (chapters 45–92)

Every other official NIP pinned in `nostr/nips/official/`, every OpenAgents
NIP and every Block (Buzz) NIP, grouped by subject and ordered by dependency.

| Chapter | Status | Result |
| --- | --- | --- |
| [45. Profiles, follows and names](ch045-profiles-follows-and-names.md) | Runnable: native C | Kind 0 profiles and their `nip05` value, kind 3 follow lists with relay hints and petnames, the newest list replacing older ones in the store, and NIP-05 identifiers checked offline against a `/.well-known/nostr.json` response, refusing redirects and other keys; and NIP-39 kind 10011 identity claims, with each proof's URL for six platforms and a check that a fetched proof holds the key's `npub`. NIP-24's extra fields are not read yet. |
| [46. Keys from a seed phrase](ch046-keys-from-a-seed-phrase.md) | Runnable: native C | BIP-39 words to seed with PBKDF2-HMAC-SHA512, BIP-32 derivation at m/44'/1237'/0'/0/0, and the NIP-06 key and its npub. |
| [47. Encrypted key backup](ch047-encrypted-key-backup.md) | Runnable: native C and wasm | NIP-49 `ncryptsec`: NFKC-normalized passwords, scrypt with `log_n` from the payload, XChaCha20-Poly1305 with the key-security byte as associated data, and bounded KDF memory. |
| [48. Signers outside the app](ch048-signers-outside-the-app.md) | Runnable: native C | NIP-07's `window.nostr` and NIP-55's Android signer intents described; NIP-46 remote signing built: `bunker://` and `nostrconnect://` URIs (secret kept, never printed), NIP-44-encrypted kind 24133 requests and responses, a client matching responses by id against a fixed deadline, a one-use connect secret, and an `#authority` permission check by method and kind. |
| [49. HTTP auth](ch049-http-auth.md) | Runnable: native C and wasm | NIP-98 kind 27235 events in `Authorization: Nostr <base64>`, binding the exact URL, method and payload hash within 60 seconds, with single-use event IDs. |
| [50. Notes, threads and subjects](ch050-notes-threads-and-subjects.md) | Runnable: native C | Kind 1 notes, NIP-10 marked `e` tags (`root`, `reply`, `mention`) with the deprecated positional form, `p` tags for participants, NIP-14 `subject` and NIP-36 `content-warning`. |
| [51. References inside content](ch051-references-inside-content.md) | Runnable: native C | NIP-27 `nostr:` references in content, the deprecated NIP-08 `#[index]` mentions, and NIP-30 `:shortcode:` custom emoji with `emoji` tags and kind 30030 sets. |
| [52. Reposts, reactions and comments](ch052-reposts-reactions-and-comments.md) | Runnable: native C | Kind 6 and 16 reposts, kind 7 reactions (`+`, `-`, emoji) and kind 17 website reactions, and NIP-22 kind 1111 comments with uppercase root and lowercase parent scope tags. |
| [53. Long-form, drafts and wiki](ch053-long-form-drafts-and-wiki.md) | Runnable: native C | Kind 30023 articles and 30024 drafts in Markdown, NIP-37 kind 31234 draft wraps encrypted with NIP-44, and NIP-54 kind 30818 wiki articles with `d`-tag normalization. |
| [54. Lists, sets and bookmarks](ch054-lists-sets-and-bookmarks.md) | Runnable: native C | NIP-51 standard lists (10000 mutes, 10001 pins, 10003 bookmarks and others) and sets (30000 follow sets and others) with public tags and private items encrypted to self, and NIP-B0 kind 39701 web bookmarks. |
| [55. Labels, reports and trusted assertions](ch055-labels-reports-and-trusted-assertions.md) | Runnable: native C | NIP-32 kind 1985 labels in `L` namespaces, NIP-56 kind 1984 reports with report types, and NIP-85 kinds 30382–30385 assertions from declared providers (kind 10040). |
| [56. Proof of work](ch056-proof-of-work.md) | Runnable: native C | NIP-13 difficulty as the number of leading zero bits of the event ID, the `nonce` tag with its target, and relay admission by `pow:` reason. |
| [57. Media and files](ch057-media-and-files.md) | Runnable: native C | `imeta` tags (NIP-92) and kind 1063 file metadata (NIP-94) read, written and checked against downloaded bytes' SHA-256; picture, video and voice `imeta` tags; Blossom blob addresses, kind 10063 server lists and kind 24242 upload authorizations; NIP-96 read only. |
| [58. Calendars, polls and highlights](ch058-calendars-polls-and-highlights.md) | Runnable: native C | NIP-52 date (31922) and time (31923) events, calendars (31924) and RSVPs (31925); NIP-88 polls (1068) and responses (1018); NIP-84 highlights (9802). |
| [59. Groups and communities](ch059-groups-and-communities.md) | Runnable: native C | The relay side of NIP-29 groups: `h` tags, moderation kinds 9000–9009 by role, join requests with invite codes, `previous` references and the relay-signed 39000–39003 state; NIP-72's moderator approval check; NIP-C7 chats (kind 9 with `q` replies); and NIP-7D threads (kind 11) whose replies are NIP-22 comments on the thread itself. |
| [60. Private messages](ch060-private-messages.md) | Runnable: native C | NIP-17 kind 14 chat and kind 15 file messages sent as gift wraps, kind 10050 DM relay lists; NIP-A4 kind 24 public messages, read with their receivers and expiration and refused when they carry an `e` tag; and the unrecommended NIP-EE MLS groups, which are not implemented. |
| [61. Live activities](ch061-live-activities.md) | Runnable: native C | NIP-53 kind 30311 live events with `streaming`, `status` and participant roles, kind 1311 live chat, and kind 30312/30313 meeting spaces and rooms with kind 10312 presence. |
| [62. Badges and statuses](ch062-badges-and-statuses.md) | Runnable: native C | NIP-58 badge definitions (30009), awards (8) and profile badges (10008, formerly 30008), and NIP-38 kind 30315 user statuses with `expiration`. |
| [63. Git on Nostr](ch063-git-on-nostr.md) | Runnable: native C | NIP-34 repository announcements (30617), issues (1621), patches (1617) and statuses (1630–1633), with the newest status by the author or a maintainer deciding the state; pull requests (1618) and updates (1619), with the tip taken from the author's newest update; and NIP-C0 snippets (1337). Repository state (30618) and a pull request's status are not built. |
| [64. App data and handlers](ch064-app-data-and-handlers.md) | Runnable: native C | NIP-78 kind 30078 application data, NIP-89 handler recommendations (31989) and announcements (31990) with follows-first resolution and safe URL templates, and NIP-5A static websites (35128 and 15128 manifests) with every served file checked against its hash. NIP-CD slash commands (31992, 10992) are not built. |
| [65. Data vending machines](ch065-data-vending-machines.md) | Runnable: native C | NIP-90 job requests (5000–5999), results (6000–6999) and feedback (7000), results matched to their request through the embedded event, a bid-capped payment check against the bolt11 amount, the customer's job state machine, and encrypted requests on NIP-44 only (NIP-04 refused). |
| [66. Markets and orders](ch066-markets-and-orders.md) | Runnable: native C | NIP-99 classified listings (30402 and 30403 drafts) with `price` in a currency and frequency, NIP-69 peer-to-peer order events (38383), and the unrecommended NIP-15 marketplace. |
| [67. Relay discovery, access and management](ch067-relay-discovery-access-and-management.md) | Runnable: native C | The NIP-86 management endpoint (Content-Type, NIP-98 with the payload tag, admin keys, single-use event IDs, ban and allow lists for keys, events and kinds) and the policy admission consults; NIP-66 discovery and monitor events and a median round-trip time over trusted monitors; NIP-43 member lists counted only from the relay's NIP-11 `self` key, and join and leave requests. |
| [68. Bridges, external IDs and timestamps](ch068-bridges-external-ids-and-timestamps.md) | Runnable: native C | NIP-48 `proxy` tags for bridged events, NIP-73 `i` and `k` tags for external content IDs (URLs, ISBNs, podcasts, geohashes), and NIP-03 kind 1040 OpenTimestamps attestations. |
| [69. Small content kinds](ch069-small-content-kinds.md) | Runnable: native C | NIP-35 torrents (2003), NIP-64 chess games in PGN (64), NIP-CC geocaches (37516) and logs (7516, 7517), and NIP-F4 podcasts. |
| [70. Retired and experimental NIPs](ch070-retired-and-experimental-nips.md) | Runnable: native C | NIP-26 delegation tokens, the NIP-31 `alt` tag and NIP-BE Bluetooth LE transport, each marked `unrecommended` in the pinned text, with what this stack reads and what it never builds. |
| [71. Lightning zaps and goals](ch071-lightning-zaps-and-goals.md) | Runnable: native C | NIP-57 zap requests (9734) sent to an LNURL server and zap receipts (9735) whose bolt11 description hash commits to the request, and NIP-75 zap goals (9041). |
| [72. Wallet Connect](ch072-wallet-connect.md) | Runnable: native C | NIP-47 Nostr Wallet Connect: `nostr+walletconnect://` URIs (secret kept, never printed), the info event (13194) with NIP-04-only wallets refused, every command's request (23194) and response (23195) JSON read and written, NIP-44 v2 under the connection secret, responses matched by author, `p`, `e` and `result_type`, and an `#authority` spending budget that refuses with `QUOTA_EXCEEDED`. |
| [73. Payment targets](ch073-payment-targets.md) | Runnable: native C | NIP-A3 kind 10133 `payto` tags, with only the Bitcoin and Lightning target types acted on under the repository rule. |
| [74. Cashu and Fedimint are excluded](ch074-cashu-and-fedimint-are-excluded.md) | Runnable: native C | NIP-60 Cashu wallets, NIP-61 nutzaps and NIP-87 mint discovery, recognized and never built: a classifier marks their nine kinds, references to them and ecash payment values as excluded, and the book check fails if another file names them. |
| [75. Hosts and reachability](ch075-hosts-and-reachability.md) | Runnable: native C | NIP-HOST grants bound to the original host-signed 3188 envelope and admitted against the host's record (request window, revocation, expiry, epochs, rights, retained replies), and NIP-REACH presence freshness and route generations. Invitations, enrollment, the directory, hint selection and direct channels are not built. |
| [76. Work, coordination and control](ch076-work-coordination-and-control.md) | Runnable: native C | NIP-COORD atomic claims with fencing tokens and leases (renew, release, cancel, the dispatcher fence) and NIP-CTRL pairing, revocation and command admission with the JCS command fingerprint. NIP-WORK items and NIP-CTX frames, COORD proposals, reservations and findings, and CTRL reads are not built. |
| [77. Capabilities, policy and extensions](ch077-capabilities-policy-and-extensions.md) | Runnable: native C | NIP-CAP dispatch (definition, exact binding, presence, grant, effects, ceilings, enforcement plan), NIP-POL single-use approvals, and NIP-EXT installation of signed releases (namespace, unknown features, equivocation, revocation, checkpoint freshness). Probes, preferences, instruction sets, listings, migration and NIP-REG are not built. |
| [78. Runs, sessions, terminals and trajectories](ch078-runs-sessions-terminals-and-trajectories.md) | Runnable: native C | NIP-RUN record digests and journal replay (gaps, forks, broken chains, controller handoff with fencing, the per-attempt state machine, head hints), NIP-ATIF chunk checks that report missing chunks, NIP-TERM client frame order with gaps. NIP-SESS, RUN retention and the 3187/30186, 3188 and 3198/3199 events are not built. |
| [79. Agents, skills and automation](ch079-agents-skills-and-automation.md) | Runnable: native C | NIP-AGENT saved agents (every definition field, private 3188 carriage sealed and opened, pinned selection by signer, id, revision and digest) and NIP-AUTO scheduling (once, interval and source triggers, missed and occupied slots recorded once, one occurrence per source revision, authority per occurrence, pause, resume and cancel). Public agents, NIP-SKILL listings, NIP-SOV and AUTO continuation, budgets and journals are not built. |
| [80. Jobs, labor and markets](ch080-jobs-labor-and-markets.md) | Runnable: native C | NIP-CJ response admission (only the worker the request named), NIP-MKT negotiation from RFQ to confirmed order and fixed-price Lightning settlement (one obligation, one attempt at a time, a preimage of the payment hash), and NIP-LAB submission, verification and acceptance at the exact price. CJ bodies, record encodings and chains, rework, disputes, cancellation, refunds and invoice decoding are not built. |
| [81. Decisions, evaluations, optimization and programs](ch081-decisions-evaluations-optimization-and-programs.md) | Runnable: native C | NIP-DEC body bounds and answer admission (an answer must match its request's question set exactly), NIP-EVAL reports shown as verified, unverifiable or untrusted and the admission that cites them, and NIP-OPT data-plan isolation. NIP-PRG, the DEC wire job, the 3189 publication and most OPT records are not built. |
| [82. Pylons, environments and deploys](ch082-pylons-environments-and-deploys.md) | Runnable: native C | NIP-PYLON beacons (30200) and service receipts (3201) verified and read: freshness by the reader's clock, no capacity from an expired beacon, receipts signed by their buyer and credited only to the beacon their p and a tags name. Model-group beacons, paid receipts, 30201 events, NIP-ENV and NIP-DEPLOY are not built. |
| [83. Attested work and sealed data](ch083-attested-work-and-sealed-data.md) | Runnable: native C | NIP-ATT releases (3202), release heads (30202) and attested endpoints (30203) checked by a client under a fixed clock: admission under the notice delay, rollback, the key-to-release binding and a Confidential Space token's claims; an endpoint that does not match its head is refused. NIP-VAULT tier user: an object opens only through a key slot (device or nostr method). Token signatures, raw TEE quotes, rebuilds, transparency, sealed jobs, tiers sealed and operator, and the key index are not built. |
| [84. Knowledge and workspaces](ch084-knowledge-and-workspaces.md) | Runnable: native C | NIP-KB entry versions (3190), heads (30190) and withdrawals (3191) read and checked, equivocation reported, the current version chosen without a withdrawn or conflicting version, and the reader's trust rule; NIP-WS conditional text replacements under the host's grants (stale, conflict, idempotency). Evidence, snapshots, private entries, ranges, worktrees, checkpoints and projections are not built. |
| [85. Live media, worlds and experience](ch085-live-media-worlds-and-experience.md) | Runnable: native C | NIP-MV world definitions (33300), pose frames (23300) admitted for their world (a pose outside its bounds refuses) and ordered by session and sequence under a fixed clock, entity states (33301) with object ids from SHA-256, and the NIP-XP quest, award and revocation readers and the derived ledger (a revoked award is removed). NIP-LIVE, the XP acceptance rules, shared bodies, gestures and zone commands are not built. |
| [86. Lightning payments for requests](ch086-lightning-payments-for-requests.md) | Runnable: native C | NIP-X402: x402 v2 over HTTP with the three base64 JSON headers, Bitcoin mainnet Lightning with a bolt11 invoice in millisats, and the `openagents:spark-receiver:1` settlement profile. |
| [87. Owner attestation and agent authentication](ch087-owner-attestation-and-agent-authentication.md) | Runnable: native C | Block's NIP-OA `auth` tag by which an owner key authorizes an agent key, and NIP-AA agent authentication to relays with virtual member privileges and revocation. |
| [88. Federated identity](ch088-federated-identity.md) | Runnable: native C and wasm | NIP-FI stateless assertions verified offline: bounded compact JWS, RS256 only, a closed JWKS, exact `kid`, and issuer, audience, community, token-class and clock binding. Fetching the JWKS, NIP-42 pairing, sessions and NIP-FA are not built. |
| [89. Channels](ch089-channels.md) | Runnable: native C | NIP-CL identity tags, labels, the oldest-channel rule and the legacy-type listing rule for system channels and 44100/44101 notices; NIP-CW channel and thread windows with composite cursors, exact `has_more` and the client rule that a response without its bounds is never an empty channel; NIP-DV snapshots readable only by their owner; NIP-WP icon commands. Summaries, 39007 binding and overlay signing are not built. |
| [90. Artifacts, archives and reminders](ch090-artifacts-archives-and-reminders.md) | Runnable: native C | NIP-AR channel artifacts (45010) with compare-and-swap revisions: a stale `prev` conflicts, an accepted event again succeeds unapplied, writes need the home channel and a move both; NIP-IA archive and unarchive requests with self, admin and owner-of-agent consent, checked against NIP-IA's published vectors; NIP-ER reminders (30300) with one head per address, author-only reads and a notification path that fires each reminder once at its `not_before`. Query limits, redaction and building reminders are not built. |
| [91. Git signing, projects, leases and read state](ch091-git-signing-projects-leases-and-read-state.md) | Runnable: native C | NIP-GS signing hashes, signatures and armor reproducing both published vectors; the NIP-MP ingest rules and fold over all 31 ingest and 12 fold fixtures; the NIP-PL expiration window and replacement order; the NIP-RS max-merge and ciphertext vector; and the four envelope projections. The signing program, lease plaintexts and the read-state override layer are not built. |
| [92. Private agent state](ch092-private-agent-state.md) | Runnable: native C | NIP-AE engrams (30174) sealed, opened by the agent or the owner only, chosen by head selection and protected from rollback; NIP-AO observer frames (24200) admitted only between an owned pair, fanned out in memory and never stored or logged, checked by a canary; the NIP-PMA reservation (30179) refused. NIP-AP personas and NIP-AM turn metrics are not built. |

### Part VII. Interop and verification (chapters 93–97)

Pinned vectors, differential tests against reference implementations, fuzzing,
formal properties and a conformance report.

| Chapter | Status | Result |
| --- | --- | --- |
| [93. Test vectors and their provenance](ch093-test-vectors-and-their-provenance.md) | Runnable: native C | Every vector file pinned by source URL, revision, license, retrieval date and SHA-256, with derived adapters labelled and their input hashes recorded. |
| [94. Differential tests](ch094-differential-tests.md) | Runnable: native C | Running the same inputs through Coax and a reference implementation: the Rust relay from history in a network-less sandbox, and independent libraries for signatures, NIP-44 and NIP-59. |
| [95. Fuzzing](ch095-fuzzing.md) | Runnable: native C | A seeded mutation fuzzer for every parser (JSON, events, filters, frames, NIP-19, NIP-44 payloads) under ASan and UBSan, with coverage guidance and shrinking shown on planted bugs, and minimized inputs kept as tests. |
| [96. Formal properties](ch096-formal-properties.md) | Runnable: native C | Five properties checked on every case of small domains, each with a planted bug its check finds: filter matching is AND across fields and OR within lists, a subscription is a union, replacement is order-independent, the index equals the scan, and verification refuses every one-bit change. |
| [97. A conformance report](ch097-a-conformance-report.md) | Runnable: native C | A machine-readable support matrix per profile (`core-read`, `core-write`, `phone-signer`, `openagents-host`, `block-identity`, `block-channel`, `agent-private`, `key-backup`) that refuses to advertise a NIP whose runtime gate is missing. |

### Part VIII. Nostr in OpenAgents (chapters 98–104)

Where projects, the website, Pylons, the Metaverse, the wallet and agents use the
stack, and the cutover of relay.openagents.com.

| Chapter | Status | Result |
| --- | --- | --- |
| [98. Projects on Nostr](ch098-projects-on-nostr.md) | Runnable: native C and wasm | OpenAgents' project pages fold NIP-34 repositories, issues and statuses and NIP-22 comments from the relay, verify each event in the browser, and replace a snapshot only with a complete bounded capture. |
| [99. The website and sign-in](ch099-the-website-and-sign-in.md) | Runnable: native C and wasm | Logging in to openagents.com with a Nostr key: a NIP-98 signed challenge from a browser signer (NIP-07) or any other signer becomes a session, a signed request is its key's account at L2, and `openagents login` joins a computer's key to an account. |
| [100. Pylons and the mesh](ch100-pylons-and-the-mesh.md) | Runnable: native C | Pylons authenticate to the relay with NIP-42, announce beacons, and answer sealed NIP-44 decision requests; the mesh opens encrypted channels with this book's primitives. |
| [101. The Metaverse and the wallet](ch101-the-verse-and-the-wallet.md) | Runnable: native C | Two players' NIP-MV presence through a Coax relay within the latency budget, and one in-world zap from request to counted receipt, paid only when the Spark wallet's rules in `pay/wallet.coax` pass, with Wallet Connect as a second path; what runs in production today and what is only in this book. |
| [102. Agents on Nostr](ch102-agents-on-nostr.md) | Runnable: native C | One attested agent end to end, offline: NIP-42 and NIP-AA login, a NIP-MKT order, a sealed NIP-CJ job claimed once and journaled with NIP-RUN, the answer, and payment against a Lightning preimage; what runs in production today and what is only in this book. |
| [103. Replace relay.openagents.com](ch103-replace-relay-openagents-com.md) | Runnable: native C | An export format, an import that verifies every id and signature again, event-set equality (a sorted-id digest, with Negentropy naming the difference), a shadow comparer, and the cutover and rollback runbook. The production cutover completed 2026-11-12 (`#13361`), and the follow-up hardening and Rust fallback retirement completed 2026-11-13 (`#13382`). |
| [104. Agent treasuries and a network of keys](ch104-agent-treasuries-and-a-network-of-keys.md) | Partly implemented: native C | NIP-KEYS wallets, enrollments, independence declarations and signing requests read under closed schemas; a wallet admitted by recomputing its BIP-380 descriptor, applying composition rules 1 to 4 and verifying each enrollment's BIP-322 possession proof; P2WSH scripts from BIP-32 public derivation; a signer that recomputes every output, the change and the fee from a PSBT v0 and refuses a PSBT whose outputs differ from its request; nonce idempotency, recovery timelocks, retired wallets, the co-signer's delay and the hot ceiling; RFC 6979 ECDSA partial signatures over BIP-143 digests, the PSBT with them and the coordinator's 2-of-3 transaction; BIP-341 Taproot key-path digests and signatures; requests and receipts as 3188 artifacts over a Coax relay, with Bitcoin Core confirming the spend and recovering the coins from the descriptor in regtest and on a private signet. Open: the spend has not been broadcast on the public signet. `tr` wallets, PSBT v2 and miniscript spends are not built. |
