code wiki / (root) / nx_connect_seal.nx

nx_connect_seal.nx

buildroot/runtime/nx_connect_seal.nx

3294 B62 linesdepth 6pulls 8 transitivereach 1 importersview sourcekind librarytopic connect
docsdependenciesstructsconstsfunctions

about

nx_connect_seal.nx -- CONNECT message sealing on the REAL, RFC-8439-verified ChaCha20-Poly1305 AEAD, built 2026-07-24 to retire the 78-line additive-cipher stand-in (nx_connect_e2ee_min) that the maturity gauge honestly graded STUB. "State of the art from the first byte up": this composes the sovereign AEAD whose KAT (nx_chacha20_poly1305_test) matches RFC 8439 2.8.2 byte-exact AND rejects a single-bit tamper. SECURITY DISCIPLINE (the parts a real messenger needs, that the stand-in never had): * AUTHENTICATED: every message carries a Poly1305 tag; open() REJECTS any tampered ciphertext/tag. * NONCE = per-message counter (4 zero bytes + 8-byte LE seq). Never reused for a key -> no keystream reuse. Nonce reuse is the cardinal AEAD failure; the counter makes it structural. * SEQUENCE-BOUND: the message counter is the AAD, so a replayed/reordered message fails to open under a different expected seq -> reorder/replay is detected, not just tampering. * CONTENT-BLIND BY CONSTRUCTION: the server stores only {seq, ciphertext, tag} and holds NO key, so it cannot read (no key) and cannot forge (AEAD auth). Key EXCHANGE (getting the conv key to both peers without the server) is a SEPARATE rung (X25519/MLS) -- not claimed here. PURE CORE (no main): key/nonce/buffers are caller-supplied. Consumers: nx_connect_seal_gate, and (once the AEAD chain is reachable from _hdl_build) the live serve. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_chacha20_poly1305.nx nx_connect_seal.nx nx_connect_seal_gate.nx

imports: nx_chacha20_poly1305.nx

imported by: nx_connect_seal_gate.nx

structs

none

consts

19const CSEAL_KEY: i64 = 32
20const CSEAL_NONCE: i64 = 12
21const CSEAL_TAG: i64 = 16
22const CSEAL_OK: i64 = 1 // == NX_AEAD_VERDICT_OK
23const CSEAL_REJECT: i64 = 0

functions

26func cseal_nonce(seq: i64, out: *u8) -> i64
34func cseal_aad(seq: i64, out: *u8) -> i64
42func cseal_seal(key: *u8, seq: i64, pt: *u8, plen: i64, ct: *u8, tag: *u8) -> i64
54func cseal_open(key: *u8, seq: i64, ct: *u8, clen: i64, tag: *u8, pt: *u8) -> i64