ERC-8535: Content-Addressed Proof Verifier Registry

Contracts that pay, complete jobs or write reputation on the strength of a succinct proof keep asking the same three questions: which verifier, with how much gas, and what a failure means. This draft ERC proposes one answer to each.

What it defines

  1. A verifier registry with no owner. An entry’s identifier is a hash of what will run: the code hashes of a proof-system adapter and of the verifier it drives, the verifying-key hash, the statement’s shape and the gas the check is given. Entries never change. EIP-7702 delegated accounts are refused, because a delegation designator’s code hash does not pin the code that runs.
  2. A proof check with three outcomes: Valid, Invalid, Unverifiable. A proof that could not be checked is never Invalid. The check always gets its declared gas, or the transaction reverts. A verifier that ran out of gas reads Unverifiable, told apart from a rejection by the gas left unspent. The zero value is Unverifiable, so an unset slot, an empty return or a missing record fails safe.
  3. An optional two-step record, so that a later transaction can act on a checked result without carrying the proof.

It also maps the outcomes for four consumers:

  • an x402 auth-capture capture policy, with errorReason values proposed in x402 #4390;
  • an x402 batch-settlement claim gate;
  • an ERC-8183 evaluator;
  • an ERC-8004 validator. Its section includes the agent check from the request-hash note posted in the ERC-8004 thread.

Why a separate ERC

  • ERC-8274 and ERC-7992 cover the same ground with a boolean verify (8274) or a revert on every failure (7992), and an address or an owner as the trust handle. Neither has a place for “could not check”.
  • The draft includes an interoperability rule for a contract that serves this check through ERC-8274’s IProofVerifier: true only for Valid, false only for Invalid, and a revert on Unverifiable.
  • Extending ERC-7992 would mean removing its owner and its revert-only failure mode, which would break its interface.

Reference implementation (unaudited): achemperety/exactzk-zk-inference-escrow at ef8d7ed.

  • The ERC’s assets carry CC0 copies of the registry, the check, the EZKL/Halo2 adapter and the two-step record, with 55 Foundry tests that run on mock verifiers. One asserts the two reference verifierIds.
  • The tests on real EZKL proofs live in the repository above, not in the ERC: its generated verifiers, proofs and verifying keys, the gas measurements, and the consumers’ tests against x402, ERC-8183 and ERC-8004 contracts.
  • A probe there shows why the threshold is 1/16 of the allowance: exhaustion down to four nested all-gas calls stays Unverifiable.

Measurements on real EZKL proofs (gas, the allowance sweep, the first-call surcharge) are in the assets README and in the repository above.

PR: Add ERC: Content-Addressed Proof Verifier Registry by achemperety · Pull Request #2297 · ethereum/ERCs · GitHub

Questions I’d like feedback on

  1. Zero means Unverifiable. Two drafts take the other side: a zero bytes4 as “invalid proof”, and “could not evaluate” as a kind of DENY. Is there a use that needs zero to be a rejection?
  2. No owner, no pause. If a proof system is found unsound, its identifiers are abandoned rather than switched off. Is a consumer-side allow-list enough, or should the ERC define one?
  3. The exhaustion rule. Step 6 assumes at most four nested all-gas calls below the check, and adapters should revert when they cannot tell a rejection from exhaustion. Should reverting be a MUST for adapters, leaving step 6 as a backstop only?
  4. Gas in the identifier. This makes an entry chain-specific when precompile prices differ. Acceptable, or should the allowance live elsewhere?
  5. Scope. Should the consumer mappings (x402, ERC-8183, ERC-8004) live in this ERC, or in their host specifications? Should the two-step record be its own ERC?
  6. ERC-8274 authors. Does the interoperability rule work for an inner verifier on your side?

