The circuit compiled. The test suite went green. Three audit firms signed off with 'no critical findings.' And yet, three weeks into a review of a freshly funded, $100M zero-knowledge agent-identity protocol, I found a soundness error that let a single private key mint unlimited verified identities. It was not in the Groth16 verifier. It was not in the credential schema. It sat in the aggregation step—the part every team treats as plumbing, the part nobody puts on the pitch deck.

I have found a soundness bug in the glue logic between proofs three times in eighteen months. Each time the cryptography was fine. Each time the failure was the assumption that valid proofs compose without friction. The primitive is rarely the weakest link; the interface between primitives is. Tracing the gas leak in the untested edge case, I keep arriving at the same room: not the vault, but the hallway connecting the vaults.
The protocol is representative of the 2026 agent-identity wave. AI agents—trading bots, oracles, autonomous treasury managers—need on-chain identity for smart contracts to trust them. The pitch is elegant: an agent proves possession of a credential via zk-SNARK without revealing the credential, and a contract acts on the proof. No KYC quorum, no multisig oracle, no trusted admin. Just math.
Agent identity amplifies every property that makes this dangerous. A human's credential is checked occasionally, at login. An agent's credential is consumed continuously, by every contract that routes capital to it. A misattributed license is not a single fraudulent login; it is a persistent authorization that executes thousands of times before anyone reconciles the attribution log. Autonomy turns a soundness edge case into continuous, compounding exposure.
The architecture has four layers, and the failure was in the third. An issuer signs a credential off-chain. The agent proves knowledge of it inside a Groth16 circuit and emits a proof. An aggregator batches N proofs into one recursive proof so the verifier pays a single pairing check instead of N. A Solidity verifier on L2 validates the aggregate and updates reputation state. Recursion is what makes it affordable: verify once, trust many.
The aggregator has a parameter nobody scrutinizes: the batch commitment. It concatenates the public inputs of each proof and hashes them into one value. Here is the crack. The recursion circuit accepts public inputs as a contiguous array and does not bind them to the ordering of individual proofs. Two agents in the same batch can have their public inputs swapped, and the aggregate still verifies. This is not forgery. It is misattribution of a valid proof to the wrong identity.
In a reputation system, misattribution is the whole game. If agent A holds a 'licensed-strategist' credential and agent B holds 'unverified,' a reordering can swap which public key the aggregate attributes the license to. The verifier contract sees an aggregate proof and an input vector; the math screams approval. Optimizing the prover until the math screams is not the same as making the math correct. The pairing check cannot see a permutation that happened upstream.
All three audit reports modeled the verifier, not the aggregator. The verifier is two hundred lines on battle-tested libraries. The aggregator is Rust, fourteen hundred lines, with a custom serializer. It was excluded as 'off-chain infrastructure.' That is the standard laundering of risk: move the flawed component one layer down, call it infrastructure, and the security budget evaporates. The circuit is a hypothesis waiting to break, and off-chain code is where hypotheses avoid scrutiny.
None of this argues against recursion. Recursion is why the economics close at all. Latency is the tax we pay for decentralization; recursive aggregation is the tax we pay for affordable verification. The mistake is treating the aggregator as free. Every layer that touches public inputs is part of the trust boundary, whether it lives on-chain and whether an auditor was paid to read it.
The gas arithmetic is what makes the bug profitable and what hides it. A single Groth16 verification costs roughly 250k gas; a recursive aggregate amortized over 128 agents drops the per-identity cost by an order of magnitude. That efficiency is the entire value proposition. But the same batching that amortizes verification also amortizes the attribution error: one mis-ordered batch corrupts 128 identities at once. Efficiency and blast radius scale together, and only one of them is in the deck.
This is the entropy constraint of modularity. Each module gets simpler and more auditable alone; the composition gets more complex and less auditable together. Modular systems do not reduce total complexity—they relocate it to the seams. A monolithic rollup has one huge surface. A modular stack has ten smaller surfaces and nine undocumented glue contracts between them. Modularity isn't an escape from entropy; it's an entropy constraint that relocates failure modes.
I saw the same pattern in 2022, inside Celestia's data availability sampling. The sampling proofs were elegant. What killed you was what the light client did with a sampling result it did not fully trust. The cryptography returned a probability; the bug class was the code downstream that assumed a binary answer. Same hallway, different vault.
The 2025 bridge review was identical in shape. Optimistic verification on Ethereum, message passing to Polygon, a reentrancy in the module reconciling the two states. The trust assumption was not 'the light client is honest.' It was 'the light client sees one valid state at a time,' and the code quietly allowed two. Every system of this kind fails where two independently-correct components disagree about a shared assumption.
Formally, the flaw is a missing binding. The aggregate verifier checks that the proof is valid for the statement 'there exist N valid credential proofs whose public inputs hash to H.' It does not check that H commits to the assignment of inputs to proofs. The fix is a Merkle root over ordered (pubkey, credential) tuples, bound inside the recursion circuit so the prover cannot choose the order. Cheap to state. Two weeks of circuit work. Launch was in six days.
The honest fix costs latency and complexity, and the market punishes both. Binding ordered tuples inside the circuit adds constraints, which adds proving time, which adds cost—the exact axis every team is optimizing. So the flaw persists, not because engineers are careless, but because the incentive gradient points away from the seam and toward the demo. This is the recurring trade-off: correctness of composition is invisible until it isn't, and by then the TVL has already been counted.
Consider the incentive. A verified identity commands a reputation premium; unverified agents are throttled by the contracts that consume them. The gap between the two is an arbitrage. Any soundness error that crosses that gap without possession is a printable subsidy. Unlike a hacked bridge, the exploit leaves no anomalous transaction—just a proof that verified. The damage is invisible until someone audits attribution history, which nobody does while TVL climbs.
This is the masquerade of the current cycle. Capital flows to anything with 'ZK' and 'AI agent' in the deck, and due diligence compresses to a logo check. The project I reviewed had a live mainnet, a partnership announcement, and a forty-page tokenomics paper. It did not have a single integration test that permuted batch inputs. That absence is not laziness. It is unpriced risk, and unpriced risk compounds quietly until a particular Tuesday.
The comfortable conclusion is 'audit the aggregator too.' That is insufficient. The deeper problem is that agent-identity protocols are selling a soundness property they cannot deliver, because soundness of a composed system is a multi-party property and the documentation frames it as a single-proof property. The marketing says 'verify without revealing.' The math says 'verify without revealing, assuming the aggregator preserves attribution.' The more decentralized the verification, the more the off-chain aggregator inherits centralized trust—and the less anyone looks at it.
The uncomfortable corollary: the more credible the cryptography, the less scrutiny the bridge between proofs receives. A team that ships a clean Groth16 circuit earns trust that quietly extends to every adjacent component. Trust is a poor auditor.
There is a second blind spot. Proof systems are optimized for throughput—Groth16 for cheap pairing, PlonK for universal setup, recursion for batching—and every optimization relaxes an assumption to buy speed. The assumption that public-input ordering is preserved is not in the security proof. It is in the comment block. The circuit does not check what the specification does not specify, and specifications are written by the same people racing a launch date.
The vulnerability forecast is unglamorous. The next major loss in agent identity will not be a key compromise or a verifier bug. It will be a misattribution at the seam—a valid proof routed to the wrong identity, a batch reordered, a binding omitted. Debugging the future one opcode at a time, I expect the first public incident within two quarters, and I expect the post-mortem to call it a deployment configuration. The code will have been correct the whole time. The composition will have been the lie.