Phantom Protocol is the post-quantum identity and anonymous routing layer I’m building for the TNHC platform. The design goal is technically-enforced privacy: no party — including the platform operator — can link a request to a user, even under full network observation. Today’s commits close every remaining placeholder in the protocol core.
What the protocol does
Phantom routes packets through a network of relays. The routing table inside each packet is fully homomorphically encrypted with TFHE-rs: each relay evaluates its own next hop without decrypting the table, so it cannot learn the full path. Route membership is proved with Plonky2 zkSNARKs — a relay can verify that a packet follows a valid path in the network without learning which path that is.
Post-quantum primitives:
- Signatures: Dilithium-5 (CRYSTALS-Dilithium, NIST PQC standard)
- Key encapsulation: ML-KEM-1024 (Kyber)
- Routing encryption: TFHE-rs (fully homomorphic)
- Routing proofs: Plonky2 zkSNARKs
- Payload encryption: ChaCha20-Poly1305 AEAD
- Hashing: Blake3
What landed today
FHE routing blob — real encryption, not plaintext
PhantomPath::construct_routing_blob(fhe) previously wrote a plaintext buffer of nullifiers and hop indices. Now it calls FheEngine::build_routing_table() and produces a bincode-serialised Vec<(EncryptedValue, EncryptedValue)> — one encrypted (node_id, next_hop) pair per hop. Encryption runs in parallel via Rayon, roughly 5× faster on a 5-hop path than the previous serial encrypt_u32() loop.
Content-based replay protection
The replay-protection nullifier used to be hash(packet_id) — meaning an attacker who re-sent the same message with a fresh random packet_id bypassed the check entirely. It now derives from hash(hops || hash(payload)). Identical message over identical path → identical nullifier, regardless of packet_id. The nullifier is now a semantic fingerprint of the communication, not an ID of the envelope.
Plonky2 zkSNARKs wired end-to-end
The Plonky2ProofGenerator and MembershipCircuit have lived in phantom-circuit and phantom-zkvm for a while, but they were never called by the routing daemon. phantom-node now initialises a Plonky2ProofGenerator(tree_depth=20, max_path_length=7) at startup and verifies path_proof on every locally-delivered packet via the ProofGenerator trait. The workspace is pinned to Rust nightly via rust-toolchain.toml so Plonky2’s #![feature] gates compile cleanly.
Yen’s k-shortest-paths
Anonymous routing requires path diversity — if only one route exists between two points, traffic analysis narrows the anonymity set to one. NetworkGraph::k_shortest_paths() previously returned a single direct 1-hop path regardless of k. It now implements the full Yen’s algorithm: BFS shortest path as seed, then iterative spur-node expansion with a min-heap candidate queue and per-iteration removed-edge/removed-node sets. Five unit tests cover direct paths, diamond graphs, missing nodes, same-source/dest, and k < available paths.
Realistic network topologies
The simulation crate now generates two important graph types:
Watts-Strogatz small-world: The internet is a small-world network — high clustering coefficient (your neighbours know each other) combined with short average path length (six degrees of separation). The generator now implements the full WS model: ring lattice seeding followed by a rewiring pass that replaces each directed edge with probability β=0.1 with a random non-adjacent target, using a mutable adjacency list to prevent self-loops and duplicate edges.
Barabási–Albert scale-free: Real-world networks have power-law degree distributions — a few hubs with enormous degree, most nodes with low degree. The generator now uses roulette-wheel preferential-attachment selection: each new node picks m connection targets with probability proportional to the current degree of each candidate.
These matter for Phantom because the routing algorithm and anonymity guarantees behave very differently on a uniform random graph versus a realistic internet topology.
HTTP bootstrap
When a Phantom node starts, it needs to join the network — download the current Merkle tree of members, verify its root matches network consensus, and generate its own membership proof. BootstrapClient previously simulated this with an in-process mock. It now makes real HTTP GET requests to http://{addr}/phantom/v1/network_state endpoints, parses a JSON NetworkStateResponse (merkle_root as hex, epoch, node_count, last_update), and verifies the root locally. If all bootstrap nodes are unreachable, it falls back gracefully to a local mock state so a node can still start in a development or air-gapped environment.
RelayKeyRegistry
For fully independent relay operation, each relay node should hold its own FHE keypair — that way a compromised relay cannot decrypt routing tables built for other relays. The RelayKeyRegistry data structure implements this: a map from node_id to Arc<FheEngine>. phantom-node registers its own engine and one per known peer at startup. The packet construction path still uses a shared engine by default — per-relay distribution is the next commit.
Status
Post-quantum primitives ✓ done
FHE routing (parallel) ✓ done
Plonky2 zkSNARKs ✓ done
Content-based nullifiers ✓ done
Yen's k-shortest-paths ✓ done
Small-world topology ✓ done
Scale-free topology ✓ done
HTTP bootstrap ✓ done
Native SDK (Bun FFI) ✓ done
Per-relay FHE keys ~ wiring pending
Live traffic through Phantom ~ not yet
No TNHC service routes real traffic through Phantom yet. The remaining gap is wiring per-relay keys into packet construction and flipping PHANTOM_REQUIRE_REAL=1 in Nexus-Cloud production. For the first time, that milestone is measurably close.
Why this matters
The long-term goal is to remove money from every cloud service that charges for it today — by running a platform that does not need surveillance-based monetization to survive. Phantom is the layer that makes “no surveillance” technically enforceable rather than just a policy statement. The cryptographic properties are not aspirational; they are implemented and testable. The gap is integration, and it is closing.
Code: github.com/The-No-Hands-company/Phantom — MIT OR Apache-2.0