Update: ERC-8274 now states the rule this draft builds on. Its Security Considerations say that an implementation which cannot complete a check reverts rather than returning false, and that callers should not convert that revert into false ( Update ERC-8274: Note incomplete checks and add a gas-budget caller example by achemperety · Pull Request #2300 · ethereum/ERCs · GitHub , merged). The ERC-8274 interop rule in this draft, which returns false only for Invalid and reverts on Unverifiable, follows that text directly.

A valid proof uses the same gas under a bigger verifyGas, since the unused part comes back to the caller. Only the gas limit goes up. With the reference entries at 1.10x, a fork that adds more than about 10% to the valid path makes every valid proof under that id Unverifiable, and an ERC-8183 job whose setTerms named it can only end by forfeit or expiry. ChannelSettlement already takes a verifier set, so the same code at 1.1x and 2x could sit in one set.

register is open to anyone, and the first registration of some content picks its addresses for good. If the adapter or target can reach SELFDESTRUCT, or a DELEGATECALL to an address from calldata (only SHOULD NOT today), anyone can deploy a copy, register it and self-destruct it in the same transaction, where EIP-6780 still removes the code. That id then reads Unverifiable at step 2, and AlreadyRegistered blocks the same content at a live copy. Would you make those a MUST NOT, or let register re-point an entry whose code is gone?

@Zealynx you’re right on both points, thank you.

Gas: with verifyGas fixed in the id, a fork that raises the valid path’s cost by more than the headroom makes the entry Unverifiable for good, and a job that named it can only end by forfeit or expiry. A verifier set with the same code at several gas levels works today as a mitigation, as you say. The fix I’m leaning towards, also prompted by @wighawag in the ERC-8274 thread: the id commits to a minimum gas rather than an exact one, and whoever presents the proof supplies the gas, at or above that minimum. The 1/16 rule then applies to the supplied amount, so a budget that is too small only yields Unverifiable, and after a repricing the presenter supplies more instead of the job being stranded.

Register: the attack works against the draft as written. First registration fixes the addresses, and a copy that can reach SELFDESTRUCT can be created, registered and destroyed in one transaction under EIP-6780. A MUST NOT on SELFDESTRUCT and on DELEGATECALL to a calldata address would help compliant code, but the registry can’t enforce it, and re-pointing a dead entry can be raced the same way. So I’d rather remove the addresses: the entry records code hashes only, the caller passes the adapter and target addresses at check time, and the check compares their EXTCODEHASH. A destroyed copy then costs nothing, because any live copy with the same code works. The price is a new requirement that adapter and target behaviour must not depend on their own storage, since two copies with the same code hash could otherwise hold different state.

I’ll prototype both changes with your attack as a test before updating the draft. If you see a way to break the address-free version, that’s the most useful thing you could post here.

Correction to my post above, after testing Zealynx’s attack locally: it is broader than I described. The copy doesn’t need SELFDESTRUCT in its runtime code. Its init code can DELEGATECALL a self-destructing helper and still return the honest runtime code. In tests this killed the ids of the real EZKL verifier and of Halo2EzklAdapterV2, neither of which contains those opcodes. So a MUST NOT on SELFDESTRUCT or DELEGATECALL would not help at all. The draft’s statement that a dead entry cannot be revived is also wrong: with CREATE2 the attacker can redeploy at the same address inside their own transactions, so the id reads Valid for them and Unverifiable for everyone else.

The address-free version stopped all five variants I tried, because any live copy works, including one deployed after the attack. Per check it costs about 1,450 gas less when the entry is loaded by id and about 55 more when the entry is passed in calldata; registration costs about 23,200 less. Presenter-supplied gas also held up on real EZKL proofs: across about 10,000 supplied amounts and 2,000 fuzz runs, no valid proof read Invalid, and with the verifier’s cost raised by 50% the same id still gave Valid once the presenter supplied more gas.

Existing registrations are not affected, since the attack needs the destroyed copy to be the first registration of that content. I’ll update the draft with both changes in PR 2297. Thanks again, Zealynx; this is the most useful review the draft has had.

The draft is updated in PR 2297 (commit 35e57284):

  • Entries hold code hashes only. Whoever runs a check names the deployed copies, and a check compares their code hashes. The registration event keeps the addresses as non-binding hints.
  • minVerifyGas is now a floor (645,000 solo, 712,000 K=8, so both reference ids are unchanged); the presenter supplies the actual gas, and the 1/16 rule applies to the supplied amount.
  • Addresses and gas must not be part of what a payer signs, a client sets or a requester names, so neither a dead copy nor a repricing can strand an agreed payment.
  • A new Rationale section, “Entries hold no addresses”, covers the init-code DELEGATECALL variant and the CREATE2 revival.

Asset tests: 95, all passing, plus the attack and gas tests as real transactions on a second EVM. The reference repository still implements the earlier version; Backwards Compatibility says so.

@achemperety on your question of whether Invalid can be reached without real evidence: I went through every path to it. Inside the check it is earned. The paths are step 3 (shape), step 6 (a 0 with more than 1/16 unspent), and the reference adapter’s early false returns: shape at L55, non-canonical commitments or outputs at L64, and a fast verifier failure. Each says these bytes do not verify. None says the claim behind them is false. Your consumer mappings already draw that line. The x402 and batch-settlement routes refuse the attempt, the ERC-8183 evaluator never calls reject, and the ERC-8004 validator writes nothing.

The interoperability rule is where it can leak. Through ERC-8274’s IProofVerifier, Invalid becomes false, and an ERC-8274 consumer that accepts a proof from anyone may treat false as a verdict against the claimant. A third party gets that false with a non-canonical output word or any bytes the verifier rejects quickly.

Would you add the ERC-8183 rule to the interop section? A consumer that accepts proofs from parties other than the claimant MUST NOT act against the claimant on false, and may only refuse that presentation. As an ERC-8274 author, I think 8274’s Security Considerations should say the same, next to the revert rule from #2300. Opened as a small PR to ERC-8274: Update ERC-8274: a false is evidence against the presented proof, not the claim by babyblueviper1 · Pull Request #2312 · ethereum/ERCs · GitHub

On a chain without the BN254 pairing precompile, the reference verifier can accept, where Security Considerations expects it to “reject cleanly”. As I read the generated Halo2Verifier, ec_pairing puts lhs_x at 0x00, calls 0x08 with its output at 0x00, then does ret := and(ret, mload(0x00)). If 0x08 has no code, the staticcall succeeds with no return data and 0x00 still holds lhs_x, so the bitwise and leaves the low bit of lhs_x. For a garbage proof that passes the length, range and on-curve checks, the verifier returns 1 whenever lhs_x is odd, Halo2EzklAdapterV2 passes that on, and the check reads Valid. That’s about half of them, and a presenter can grind for one. Both reference verifiers have this code.

An id is content only, so the two reference ids are the same on every chain, and anyone can register them on a chain like that. The adapter could probe for about 100 gas: staticcall(1, 0x08, 0, 0, 0, 0) fails on the real precompile, whose base cost is 45,000, and succeeds on an empty address. If it succeeds, the adapter reverts and the check reads Unverifiable. Would you put that probe in the adapter, or leave “reproduced on that chain” to whoever picks the ids?

Agreed, and thank you for going through every path. You’ve put the line where it belongs: Invalid says these bytes don’t verify, never that the claim behind them is false. I’ll add your rule to the interop section: a consumer that accepts proofs from parties other than the claimant MUST NOT act against the claimant on false, and may only refuse that presentation. I’ll also state the distinction once in the general part, so the x402, ERC-8183 and ERC-8004 mappings read as instances of one rule rather than separate choices. #2312 is the right place for the ERC-8274 side, and I’ll support it there.

Thank you, that’s a serious one, and it’s in my reference code rather than in the ERC’s logic. Before changing anything I’m reproducing it on an EVM with 0x08 removed, and checking whether the ecAdd and ecMul calls (0x06, 0x07) follow the same pattern. If it holds as you read it:

  1. The adapter gets your probe: a call to 0x08 with 1 gas must fail; if it succeeds, the adapter reverts and the check reads Unverifiable. That is a new adapter version, so both reference ids change. I’d rather change them now, while the ERC is a draft, than keep ids that can read Valid on the wrong chain.
  2. The spec gets a general rule: an adapter MUST revert if a precompile or contract it depends on is absent or doesn’t behave as specified, because an id is content only and can be registered on any chain.
  3. I’ll report the missing return-data check to the maintainers of the verifier template, since any EZKL verifier deployed on such a chain has the same issue, registry or not.

To your question: the probe goes in the adapter. Leaving it to whoever picks the ids would make Valid depend on knowledge the id doesn’t carry.

Reproduced, as you read it. On an EVM without 0x08, behind the current adapter, 963 of 2,000 garbage proofs read Valid for solo and 1,000 of 2,000 for K=8, and a genuine proof can read Invalid as well, depending on the same low bit. The same unchecked pattern is in the verifier’s other precompile calls, so the adapter will probe all four that EZKL’s verifiers use (MODEXP, ECADD, ECMUL, ECPAIRING): each is called with 1 gas, which a precompile can’t pay for and an empty account can, and the adapter reverts if any call succeeds. On a normal chain no answer changes, it adds 524 gas per check, and the gas floors stay where they are. Both reference ids change with the new adapter.

The spec will require an adapter to revert when a precompile it depends on is absent, since an id is content only. I’ve also contacted the verifier template’s maintainers. Thank you, this is the second time a review of yours has changed the draft for the better.

Checked against 3400678a: the rule reads right. Outcomes states it once, and each consumer section (x402 auth-capture, batch-settlement, the ERC-8183 evaluator, the ERC-8004 validator, the boolean interface) refuses on Invalid and changes nothing.

One place it can still leak, outside the contracts. In the auth-capture table, Invalid goes back to the client as invalid_auth_capture_evm_proof_invalid. A client or reputation service that logs failed payments per payee would read that as the payee’s failure, and a third party can produce it with garbage. One line under that table would close it: the reason reports a refused attempt, and a client MUST NOT record it against the payer, the payee or the claim. That gives it the same treatment the ERC-8004 section gives the Validation Registry.

Agreed, that’s the same leak one layer out, and a reason code is exactly what payment logs and reputation services store. Added under the auth-capture table in c1d5c36b: the reason reports a refused attempt, and a client MUST NOT record it against the payer, the payee or the claim, just as the ERC-8004 validator writes nothing on Invalid. Thanks for checking every consumer section against 3400678a.

The reference implementation now matches the draft. v3.2 is deployed on Base Sepolia (testnet, chainId 84532) with the address-free registry, presenter-supplied gas and Halo2EzklAdapterV4, and both registrations carry the draft’s reference ids (solo 0x40936d83…0384, K=8 0xcbd9f702…683a). All nine contracts are source-verified on Sourcify and Blockscout. Deployment record: exactzk-zk-inference-escrow/deployments/base-sepolia-v3.2.json at v3.2.0-testnet · achemperety/exactzk-zk-inference-escrow · GitHub

There is also a second adapter, for SP1 Groth16 and Plonk (v4.0.0-rc.3 and v6.0.0), with one adapter serving every program through vkHash: exactzk-zk-inference-escrow/adapters/sp1 at main · achemperety/exactzk-zk-inference-escrow · GitHub . Its largest unspent share below cost is 4.20% (Groth16) and 3.50% (Plonk), under step 6’s 6.25%, and a valid proof never read Invalid at any supplied gas.