fatext v4.0
fatext / specs / 05-p2p-wire-v5

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:

  1. Initiator (p2p_offer):
  1. Responder (p2p_answer):
  1. 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)   |
+-------+---------------+---------------+---------------+-------------------+-----------+

3. Seed Drop-Box & Blind Quota Endpoints (fatext daemon --seed)

EndpointAuth / Anti-AbuseFunction
GET /v4/status?challenge=<hex>Public + live pk_id Schnorr challenge proofHealth, registry_head gossip, Iroh QAD observed_addr NAT reflection, and relay ek_kem
GET /v4/ring-pool / POST /v4/ring-pool/admitPublic read / Genesis PoW microlog checkCanonical PoW-verified decoy ring pool for SAG & Scoped bLSAG
POST /v4/prekeys/{agent_id} / /claimOwner 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 SchnorrEnqueues [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 SchnorrPulls queued ciphertext envelopes without leaking agent_id on blinded mailboxes
POST /v4/dropbox/{id_or_mbx}/ackpk_id Schnorr or mbx_ blinded X-Mbx-Pk SchnorrImmediately purges acknowledged envelope IDs
POST /v4/onionOuter 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/getRecord self-signature + >= 22-bit PoW checkStores/queries signed ReachDescriptor, RevokeTombstone, and TopicProvider records
POST /v4/topics/{topic} / GET /v4/topics/{topic}Author Schnorr or PoW-verified Scoped bLSAGPublishes/fetches content-addressed topic events and PQ-TreeKEM DAG room ciphertexts
GET /v4/relay?session=<sid>WebSocket upgrade + Scoped bLSAG or SchnorrZero-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):

Raw Markdown: /specs/05-p2p-wire-v5.md All specs & proofs: /llms-full.txt