Expand description
CORD-01 Private Streams — the Concord v2 envelope.
Every durable plane event is the same three-layer shape: a kind-1059 wrap
signed by the plane’s derived group key (fixed author, random ephemeral p
tag — NIP-59 reversed), containing a seal signed by the author’s real
key, containing the unsigned rumor that carries the functional kind.
Two seal forms, fixed per plane (CORD-02 §5), declared by the seal’s kind:
- 20013 encrypted (Chat, Guestbook, rekey planes): the rumor is NIP-44-encrypted again inside the already-encrypted wrap, so no layer can ever be lifted out as a standalone public event.
- 20014 plaintext (Control Plane ONLY): the seal’s content is the rumor’s serialized JSON string byte-verbatim, which is what lets a compaction re-wrap a signed edition into a new epoch with the signature intact. A re-wrap MUST carry those exact bytes forward, never re-serialize.
Ephemeral actions (typing, voice presence) ride the identical structure at kind 21059 — relays MUST NOT store it.
NIP-44 hard-caps plaintext at 65,535 bytes and libraries are lenient, so the cap is enforced HERE at every nesting layer — a lenient publisher mints events a strict reader cannot decrypt.
Structs§
- Batch
Checked - A page’s batch-opened seals, held for
open_wrap_aton this thread until it drops. Hold it only across the page’s synchronous opens. - Opened
Stream - A fully verified, opened stream event.
Enums§
- Seal
Form - Which seal form a plane uses (CORD-02 §5) — a fixed property of the plane, never a per-message choice.
- Stream
Error - Errors from building or opening a v2 stream event.
Constants§
- KIND_
SEAL_ ENCRYPTED - Encrypted seal (Chat / Guestbook / rekey planes).
- KIND_
SEAL_ PLAINTEXT - Plaintext seal (Control Plane only).
- KIND_
WRAP - Durable stream wrap.
- KIND_
WRAP_ EPHEMERAL - Ephemeral stream wrap — identical structure, relays MUST NOT store it.
- NIP44_
MAX_ PLAINTEXT - NIP-44 v2 plaintext hard cap, enforced at every nesting layer.
Functions§
- build_
rumor_ ms - Build an unsigned rumor carrying a full epoch-ms timestamp:
created_attakes the seconds, an["ms", <0..999>]tag the remainder. - build_
rumor_ secs - Build an unsigned rumor with a plain seconds timestamp and NO
mstag — the Control Plane shape (editions fold by version, not time). - build_
seal - Local-keys convenience: build + sign the seal in one step. Wire-identical to
the split path (
seal_content+ caller-side signing), which bunker accounts use instead. - channel_
binding_ tags - The standard chat binding tags for a rumor:
["channel", id]+["epoch", n]. - check_
channel_ binding - Enforce the Chat-plane binding (CORD-03 §3): the rumor MUST commit
["channel", id]+["epoch", n], strict-equal to the coordinate whose key decrypted the wrap; a mismatch (or duplicate/absent tag) is a splice — drop. - check_
page check_signatures_togetherfor a page whose wraps all open undergroup.- check_
signatures_ together - Checks a page of wraps’ signatures in one BIP-340 batch (nostr-verify) before they are
opened one by one: every seal’s, found by opening the wrap under the first of its
conversation keys that fits, and with
truethe wrap’s own (a Write-Restricted Stream). What verifies joins the session’s checked signatures, so the opens confirm only ids, and while the guard lives they take each seal from here rather than decrypting it again. Anything the batch rejected or never saw is verified in full as before. - open_
wrap - Open and fully verify a stream wrap against the plane’s group key.
- open_
wrap_ at open_wrapagainst a stream READ VIEW: the address to verify by and the conversation key that opens the wraps — no signing secret needed. Withverify_wrap_sig(a Write-Restricted Stream, CORD-01), the wrap’s own signature is additionally checked: there the signer set is narrower than the readership, so unlike an ordinary stream wrap (signed with a key every reader holds — proves nothing) it proves a write-keyholder published this, and a reader MUST check it rather than lean on the relays having done so.- resolve_
ms_ strict - Resolve a rumor’s true millisecond time — STRICT per CORD-02 §5: an absent
mstag is offset 0; ANY presentmstag that isn’t a lone integer in 0..=999 makes the event malformed (BadMs— drop it, never clamp), or the excess would smuggle arbitrary “future” past the coalesce clock checks. - rewrap_
seal - Re-wrap an already-verified PLAINTEXT seal into another stream (a compaction carrying a signed edition into a new epoch). The seal event is carried whole — its content string holds the rumor bytes verbatim, so the rumor id and the author’s signature survive.
- seal_
and_ wrap_ signed - Signer-driven twin of
build_seal+wrap_seal_with_tags: seal a rumor into its wrap using aVectorSignerfor the author signature, so a NIP-46 bunker (or NIP-55) account yields wire-identical output to the local-keys path. Only the seal signature needs the identity key; the seal content (symmetric group-key encrypt, or plaintext) and the group-key wrap do not. - seal_
and_ wrap_ signed_ for seal_and_wrap_signedp-tagged toowner(seewrap_seal_for).- seal_
content - The seal’s
contentfor a rumor: NIP-44 ciphertext under the stream’s conversation key (encrypted form) or the rumor’s serialized JSON string verbatim (plaintext form). Split from signing so the caller can sign with local keys OR a NIP-46 bunker — the seal is(seal_form.kind(), content, created_at = rumor.created_at)signed by the author’s real key. - split_
ms - Split a full epoch-ms send time into (
created_atseconds,msremainder). - wrap_
owner - The
pkey a wrap names: whoever holds its secret may delete the wrap. - wrap_
seal - Wrap a signed seal into the outer stream event: content = NIP-44 under the
stream conversation key, signed by the group key, one random ephemeral
ptag (NIP-59 reversed). Returns the wrap and the ephemeralpkeypair — a client MAY retain the latter to best-effort NIP-09-scrub the wrap later. - wrap_
seal_ for wrap_seal_with_tagsp-tagged toowner, the key that may later delete the wrap (CORD-01 §Deletions).- wrap_
seal_ with_ tags wrap_sealplus caller-suppliedextra_tagson the outer wrap. The chat plane uses this to mirror a message’s NIP-40expiration(Self-Destruct Timer) onto the wrap so relays drop the stored event on schedule; every other plane wraps with none.