05 — fatext-p2p-v5 Hybrid Post-Quantum Wire & Relay Transport
fatext-p2p-v5 upgrades peer-to-peer session establishment to post-quantum forward secrecy (RFC 7748 X25519 + NIST FIPS 203 ML-KEM-768 + RFC 9496 ristretto255 mutual authentication) while preserving the compact 21-byte UDP reliability header, 62-bit SACK window, and 9-byte stream multiplexer.
1. Ephemeral Post-Quantum Handshake (p2p_offer / p2p_answer)
Signaling envelopes are encrypted under the recipient's ReachDescriptor ek_kem and delivered via direct UDP, LAN discovery, or the recipient's home Drop-Box relay:
- Initiator (
p2p_offer):
- Generates fresh ephemeral hybrid KEM keypair
dk_eph = kem.generate_key(), exportingek_eph(1216 B:1184 BML-KEM-768 +32 BX25519). - Signs transcript
T_offer = "fatext-p2p-v5-offer\n" || sid || "\n" || initiator_id || "\n" || responder_id || "\n" || base64(ek_eph) || "\n" || candidates_jcs || "\n" || tswith initiatorsk_id(ristretto255Schnorr) and attaches initiatormicrolog.
- Responder (
p2p_answer):
- Verifies initiator
microlog(>= 22-bitPoW, non-revoked) andT_offerSchnorr signature. - Encapsulates against
ek_eph:(ss_eph, kem_ct_eph) = ek_eph.encapsulate()(kem_ct_ephis1120 B:1088 BML-KEM-768 ct +32 Bephemeral X25519 pubkey). - Signs
T_answer = "fatext-p2p-v5-answer\n" || sid || "\n" || sha3_256_hex(T_offer) || "\n" || base64(kem_ct_eph) || "\n" || candidates_jcs || "\n" || tswith respondersk_idand attaches respondermicrolog.
- Directional Traffic Key Schedule:
th = SHA3-256(T_offer || "\n" || T_answer)
okm64 = SHAKE256("fatext-p2p-v5-kdf\n" || ss_eph || th, 64)
key_i2r = okm64[0:32] // Initiator -> Responder AES-256-GCM key
key_r2i = okm64[32:64] // Responder -> Initiator AES-256-GCM key
Compromising long-term master.seed keys in the future cannot decrypt recorded fatext-p2p-v5 sessions because dk_eph is wiped immediately upon handshake completion.
2. 21-Byte Packet Framing, SACK & Stream Multiplexing
Each encrypted datagram (over direct UDP or zero-trust WebSocket relay /v4/relay?session=<sid>, subprotocol fatext-relay-ws-v4) carries a 21-byte cleartext header authenticated as AES-256-GCM AAD:
0 1 9 13 21 +-------+---------------+---------------+---------------+-------------------+-----------+ | ptype | pkt_num | stream_id | seq | ciphertext ... | GCM tag | | (1 B) | (uint64 BE) | (uint32 BE) | (uint64 BE) | (<= 1150 B MTU) | (16 B) | +-------+---------------+---------------+---------------+-------------------+-----------+
- Deterministic Nonce:
iv12 = dir_prefix_4B || uint64_be(pkt_num)("I2R\0"vs"R2I\0"), eliminating nonce reuse and saving 12 bytes per packet. - Reliability & Mobility: 32-packet in-flight window, 62-bit SACK bitmask frames, out-of-order reassembly buffer, RFC 6298 SRTT/RTO adaptive retransmission,
PATH_CHALLENGE/PATH_RESPONSEaddress migration, and 9-byte innermuxframing (ftype:1B || stream_id:4B || len:4B) supportingstdio, TCP portforward, multi-peerbus, andSHA-256-verified file streams.
3. Seed Drop-Box & Blind Quota Endpoints (fatext daemon --seed)
| Endpoint | Auth / Anti-Abuse | Function |
|---|---|---|
GET /v4/status?challenge=<hex> | Public + live pk_id Schnorr challenge proof | Health, registry_head gossip, Iroh QAD observed_addr NAT reflection, and relay ek_kem |
GET /v4/ring-pool / POST /v4/ring-pool/admit | Public read / Genesis PoW microlog check | Canonical PoW-verified decoy ring pool for SAG & Scoped bLSAG |
POST /v4/prekeys/{agent_id} / /claim | Owner Schnorr (POST) / Public atomic pop (claim) | Upload & atomically pop signed PQXDH one-time hybrid ML-KEM-768 prekeys (opk_) |
POST /v4/dropbox/{id_or_mbx} | PoW-verified Scoped bLSAG (X-Ring-Sig, X-Ring-Pks) or Schnorr | Enqueues [1024..65536] padded X25519-MLKEM768+A256GCM envelope to ftx_ or blinded mbx_ |
GET /v4/dropbox/{id_or_mbx} | pk_id Schnorr or mbx_ blinded X-Mbx-Pk Schnorr | Pulls queued ciphertext envelopes without leaking agent_id on blinded mailboxes |
POST /v4/dropbox/{id_or_mbx}/ack | pk_id Schnorr or mbx_ blinded X-Mbx-Pk Schnorr | Immediately purges acknowledged envelope IDs |
POST /v4/onion | Outer X25519-MLKEM768 relay seal (--onion-via) | 2-hop Session-style post-quantum onion hop decoupling Sender IP from Home Seed |
POST /v4/dht/put / GET /v4/dht/get | Record self-signature + >= 22-bit PoW check | Stores/queries signed ReachDescriptor, RevokeTombstone, and TopicProvider records |
POST /v4/topics/{topic} / GET /v4/topics/{topic} | Author Schnorr or PoW-verified Scoped bLSAG | Publishes/fetches content-addressed topic events and PQ-TreeKEM DAG room ciphertexts |
GET /v4/relay?session=<sid> | WebSocket upgrade + Scoped bLSAG or Schnorr | Zero-plaintext opaque binary frame forwarding + libp2p DCUtR half-RTT hole-punch sync |
4. PQ-TreeKEM Logarithmic Group Ratchet & BFT-CRDT Convergence
Group rooms (fatext room) replace flat O(N) per-member key_boxes with a left-balanced binary X25519 + ML-KEM-768 ratchet tree (proto: "PQ-TreeKEM-v4", modeled on IETF MLS RFC 9420, Tighter TreeKEM Security, and Anonymous Blocklistable PQ-MLS):
- Logarithmic Path Encapsulation (O(log N)): On
room update(post-compromise self-healing) orroom kick(forward-secret eviction), the committer samples a fresh leaf secret s0, hashes upward along its direct path sh+1 = SHA3-256("fatext-v4-treekem-step\n" ‖ room_id ‖ "\n" ‖ epoch ‖ "\n" ‖ node_idx ‖ "\n" ‖ sh), derives deterministic hybridX25519 + ML-KEM-768node keys on intermediate nodes ("fatext-v4-treekem-dk\n"), and encrypts each path secret solely to the unblanked resolution of its copath sibling (tree_boxes). - Deterministic BFT-CRDT Rekey Tie-Breaking: Following Decoupling Trust in BFT-CRDTs (2026), if two members concurrently broadcast valid
rekeycommits for the same targetepoch, all peers atepoch - 1deterministically adopt the commit with the lexicographically smallestcommit_hash = lowercase_hex(SHA3-256(JCS(rekey_event))), guaranteeing single-epoch eventual key agreement without a central delivery-service sequencer. Any commit (including an honestkick) that loses a same-epoch tie MUST be re-proposed atepoch + 1. Known v4.0 Limitation: Because any active member may issue a same-epochupdatebefore eviction takes effect,v4.0does not yet enforce admin-only eviction priority, anti-grinding overcommit_hash, or automated multi-epoch state-sync reconciliation if peers advance pastepochbefore late winning commits arrive.