--- eip: 8535 title: Content-Addressed Proof Verifier Registry description: Immutable registry of proof verifiers identified by code hash, and a proof check with three outcomes, Valid, Invalid, Unverifiable author: Ruslan Baiandin (@achemperety) discussions-to: https://ethereum-magicians.org/t/draft-erc-content-addressed-proof-verifier-registry/30598 status: Draft type: Standards Track category: ERC created: 2026-11-26 requires: 150, 1052, 7702 --- ## Abstract This ERC defines three things: 1. A **verifier registry** with no owner. Every entry is immutable, and its identifier is a hash of what will run: the code hashes of a proof-system adapter and of the verifier contract it drives, the verifying-key hash, the shape of the statement and the least gas a check may be given. An entry holds no addresses: whoever runs a check names deployed copies of the code, and the check compares their code hashes with the entry's. 2. A **proof check** with three outcomes: `Valid`, `Invalid`, `Unverifiable`. The normative rule is that a proof that *could not be checked* is never reported `Invalid`. The zero value of the outcome is `Unverifiable`, so anything that defaults to zero (an empty return, a missing record, an unset variable) fails safe: it means "nothing was decided". 3. An optional **two-step record**: anyone may check a proof once and record `Valid` or `Invalid` under `keccak256(abi.encode(verifierId, inputCommitment, keccak256(abi.encode(output, proof))))`, so that a later transaction can act on the result without carrying the proof. The ERC also specifies how four consumers map the outcomes: an x402 `auth-capture` capture policy, an x402 `batch-settlement` claim gate, an [ERC-8183](./eip-8183.md) evaluator and an [ERC-8004](./eip-8004.md) validator. ## Motivation Contracts that release funds, complete jobs or write reputation on the strength of a succinct proof face the same three questions every time: - **Which verifier?** A verifier address, or an id handed out by an owner, does not say what code runs. An upgradeable verifier, a registry whose owner can repoint an id, or an account whose code is an [EIP-7702](./eip-7702.md) delegation can change the meaning of a proof that was agreed on earlier. - **With how much gas?** A proof check that the transaction sender can under-fund lets that sender turn a valid proof into a failure. An amount of gas fixed in advance has the opposite problem: a hard fork that raises the cost can leave a valid proof uncheckable for good. - **What does a failure mean?** A boolean `verify` merges "the proof is wrong" with "the check could not run": the verifier is unknown, its code changed, the call ran out of gas after a hard fork repriced a precompile. Consumers act very differently on the two. "Wrong" may end a job or count against an agent. "Could not run" should change nothing, and the same proof may pass later. The drafts in flight answer these questions differently, or leave them open (see [Rationale](#relation-to-other-proposals)). This ERC fixes one answer, measured on a working implementation with the four consumers above: - the verifier is identified by content, can never change and does not depend on any one deployed copy; - the check gets exactly the gas its caller names, at or above a floor that the identifier fixes, or the transaction reverts; - `Unverifiable` is a separate outcome, and it is the default. ## Specification The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174. ### Statement Every proof is checked against one statement, whatever the proof system. A proof has `lanes ≥ 1` lanes. For each lane `i`: > the circuit behind the entry's verifier contract maps the input committed to by `commitments[i]` to `outputs[i * outputSize : (i + 1) * outputSize]`. Nothing else is part of the statement. A *solo* circuit has one lane. A proof is reusable for every claim with the same `(verifierId, inputCommitment)`. Software that sets an input commitment SHOULD draw fresh randomness into it after the verifier is named. ### Adapter An adapter translates the statement into one proof system's verifier interface. One deployment serves every verifying key of its proof system: the key is either embedded in the code of `target` or passed in as `vkHash`. ```solidity interface IProofAdapter { /// @return ok True if and only if `proof` establishes every lane's statement. function verify( address target, bytes32 vkHash, // the entry's vkHash, passed by the check uint32 outputSize, bytes32[] calldata commitments, bytes calldata outputs, bytes calldata proof ) external view returns (bool ok); /// @notice Tag of the proof system, for example keccak256("halo2-kzg-bn254/ezkl"). function proofSystem() external view returns (bytes32); } ``` - `vkHash` is the entry's `vkHash`, which the check passes unchanged. What it holds is defined per proof system, by the adapter. An adapter whose `target` serves more than one verifying key MUST take the key from `vkHash`, so that the identifier binds the key, and MUST NOT take it from `proof` or any other argument the presenter chooses. An adapter whose `target` embeds its key MAY ignore `vkHash`. | Proof system | `vkHash` | What the adapter does with it | |---|---|---| | EZKL (Halo2, KZG, BN254) | `keccak256` of the canonical verifying-key bytes | Nothing. The generated verifier embeds its key, so `targetCodeHash` fixes the key that a proof is checked against. The verifier has no function that returns its key, and its code holds the key as constants spread through it, so the adapter cannot compare the two. The reference adapter accepts `vkHash` and does not read it. | | SP1 (Groth16, Plonk) | The program key, `vk.bytes32()` | Passes it to the SP1 verifier as `programVKey`. One SP1 verifier serves every program, so its code hash cannot fix the program; the identifier binds it through `vkHash`, and one adapter serves every program. | - An adapter MUST hold no state and MUST NOT read any. Its answer MUST depend only on its code, its arguments, the code of `target` and precompiles. The code at `target` MUST NOT read state either. For both, state includes the account's own storage, balance and address. A check relies on this: its caller chooses which copies of the code run, and anyone can deploy a copy with storage of their choosing. - The adapter and `target` SHOULD NOT contain `DELEGATECALL` or `CALLCODE`, because the code those run is not in the code hash, and SHOULD NOT contain `SELFDESTRUCT`. Avoiding the three does not keep a copy from being destroyed, and an entry does not need it to: see [Entries hold no addresses](#entries-hold-no-addresses). - The adapter and `target` MUST forward all of their remaining gas on every call they make, to a precompile or to other code, and such calls MUST NOT nest more than four deep, counted from the adapter's call to `target` (the depth assumption of [Check](#check)). A fixed amount turns a precompile repricing into a clean rejection with gas to spare, which step 6 cannot tell from a real one and which supplying more gas does not repair. The one exception is a call whose success can only make the adapter revert, such as the probe in the next rule: no repricing can turn it into a rejection. - An adapter MUST revert, and MUST NOT return either `true` or `false`, if a precompile or contract that it or `target` depends on is absent from the chain. An identifier is content only, so an entry can be registered on any chain, including one that lacks a precompile its verifier calls, and a call to a missing precompile succeeds with no return data. The check belongs in the adapter, not with whoever chooses which identifiers to accept, so that `Valid` never depends on knowledge the identifier does not carry. The reference adapter probes all four precompiles that EZKL's generated verifiers call, `MODEXP`, `ECADD`, `ECMUL` and `ECPAIRING`, before calling `target`: each is called with 1 gas and no input, which the precompile cannot pay for and an account without code can, and the adapter reverts if any of these calls succeeds. Whether a precompile that is present behaves as specified is not something an adapter can establish for itself: registrants SHOULD test each entry on every chain where it is used. - `verify` MUST return `false` when the verifier gives a definite rejection: a bad proof, a malformed argument, a public input outside the proof system's field. - `verify` SHOULD revert, not return `false`, when it cannot tell a rejection from a failure of the verifier call. For a target that rejects by reverting with no data, the adapter SHOULD revert whenever `target` did not accept and no more than 1/16 of the gas the adapter started with is left. That is the same threshold as [Check](#check) step 6, applied to the adapter's own call. The check classifies a revert as `Unverifiable`. Whatever an adapter does here, step 6 also catches a target that exhausted its gas inside the adapter, within the depth that step assumes. - `proofSystem()` MUST be constant for the adapter's code. ### Registry ```solidity struct VerifierEntry { uint32 lanes; // statements per proof; 1 for a solo circuit uint32 outputSize; // bytes of output per lane uint32 minVerifyGas; // floor for the gas a check hands to the adapter bytes32 adapterCodeHash; // EXTCODEHASH of the adapter (IProofAdapter) bytes32 targetCodeHash; // EXTCODEHASH of the system-specific verifier contract; 0 if the adapter needs none bytes32 vkHash; // the verifying key, as the adapter defines it (see Adapter); passed to the adapter bytes32 emptyLane; // commitment that marks a padding lane; 0 if the circuit has none } interface IVerifierRegistry { /// @dev `target` and `adapter` are hints, not part of the entry. event VerifierRegistered( bytes32 indexed verifierId, bytes32 indexed vkHash, address indexed target, address adapter, bytes32 adapterCodeHash, bytes32 targetCodeHash, bytes32 proofSystem, uint32 lanes, uint32 outputSize, uint32 minVerifyGas, bytes32 emptyLane ); error AlreadyRegistered(bytes32 verifierId); error NoCode(address account); error CodeHashMismatch(address account, bytes32 expected, bytes32 actual); error DelegatedAccount(address account); error TargetHashWithoutTarget(); error ZeroLanes(); error ZeroVerifyGas(); /// @param adapter A live copy of the adapter. Not stored. /// @param target A live copy of the verifier contract, or address(0) if the adapter needs none. Not stored. function register(VerifierEntry calldata e, address adapter, address target) external returns (bytes32 verifierId); function computeId(bytes32 proofSystem, VerifierEntry calldata e) external pure returns (bytes32); function entry(bytes32 verifierId) external view returns (VerifierEntry memory); function entryHash(bytes32 verifierId) external view returns (bytes32); function exists(bytes32 verifierId) external view returns (bool); } ``` **Identifier.** The identifier commits to the proof system and to every field of the entry: ```solidity verifierId = keccak256(abi.encode( proofSystem, // IProofAdapter(adapter).proofSystem(), read at registration e.vkHash, e.targetCodeHash, e.adapterCodeHash, e.lanes, e.outputSize, e.minVerifyGas, e.emptyLane )); ``` **Registration.** `register` MUST be callable by anyone. Its caller shows it one live copy of the adapter and, unless the adapter needs none, one of the verifier contract. It MUST revert: - with `ZeroLanes` if `lanes == 0`, and with `ZeroVerifyGas` if `minVerifyGas == 0`; - with `NoCode` if `adapter` has no code, or if `target` is non-zero and has no code; - with `CodeHashMismatch` if `adapter.codehash != adapterCodeHash`, or if `target` is non-zero and `target.codehash != targetCodeHash`; - with `TargetHashWithoutTarget` if `target == address(0)` and `targetCodeHash != 0`; - with `DelegatedAccount` if the code of `adapter` or `target` begins with the EIP-7702 delegation designator `0xef0100`; - with `AlreadyRegistered` if the identifier exists. On success it MUST store the entry and `keccak256(abi.encode(e))` under the identifier, and emit `VerifierRegistered`. It MUST NOT store `adapter` or `target`. **The addresses in the event are hints.** `VerifierRegistered` carries the two addresses that were shown to `register`, to help presenters find deployed copies. They are not part of the entry and they bind nobody. A check never uses them: it MUST take its addresses from its caller, and MUST accept any account that has the registered code. A hint can be dead, because the account may have been destroyed since, even in the transaction that registered the entry. That only means that the presenter has to find another live copy, or deploy one. **Delegated accounts are refused.** An EIP-7702 delegated account's code is the 23-byte designator `0xef0100 ‖ delegate`, and `EXTCODEHASH` returns the hash of that designator, not of the code that runs. Such an entry would commit to a pointer, not to content, which defeats content addressing. Worse, the account's key holder can re-delegate at any time with one signed authorization. They can point the account at a contract that writes the account's storage and then point it back. The designator, and so the code hash, is the same as before, but the storage the delegate reads is different. Both checks this ERC relies on, the code hash at registration and at use, would pass while different behaviour runs. The refusal is needed at registration only. Being a designator is a property of the code, and a check accepts an account only if its code has the same hash as the code that `register` examined. **Immutability.** The registry MUST have no owner and no function that changes or removes an entry. It MUST NOT be deployed behind an upgradeable proxy. `entry` of an unknown identifier MUST return an all-zero entry. `entryHash` of an unknown identifier MUST return zero. **What an identifier pins.** It pins code, not addresses. An entry points at no deployed copy; whoever runs a check chooses the copies. For code that reads no state, every copy behaves the same. Where the adapter passes `vkHash` to the verifier as the key, as for SP1, the identifier binds the key. Where the verifier embeds its key, as for EZKL, the identifier does not prove that the verifier code embeds the key `vkHash` names. That is established off chain, by regenerating the verifier from the key and comparing bytecode. ### Outcomes ```solidity enum ProofStatus { Unverifiable, // 0: the check could not be run, or ran without a definite answer. Nothing was decided. Valid, // 1: an adapter with the registered code, on a target with the registered code, accepted. Invalid // 2: such an adapter, on such a target, definitely rejected; or the arguments do not fit the entry. } ``` **Normative rule: "could not be checked" never becomes `Invalid`.** An implementation MUST return `Invalid` only in the two cases [Check](#check) names, steps 3 and 6. Every other failure, including any the implementation cannot classify, MUST be `Unverifiable`. **Zero means `Unverifiable`.** A reader of a `ProofStatus` that crosses a call boundary or comes from storage MUST read it as `Unverifiable` in each of these cases: the call failed, the return data is not exactly 32 bytes, the value is 0, or the value is anything but 1 or 2. Why zero is `Unverifiable` and not `Invalid`: [Rationale](#zero-is-unverifiable). **`Invalid` is evidence against the presented bytes, not against the claim.** `Invalid` says that this proof, with these arguments, does not verify under the entry. It never says that the statement is false: a true statement presented with a corrupted proof, with arguments that do not fit the entry, or with an output word outside the proof system's field also reads `Invalid`. Only `Valid` says anything about the statement. Every consumer rule in this ERC applies this distinction. **What a consumer may do with each outcome.** - On `Valid`, a consumer MAY act on the statement. - On `Unverifiable`, a consumer MUST NOT take any action it would not take if no proof had been presented. In particular, it MUST NOT end, reject, refund, penalise or record anything against the claim or payment the proof was for. A deadline that passes while proofs are `Unverifiable` is the host protocol's own exit, not a verdict. A consumer MUST NOT turn repeated `Unverifiable` outcomes, or the time spent waiting for a definite one, into a rejection. - On `Invalid`, a consumer MAY refuse that presentation, and MUST NOT treat it as a verdict on the claim. Where anyone other than the claimant may present a proof, it MUST NOT end, reject, refund, penalise or record anything against the claim or payment on `Invalid`, because a third party can present garbage. It SHOULD refuse that attempt and leave everything as it was. - A consumer that moves funds on a proof MUST make their destination independent of who presents the proof: for example the signed recipient, the signed payee of a request, or the job's provider. ### Check A check takes: - a registry `R` and a `verifierId`; - either a caller-supplied entry `e` or none; - `adapter` and `target`, the copies of the code to run; `target` is `address(0)` if the entry has no target; - `verifyGas`, the gas to hand to the adapter; - `commitments`, `outputs` and `proof`. It MUST proceed as follows: 1. **Authenticate or load the entry.** Exactly one of two branches applies: - *Entry supplied by the caller.* Let `h = R.entryHash(verifierId)`. If `h == 0` (unknown identifier) or `h != keccak256(abi.encode(e))` (not the registered entry), return `Unverifiable`. Otherwise continue with the supplied `e`. - *No entry supplied.* Let `e = R.entry(verifierId)`. If `e.adapterCodeHash == 0` (unknown identifier), return `Unverifiable`. Otherwise continue with the loaded `e`. 2. **Check the code.** Return `Unverifiable` in each of these cases: - `adapter.codehash != e.adapterCodeHash`; - `e.targetCodeHash != 0` and `target.codehash != e.targetCodeHash`; - `e.targetCodeHash == 0` and `target != address(0)`. Comparing hashes is not enough here, because an account that does not exist also has code hash 0. 3. **Check the shape.** If `commitments.length != e.lanes` or `outputs.length != e.lanes * e.outputSize`, return `Invalid`. 4. **Reserve the gas.** If `verifyGas < e.minVerifyGas`, or if `gasleft() < verifyGas + verifyGas / 63 + margin`, the check MUST revert, and MUST NOT return any status. No value of `verifyGas` may make the sum wrap around. `margin` covers the call itself and the operations between this test and the call. It is implementation-defined; the reference uses 5,000. 5. **Call.** `STATICCALL` `adapter` with exactly `verifyGas` gas and calldata `abi.encodeCall(IProofAdapter.verify, (target, e.vkHash, e.outputSize, commitments, outputs, proof))`. Let `used` be `gasleft()` just before the call minus `gasleft()` just after it. 6. **Classify.** - The call succeeded, returned exactly 32 bytes, and the word is `1`: return `Valid`. - The call succeeded, returned exactly 32 bytes, the word is `0`, and `used < verifyGas - verifyGas / 16` (more than `verifyGas / 16` left unspent): return `Invalid`. - Anything else: return `Unverifiable`. That covers a revert, running out of gas, return data of another length, another word, and a `false` returned after the adapter consumed nearly all of the gas it was given. The last condition in step 6 matters because a verifier can signal rejection by reverting with no data, which looks the same as running out of gas. An adapter cannot tell the two apart by return data, and in good faith returns `false` for both. Step 6 tells them apart by the gas left unspent. Running out of gas deep inside the adapter does not use all of `verifyGas`. Every call that forwards all of its remaining gas keeps back 1/64 of it ([EIP-150](./eip-150.md)), and gets that back when the inner call fails. Let `d` be the number of nested calls below the check that forward all remaining gas, counted from the adapter's call to its target down to the call that ran out. Then the gas left unspent after exhaustion is at most verifyGas * (1 - (63/64)^d) which is about 1.6% at `d = 1`, 3.1% at `d = 2`, 4.6% at `d = 3`, 6.1% at `d = 4` and 7.6% at `d = 5`. Some examples of `d`: - `d = 1`: the target ran out in its own code. - `d = 2`: the target ran out inside a precompile. This is the case of a precompile repricing such as Osaka's `MODEXP` change. - `d = 3`: target, then helper, then precompile. **Depth assumption.** The threshold `verifyGas / 16` (6.25%) covers `d <= 4`, whatever amount is supplied. An adapter and target whose all-gas call chain is deeper than four, counted from the adapter's call, MUST NOT be registered: below the threshold, their exhaustion can read as `Invalid`. The floor does not replace this rule. It keeps a presenter from starving a deeper target at the prices the floor was sized for, but once a repricing uses up the headroom, a valid proof can read `Invalid` at the floor. EZKL's generated verifiers, behind the reference adapter, have `d <= 2`. Registrants SHOULD measure the depth of each entry on each chain where it is used, with the second probe of [Probe](#probe): a valid proof run at every budget below its cost must never leave `verifyGas / 16` or more unspent. **Sizing the gas.** `minVerifyGas` is a floor: a check may be given more, never less. Registrants SHOULD set it at least 10% above the measured cost of the most expensive path, rejection included. Measure it as the first call in a transaction, which pays the [EIP-2929](./eip-2929.md) cold-account charge for the adapter and the target, on the chain where the entry is used. A genuine rejection then leaves at least about 9% unspent, above the 6.25% threshold. Presenters SHOULD supply at least 10% above what the check costs when they present the proof. At the prices the floor was sized for, the floor itself is enough. After a repricing, the same proof is checked under the same identifier with more gas. Supplying more than the check needs raises only the transaction's gas limit, because the caller gets unspent gas back. A check MUST be `view`. It MAY be implemented as an internal library, as the reference does, or exposed by a contract. ### Optional: two-step record A contract that records checks implements: ```solidity interface IProofCheckRecord { /// @notice A check produced a definite answer. The output travels here. event CheckRecorded( bytes32 indexed key, bytes32 indexed verifierId, bytes32 indexed inputCommitment, bool valid, bytes output ); /// @notice Check a one-lane proof and record Valid or Invalid. Anyone may call this. function recordCheck( bytes32 verifierId, address adapter, address target, uint256 verifyGas, bytes32 inputCommitment, bytes calldata output, bytes calldata proof ) external returns (ProofStatus); /// @notice The recorded outcome under `key`; Unverifiable (0) if none. function recorded(bytes32 key) external view returns (ProofStatus); /// @notice keccak256(abi.encode(verifierId, inputCommitment, proofHash)). function recordKey(bytes32 verifierId, bytes32 inputCommitment, bytes32 proofHash) external pure returns (bytes32); function registry() external view returns (IVerifierRegistry); } ``` - The key MUST be `keccak256(abi.encode(verifierId, inputCommitment, keccak256(abi.encode(output, proof))))`. The addresses and the gas are not in it: no choice of copies or gas turns one definite answer into the other. - `recordCheck` MUST run [Check](#check) with one lane and with the `adapter`, `target` and `verifyGas` its caller names. If a result is already recorded under the key, it MUST return that result without running the check again. - On `Valid` or `Invalid`, it MUST store the result under the key and emit `CheckRecorded`. On `Unverifiable`, it MUST store nothing and emit nothing, so that the same bytes can be presented again once they can be checked. - A stored result MUST never change. The record has no owner and no delete. - `recorded` of a key with no record MUST return `Unverifiable`. Because zero is `Unverifiable`, the storage default is already the right answer. - A consumer that moves funds on a record MUST read `Valid` under the key computed from the terms it binds. The transaction that moves the funds MUST carry `verifierId`, `inputCommitment` and `proofHash`, and the output MUST be on chain in the `CheckRecorded` event of that record. The input commitment is in the key in the clear, beside `verifierId`. A consumer can tie a record to a payment only through terms the payer signed. If the key hid the commitment inside the proof's hash, a presenter could pair a payment with a valid record for another commitment. ### Consumers These sections are normative for implementations that claim to follow this ERC in the named context. Each applies the rule of [Outcomes](#outcomes) that `Invalid` is evidence against the presented bytes only: none of them acts against a claim on `Invalid`. **The addresses and the gas come from the presenter.** A consumer that runs the check MUST take `adapter`, `target` and `verifyGas` from whoever presents the proof, together with the proof. It MUST NOT fix them in advance, and they MUST NOT be part of what a payer signs, a client sets or a requester names. Otherwise a destroyed copy or a repricing could strand a payment, a job or a request that was already agreed on. The presenter gains nothing by choosing them badly: addresses without the registered code give `Unverifiable`, and too little gas reverts or gives `Unverifiable`. **Anyone may present until the deadline.** A consumer that takes `verifyGas` from the presenter MUST accept a proof for a claim from anyone, directly or through the [optional two-step record](#optional-two-step-record), until the claim's deadline. Where the host protocol lets only one party act, as in x402 `auth-capture`, the section for that context says how the rule is met. Otherwise the only party allowed to present could supply too little gas, or name copies without the registered code, until the deadline passes: every answer would be `Unverifiable`, and the host protocol's exit would decide instead of the proof. #### x402 `auth-capture`: capture policy A read-only policy answers an operator's capture or charge with one status word (`bytes32`, short ASCII, left-aligned). The `errorReason` strings below are **proposed in x402 issue 4390; they are not part of x402**. x402 reserves the `"policy"` operator type and its fields, but defines neither these reasons nor this reason-returning check. Until x402 adopts them, an implementation uses them as written here and SHOULD NOT present them as x402's. | Check outcome | Policy answers | `errorReason` (proposed in x402 issue 4390) | |---|---|---| | `Valid` | `"Authorized"` | none | | `Invalid` | `"ProofInvalid"` | `invalid_auth_capture_evm_proof_invalid` | | `Unverifiable` | `"VerifierUnavailable"` | `invalid_auth_capture_evm_verifier_unavailable` | | (terms the payer's salt does not bind) | `"Denied"` | `invalid_auth_capture_evm_policy_denied` | - The `invalid_auth_capture_evm_proof_invalid` reason reports a refused attempt. A client MUST NOT record it against the payer, the payee or the claim, just as [ERC-8004: validator](#erc-8004-validator) writes nothing to the Validation Registry on `Invalid`. - The zero word MUST NOT be a status. An operator MUST revert on every word but `"Authorized"`, and pass the word on unchanged. - A facilitator that uses the proposed reasons MUST NOT map an unknown word, an unrecognised revert or an empty revert to `invalid_auth_capture_evm_proof_invalid`. - A refusal refuses that attempt only. The hold stays capturable until its capture deadline, and the payer's `reclaim` after it is the escrow's own. - The data that reaches the policy with the proof carries `adapter`, `target` and `verifyGas`. The payer's salt MUST NOT bind them. - Only the operator captures, so the rule that anyone may present until the deadline ([Consumers](#consumers)) is met here in one of two ways: through the [two-step record](#optional-two-step-record), which anyone may write and the hook reads, or where the operator is already trusted to capture at all. An operator that supplies too little gas gains no power it did not already have by not capturing. - A policy that also exposes the scheme's boolean hooks (`authorizeCapture`, `authorizeCharge`) returns `true` only for `"Authorized"`. - On the optional two-step route, the hook reads the [record](#optional-two-step-record): no record is `"VerifierUnavailable"`, a recorded `Invalid` is `"ProofInvalid"`, a recorded `Valid` is `"Authorized"`. #### x402 `batch-settlement`: claim gate A gate that is both the channel's `receiverAuthorizer` and its `receiver` claims a voucher's value one unit per proven request. Each request is an input commitment and a payee, signed by the payer under a per-batch root. - On `Valid`, the gate claims exactly one unit and pays it to the payee of the signed request. - On `Invalid`, it reverts with `ProofInvalid()`. On `Unverifiable`, it reverts with `VerifierUnavailable(verifierId)`. Either way the request's position stays open. - The presenter cannot name the payout. The claim call carries `adapter`, `target` and `verifyGas` beside the proof, and the payer's signed root does not cover them. #### ERC-8183: evaluator The job's client names `(verifierId, inputCommitment)`, and no address or gas, while the job is Open. Once the provider has submitted, anyone may present a proof. - On `Valid`, the evaluator calls `complete`, with the claim digest `keccak256(abi.encode(verifierId, inputCommitment, keccak256(output)))` as the reason, and publishes the output in an event. - On `Invalid` or `Unverifiable`, it reverts and changes nothing. The evaluator MUST NOT call `reject` on either, because a third party could otherwise end a job with garbage. A job evaluated this way ends completed, given up by its provider, or expired. - The evaluator MUST refuse proofs at and after `expiredAt`, so that completion and `claimRefund` are never both available. #### ERC-8004: validator A request names the agent's claimed output for a `(verifierId, inputCommitment)`, and no address or gas. Anyone may present a proof. - A validator that follows this ERC MUST accept only request hashes that commit to `agentId`, the chain and the validator, and MUST read `getValidationStatus(requestHash)` and refuse to respond if the stored `agentId` is not that agent. The reason: the Validation Registry keys a request by its hash alone and stores the agent named by whoever opened it first, so anyone who learns a hash before it is used can open it for another agent, and an answer by hash would be credited to that agent. - On `Valid`, the validator writes a response. If the proven output's hash equals the claimed one, the response is `100`, tag `zk-proof/passed`. Otherwise it is `0`, tag `zk-proof/contradicted`, because the circuit maps one input to one output, so the claim is shown to be false. The response hash is the claim digest above, the same value an ERC-8183 job records. - On `Invalid` or `Unverifiable`, the validator reverts and writes nothing. The Validation Registry averages responses and has no value for "could not check", so any response written there reads as a verdict. #### Interoperability with boolean verifier interfaces A contract that exposes this check through an interface returning `bool`, such as the inner verifier of [ERC-8274](./eip-8274.md), MUST return `true` only for `Valid` and `false` only for `Invalid`, and MUST revert on `Unverifiable`. Where the interface has no parameters for `adapter`, `target` and `verifyGas`, the contract MUST read them from a field that the presenter fills in. In ERC-8274 that is `proof`, not `metadata`, which that ERC defines as configuration fixed at deployment. Through such an interface, `false` is `Invalid`, and carries no more than [Outcomes](#outcomes) gives it: it is evidence against the presented proof, not against the claim. A third party gets `false` with a non-canonical output word, or with any bytes the verifier rejects quickly. A consumer of the interface that accepts proofs from parties other than the claimant MUST NOT act against the claimant on `false`, and MAY only refuse that presentation. ## Rationale ### Identifier: content, not address or owner The identifier commits to everything that decides what the check does: the code that runs (`adapterCodeHash`, `targetCodeHash`), the key it claims to embed or passes to the verifier (`vkHash`), how the statement is laid out (`lanes`, `outputSize`, `emptyLane`, `proofSystem`) and the least gas a check may be given (`minVerifyGas`). Two parties that agree on an identifier agree on the computation, with nobody able to change it later. Addresses are left out on purpose: they only say which copy of the code to call, and for code without state every copy is equivalent. ### Entries hold no addresses An earlier version of this draft stored the addresses of one adapter and one target in the entry, and the first registration fixed them for good. That let anyone kill an identifier. [EIP-6780](./eip-6780.md) still removes an account that runs `SELFDESTRUCT` in the transaction that created it. An attacker could therefore create a copy of the code, register it and destroy it, all in one transaction. The identifier then existed, but the copy its entry pointed at did not. Every check read `Unverifiable`, and `AlreadyRegistered` kept everyone else from registering the same content at a live copy. Banning `SELFDESTRUCT` and `DELEGATECALL` from registered code would not have helped, because the copied code does not need them. The init code that creates the copy can `DELEGATECALL` a helper that runs `SELFDESTRUCT`, and then return the honest runtime code unchanged. The new account is already marked for removal, but it keeps the right code, and the right code hash, until the transaction ends. Registration accepts it. This works against any adapter and any target, including the ones this ERC uses as its reference. Nor was such an identifier simply dead. If the attacker had created the copy with `CREATE2`, the same init code could create it again at the same address, for one transaction at a time. The check then read `Valid` inside the attacker's own transactions and `Unverifiable` in everybody else's, so the attacker decided which payments settled. Letting `register` replace a dead address would not have closed the hole, because the replacement can be raced and destroyed in the same way. So the entry holds code hashes only, and whoever runs a check names the copies. A destroyed copy then costs nothing: any live copy of the same code serves, and anyone who has the code can deploy one. The addresses in `VerifierRegistered` are hints for finding one. The price is that the rule against reading state matters more. With fixed addresses, only the first registrant could choose the storage of a target that broke the rule. Now every presenter can, and with it forge a `Valid`. A target that breaks the rule was never safe to register. ### No owner, no pause Deployed verifier routers in practice have an owner who maps ids to verifiers, and an emergency stop for when a proof system turns out to be unsound. A stop protects every user at once, but it means an owner can change or halt what an id does. In a payment that is a party outside the agreement who can decide whether it settles. This ERC takes the other side: an identifier never changes meaning. If a proof system is found unsound, its identifiers are abandoned. Consumers stop offering them, clients refuse terms that name them, and new entries get new identifiers. Every payment already agreed still settles only against the code both sides chose. A consumer that wants a stop can build one into its own contract, for example a list of identifiers it accepts. That puts the trust in that consumer, where its users can see it, rather than in the registry every consumer shares. ### Gas: a floor in the identifier, an amount from the presenter An earlier version of this draft put the exact gas in the identifier. That strands payments. If a hard fork raises the cost of a verifier by more than the headroom, every valid proof under that identifier is `Unverifiable` for good, and a payment or a job that names it can only expire. Letting the caller choose the gas seems to have the opposite problem: whoever submits the transaction could make a valid proof fail by under-funding it. Two rules prevent that. Step 4 hands the adapter the whole amount or reverts the transaction, which nobody can mistake for a verdict. Step 6 looks for exhaustion relative to the amount supplied, so an amount that is too small gives `Unverifiable` and not `Invalid`, within the depth assumption. After a repricing, whoever presents the proof supplies more, and the identifier stays as it is. The identifier keeps a floor. It is an amount that was enough when the entry was sized, so parties that agree on an identifier also agree on what a check is expected to cost. It also keeps a presenter from starving the check far below that cost, which limits the harm if a verifier breaks the depth assumption. ### Three outcomes `Invalid` and `Unverifiable` lead to different next steps. `Invalid`: this proof will never pass, so present another. `Unverifiable`: nothing was decided, so the same proof may pass later, and no rejection, refund or reputation entry may follow. A boolean has room for only one of them, and every boolean design in [Relation to other proposals](#relation-to-other-proposals) resolves that by reporting "could not check" as `false`. ### Zero is `Unverifiable` An earlier version of the reference implementation numbered the outcomes `Invalid = 0, Valid = 1, Unverifiable = 2`, so that "an unset status never reads as acceptance". Both numberings keep `Valid` non-zero, so both meet that goal equally. The numbering decides something else: whether a value that nobody set reads as a rejection or as no decision. Zero appears without anyone deciding in many ways: - an unset storage slot (the two-step record before any check); - a low-level call that reads a pre-zeroed word after calling an account without code (success, empty return data); - a function that falls through without assigning its return value; - a proxy whose implementation is not initialised; - a default struct field. With zero = `Invalid`, every such slip produces a false rejection. With zero = `Unverifiable`, it produces "try again", which by the consumer rules is the same as no proof having been presented. This ERC therefore makes the safe default the outcome that commits to nothing. `Valid = 1` also matches the adapter's success word. The reference's two-step record already stored `0 = none, 1 = Valid, 2 = Invalid`, which is this numbering. The change brought the check's return value in line with its own record. Two drafts in flight take the other side: the open proposal *ZK Proof Verification for Smart Accounts* makes `0x00000000` mean "invalid proof", and [ERC-8354](./eip-8354.md) places `COULD_NOT_EVALUATE` under a `DENY` decision. That is the reason this ERC states its choice normatively. ### A verifier that exhausted its gas is `Unverifiable` A `false` that comes from running out of gas is not a rejection of the proof. It depends on the gas schedule, which hard forks change. With the reference implementation's EZKL verifiers, the Osaka repricing of `MODEXP` changed the cost of one EZKL verification by exactly 8,097 gas (577,544 against 569,447 under Cancun). EZKL's generated verifiers reject a proof by reverting with no data, which a caller cannot tell from running out of gas. Step 6 makes the distinction by the gas left unspent instead, under the depth assumption stated there. An honest presenter whose check ran out of gas presents the same proof again with more. An attacker gains nothing by crafting a proof that burns all the gas supplied: it costs them that gas, and an `Unverifiable` attempt changes no more than an `Invalid` one. ### The entry supplied by the caller The cheap path takes the entry from calldata and authenticates it with a single storage read (`entryHash`), instead of the five reads `entry` costs. An entry that does not hash to the registered one is `Unverifiable`, not `Invalid`: the caller named the wrong verifier, which says nothing about the proof. ### Relation to other proposals In short: - **[ERC-1922](./eip-1922.md) and [ERC-1923](./eip-1923.md)** (zk-SNARK Verifier and Verifier Registry, 2018, Stagnant): `verify` returns `bool`. The key id is derived from the key, but code is not pinned and there is no third outcome. - **[ERC-7992](./eip-7992.md)** (Verifiable ML Model Inference, Draft): the same statement shape (`modelId`, `inputCommitment`, `output`, `proof`). Its registry's `modelId` is opaque, its entries are updatable by an owner, and `verifyInference` reverts on every failure, so "could not verify" and "invalid" share the revert path. Its optional storage keys `keccak256(abi.encodePacked(modelId, inputCommitment, output))` and stores successes only. - **ERC-8274** (AI Inference Proof Verification, Draft): the same motivation for ERC-8183 and ERC-8004. Its `IProofVerifier.verify` returns `bool` and is not `view`. It has no registry by design: the trust handle is the verifier address, and the outer verifier may be replaced by emitting an event. Its `proofProfile()` may commit to the runtime code hash, but nothing checks it at use. The [interoperability rule](#interoperability-with-boolean-verifier-interfaces) above lets a contract built on this ERC serve as one of its backends without losing `Unverifiable`. - ***ZK Proof Verification for Smart Accounts*** (open pull request, not yet merged): a magic `bytes4` value on success and `0x00000000` on an invalid proof; no registry, no third outcome. - **[ERC-8084](./eip-8084.md)** (ZK proof metadata, Draft): metadata only (`circuitId` as a content hash, `proofSystem`); no verification interface. - **[ERC-8262](./eip-8262.md)** (Zero-Knowledge Compliance Oracle, Review): `bool` results; verifiers chosen per proof type, versioned by an administrator, with revocation. - **ERC-8354** (Confidential Agent Policy Verdicts, Draft): `bool` verification; a domain registry with a mutable verifier address and program key; "could not evaluate" is a kind of `DENY`. - **[ERC-8404](./eip-8404.md)** (Recomputable Verification Receipts, Draft): off-chain receipts with `VERIFIED / REFUTED / UNVERIFIABLE`, and the rule that absence must not silently become `false` or `REFUTED`. It agrees with this ERC's rule; it defines no on-chain registry or check. - **[EIP-8357](./eip-8357.md)** (EVM Verification Key Registry, Core, Draft): an append-only registry of STARK verification-key hashes written only by the system at forks. Its immutability matches this ERC's, but it is not an application-level registry of verifier code. None of these covers the combination this ERC needs: content-addressed immutable entries, code checked on every use, a gas rule that neither an under-funded transaction nor a repricing defeats, and a fail-safe third outcome. Extending ERC-7992 would mean removing its owner, `updateModel` and its revert-only failure mode, which would break its existing interface. This draft is therefore a separate ERC that names its relation to each. ## Backwards Compatibility No existing standard is replaced. The code in [Reference Implementation](#reference-implementation) follows this text. The reference implementation's own repository, which also holds the consumers and the tests on real proofs, differs in four places. None of them changes how an identifier is computed: 1. **Interface name.** The adapter interface is `IProofVerifier` in that repository and `IProofAdapter` here and in the assets, to avoid a clash with ERC-8274's `IProofVerifier`. The rename changes no bytecode; the parameter in item 4 does. 2. **Addresses and gas.** The repository's registry and check implement an earlier version of this draft, in which an entry stored the two addresses and the exact gas. The same content has the same identifier in both, with the exact gas in the place of the floor. The interfaces differ: `register`, `computeId`, `entry`, `recordCheck` and the arguments of a check, and also the value of `entryHash`, because the struct is another. A registry of the earlier version is open to the attack in [Entries hold no addresses](#entries-hold-no-addresses), and needs a new deployment to follow this text. 3. **Entries sized before step 6.** Entries are immutable, so the repository's two earliest entries stay registered. They name the earlier `Halo2EzklAdapter`, which answers `false` when its target runs out of gas instead of reverting as [Adapter](#adapter) recommends, and which does not probe for missing precompiles as [Adapter](#adapter) requires; they are safe to use only on chains that have all four. Their gas (600,000 and 660,000) leaves about 2.4% and 2.1% over the valid path as a first call, below the 10% that [Check](#check) recommends. Checked with exactly that gas, they fail safe: a valid proof is `Valid`, an early rejection `Invalid`, and a rejection at the final pairing `Unverifiable`. The reference repository tests this on real proofs. `test_a_late_rejection_with_tight_gas_is_unverifiable_and_with_more_invalid` in the assets shows the same effect on a mock verifier, and that supplying more gas turns the last case into `Invalid`. The [reference entries](#reference-entries) replace them. 4. **Adapters without `vkHash`.** `verify` gained its `vkHash` parameter after the repository's adapters and the earlier reference entries were written, so its selector changed. An adapter with the earlier signature, `Halo2EzklAdapter`, `Halo2EzklAdapterV2` or `Halo2EzklAdapterV3`, does not have the function that step 5 calls. A check that follows this text therefore reads every entry that names one as `Unverifiable`: such an entry stays a valid identifier and decides nothing. The [reference entries](#reference-entries) name `Halo2EzklAdapterV4`, which is `Halo2EzklAdapterV3` with the new signature. ## Test Cases The tests are in [the assets folder](../assets/eip-8535/), for Foundry. They run on mock verifiers that have the interface of EZKL's generated verifiers and fail the way those do: a rejection is a revert with no data, decided after most of the gas is spent. Tests on real EZKL proofs, and the probe and its measurements on the real verifiers, are in the reference implementation's repository, as are the tests of the consumer rules, which need each host protocol's contracts. Those tests cover the earlier version that [Backwards Compatibility](#backwards-compatibility) describes. - Registry, [`VerifierRegistry.t.sol`](../assets/eip-8535/test/VerifierRegistry.t.sol): `test_id_is_computed_from_content`, `test_every_field_changes_the_id`, `test_gas_floor_is_part_of_the_id`, `test_same_code_at_other_addresses_is_the_same_entry`, `test_delegated_account_reverts`, and one test for each malformed-entry revert. - Destroyed copies, [`DestroyedCopy.t.sol`](../assets/eip-8535/test/DestroyedCopy.t.sol): the attack of [Entries hold no addresses](#entries-hold-no-addresses) in five forms, on a target and on an adapter, with and without `SELFDESTRUCT` or `DELEGATECALL` in the copied code. For each: `test_the_event_points_at_a_destroyed_copy`, `test_a_live_copy_still_checks`, `test_a_copy_deployed_after_the_attack_checks`, `test_the_destroyed_copy_is_unverifiable`, `test_a_revived_copy_is_a_copy_like_any_other`. - Check, [`ProofCheck.t.sol`](../assets/eip-8535/test/ProofCheck.t.sol): `test_zero_value_of_the_status_is_unverifiable`, `test_valid_solo_proof_is_valid`, `test_wrong_output_is_invalid_and_does_not_revert`, `test_unknown_id_is_unverifiable`, `test_supplied_entry_that_is_not_the_registered_one_is_unverifiable`, the code-changed and code-removed cases, `test_any_copy_of_the_registered_code_gives_the_same_answer`, `test_addresses_without_the_registered_code_are_unverifiable`, `test_an_entry_without_a_target_takes_address_zero_only`, `test_a_target_that_reads_storage_can_be_forged_which_is_why_it_must_not_be_registered`, `test_arguments_that_do_not_fit_the_entry_are_invalid`, `test_misbehaving_adapters_never_give_valid` (a revert, running out of gas and a word other than 0 or 1 are each `Unverifiable`), `test_the_adapter_receives_the_entry_vk_hash`, `test_insufficient_gas_reverts_with_a_typed_error`, `test_no_gas_amount_turns_a_valid_proof_invalid`, `test_adapter_always_receives_the_supplied_gas_in_full`. - Supplied gas, [`SuppliedGas.t.sol`](../assets/eip-8535/test/SuppliedGas.t.sol): `test_gas_below_the_floor_reverts`, `test_gas_that_cannot_be_forwarded_reverts_up_to_the_largest_value`, `test_no_supplied_amount_turns_a_valid_proof_invalid`, `test_no_supplied_amount_and_gas_limit_turn_a_valid_proof_invalid`, `test_a_real_rejection_is_invalid_with_enough_gas`, `test_after_a_repricing_more_gas_makes_a_valid_proof_checkable` (a verifier that costs half as much again, with no registered code changed), `test_the_floor_protects_a_deeper_target_only_until_a_repricing`. - Two-step record, [`ProofCheckRecord.t.sol`](../assets/eip-8535/test/ProofCheckRecord.t.sol): `test_an_unrecorded_key_is_unverifiable_never_invalid`, `test_a_proof_can_be_presented_again_after_unverifiable`, `test_a_valid_record_for_another_commitment_has_another_key`, `test_a_record_never_changes`, `test_the_choice_of_copies_and_gas_cannot_spoil_a_record`, `test_an_entry_with_more_than_one_lane_is_invalid`. - Exhaustion and the 1/16 rule (step 6 and [Adapter](#adapter)), [`OutOfGasClassification.t.sol`](../assets/eip-8535/test/OutOfGasClassification.t.sol): `test_exhaustion_to_depth_4_is_unverifiable_behind_an_adapter_that_answers_false`, `test_exhaustion_to_depth_4_is_unverifiable_behind_adapter_v4`, `test_adapter_v4_reverts_on_exhaustion_to_depth_4`, `test_depth_5_reads_as_a_rejection_which_is_why_it_must_not_be_registered`, `test_check_boundary_is_one_sixteenth_of_the_supplied_gas`, `test_adapter_v4_boundary_is_one_sixteenth_of_its_gas`, `test_a_late_rejection_with_tight_gas_is_unverifiable_and_with_more_invalid`, `test_at_1_10_times_the_valid_path_every_rejection_is_invalid`, `test_a_valid_proof_short_of_gas_is_never_invalid`, `test_adapter_v4_reverts_when_the_verifier_runs_out_of_gas`, `test_first_call_surcharge_is_eip2929_and_entries_are_sized_over_it`. The exhaustion chains are the probe's below: `d = 1` to `4` with a loop and with `MODEXP` or `ECPAIRING` at the bottom read `Unverifiable` behind both adapters, and `d = 5` reads `Invalid`. - Missing precompiles ([Adapter](#adapter)), [`MissingPrecompile.t.sol`](../assets/eip-8535/test/MissingPrecompile.t.sol), with an account without code in place of each precompile the reference adapter probes: `test_with_every_precompile_present_the_answers_are_those_of_the_reference_adapter`, `test_a_missing_precompile_makes_every_check_unverifiable`, `test_the_adapter_reverts_with_the_missing_precompile`. - Reference identifiers, [`ReferenceIds.t.sol`](../assets/eip-8535/test/ReferenceIds.t.sol): `test_reference_ids`, the two identifiers below. ### Reference entries The reference registers two entries sized to step 6, with `Halo2EzklAdapterV4` and two EZKL-generated verifiers. Their identifiers are test vectors for `computeId`, checked by [`test/ReferenceIds.t.sol`](../assets/eip-8535/test/ReferenceIds.t.sol). An identifier depends on content only, so any registry that registers the same code with the same fields gets the same identifier. | Entry | `proofSystem` | `lanes` | `outputSize` | `minVerifyGas` | `emptyLane` | `verifierId` | |---|---|---:|---:|---:|---|---| | solo | `keccak256("halo2-kzg-bn254/ezkl")` | 1 | 320 | 645,000 | `0` | `0x40936d83e9f1a91879f4a738b1c0aceb68560c1a530bb28c2e2e17acedc00384` | | K=8 | `keccak256("halo2-kzg-bn254/ezkl")` | 8 | 320 | 712,000 | `0` | `0xcbd9f7020d1ba5defffb6c80530dd5e7d2e17d72f12c69259ced773d9926683a` | `adapterCodeHash` is that of `Halo2EzklAdapterV4` compiled with the settings in the assets' `foundry.toml`, which are therefore part of the vector. `targetCodeHash` and `vkHash` are those of the two verifiers and their verifying keys, given in that test as constants; the verifiers themselves are in the reference implementation's repository. Each floor is at least 1.10 times the valid path measured as a first call (solo 586,210, so 644,831, rounded up to 645,000; K=8 646,955, so 711,651, rounded up to 712,000). A wrong output, rejected at the final pairing, then leaves 63,769 (9.9%) and 70,024 (9.8%) unspent in a check at the floor, and reads `Invalid`. The floors are those of the previous reference adapters: `Halo2EzklAdapterV3`, whose identifiers were `0xb169f3c0f20d9e73de01a8d8a780842720bd33a6149682053a1a6756f309d6cc` and `0x430ad89f504217d4c76b6862ab5f2db6bf41d48b6c8c86b4163a270c00f1eed8`, and `Halo2EzklAdapterV2`, whose identifiers were `0x660e857f27694c13851bfd3b8558b8a8e7e76d5fc48b3b31f60f8fa3f086c1e1` and `0x81e1e6281df75ff6da92568a8f6448aa11150fed22cbf5396465a764cc83c286`. The probes for the four precompiles add 524 gas to each check, and the `vkHash` argument 19 more to the adapter's call (about 45 to the whole check). ### Probe A probe in the reference implementation measured `used` for synthetic targets that exhaust their gas at a known depth, behind the earlier EZKL adapter, called with `STATICCALL` and 600,000 gas, on the Osaka schedule. Its chains are the exhaustion tests above, which the assets run behind mock verifiers. "Unspent" is the gas supplied minus `used`. The bound is `1 - (63/64)^d`. | Chain below the check | `d` | Unspent | Bound | 1/32 rule | Step 6 (1/16) | |---|---:|---:|---:|---|---| | adapter → target (loops) | 1 | 6,654 (1.11%) | 1.56% | `Unverifiable` | `Unverifiable` | | adapter → target → loop | 2 | 18,316 (3.05%) | 3.10% | `Unverifiable` | `Unverifiable` | | adapter → target → `MODEXP` (gas too low) | 2 | 18,240 (3.04%) | 3.10% | `Unverifiable` | `Unverifiable` | | adapter → target → `ECPAIRING` (point off the curve) | 2 | 18,325 (3.05%) | 3.10% | `Unverifiable` | `Unverifiable` | | adapter → target → helper → `MODEXP` | 3 | 27,243 (4.54%) | 4.61% | **`Invalid`** | `Unverifiable` | | adapter → target → helper → helper → `MODEXP` | 4 | 36,090 (6.02%) | 6.10% | **`Invalid`** | `Unverifiable` | | adapter → target → three helpers → `MODEXP` | 5 | 44,782 (7.46%) | 7.57% | **`Invalid`** | **`Invalid`**, outside the depth assumption | What the probe shows: - **The bound holds.** Every measured depth stays below its bound. The shortfall at `d = 1` is the gas the adapter spends before and after its call. - **The earlier 1/32 rule was not enough.** It would have reported `d = 3` and `d = 4` exhaustion as `Invalid`. - **A precompile's bad input looks like running out of gas.** A precompile that rejects its input consumes all the gas forwarded to it, the same as running out (row `ECPAIRING`). A malformed proof that reaches a precompile therefore reads `Unverifiable`, which is the fail-safe side. A second probe measures the depth an entry actually has, instead of a synthetic chain. It runs the entry's valid proof at every budget from half its cost up to its cost, in steps of 250 gas, calls the adapter as step 5 does, and reports the largest share of the budget left unspent. Below its cost a valid proof never completes, so every one of these calls ends in exhaustion somewhere in the call chain, wherever the budget happens to run out. For the two reference entries, behind `Halo2EzklAdapterV4`, on the Osaka schedule: | Entry | Budgets | Largest unspent | Where | Bound at `d = 2` | |---|---:|---:|---|---:| | solo | 1,163 | 1.78% | 112 gas below the cost | 3.10% | | K=8 | 1,284 | 1.75% | 235 gas below the cost | 3.10% | The largest share comes just below the cost, where the verifier runs out inside its final pairing. Both stay well below the 6.25% of step 6. An entry whose largest share reaches 6.25% is outside the depth assumption. ## Reference Implementation In [the assets folder](../assets/eip-8535/). Unaudited. Solidity 0.8.24 or later; the tests use Foundry. | Part | Code | |---|---| | Registry | [`src/VerifierRegistry.sol`](../assets/eip-8535/src/VerifierRegistry.sol), interface [`src/IVerifierRegistry.sol`](../assets/eip-8535/src/IVerifierRegistry.sol) | | Adapter interface | [`src/IProofAdapter.sol`](../assets/eip-8535/src/IProofAdapter.sol) | | EZKL / Halo2 adapter | [`src/Halo2EzklAdapterV4.sol`](../assets/eip-8535/src/Halo2EzklAdapterV4.sol) | | Check | [`src/ProofCheck.sol`](../assets/eip-8535/src/ProofCheck.sol): steps 1 to 6 | | Two-step record | [`src/ProofCheckRecord.sol`](../assets/eip-8535/src/ProofCheckRecord.sol), interface [`src/IProofCheckRecord.sol`](../assets/eip-8535/src/IProofCheckRecord.sol) | The four consumers of [Consumers](#consumers) also have reference implementations, each built against its host protocol's contracts, and so does the earlier adapter that [Backwards Compatibility](#backwards-compatibility) describes. They are in the reference implementation's repository, not in the assets. ## Security Considerations - **Content pins code, not behaviour that depends on state.** An identifier for code that reads storage, balances, block data or other contracts is not safe to rely on. The presenter chooses the copies, so anyone can deploy a copy of a target that reads storage, fill that storage so that it accepts a false statement, and get `Valid`. The registry cannot detect such code, which [Adapter](#adapter) rules out. Reviewers of an entry should check that the adapter and the target read no state and contain no `SELFDESTRUCT`, `DELEGATECALL` or `CALLCODE`. - **The verifying key is enforced only where the adapter passes it on.** An adapter whose verifier serves many keys, such as SP1's, passes `vkHash` to the verifier as the key, and the identifier binds it. For a verifier that embeds its key, such as EZKL's, `vkHash` is a claim by the registrant. Whether the target embeds that key is established off chain, by regenerating the verifier from the key, compiling it with the named compiler and comparing runtime bytecode without the metadata trailer. - **A proof shows what the circuit computes, nothing more.** It shows that the circuit maps the committed input to the output. It does not show that a model is any good, and a circuit is a fixed-point quantisation of the model it stands for. - **Gas.** Without step 4, a submitter could under-fund a valid proof into failure. Step 4 relies on the 63/64 rule of [EIP-150](./eip-150.md). The floor is sized for the chain the entry is used on: L2 gas schedules and precompile prices differ, and a hard fork can reprice operations (see [Rationale](#a-verifier-that-exhausted-its-gas-is-unverifiable)). Presenters then supply more gas, up to what the chain allows one transaction. A floor that a repricing has left too low decides nothing wrongly, and one that is now higher than needed only raises the gas limit. - **The exhaustion rule assumes a shallow call chain.** Step 6 classifies exhaustion correctly only for `d <= 4` all-gas nested calls below the check. A deeper adapter or target can make exhaustion read `Invalid`, which is why [Check](#check) rules out registering one. The gas floor protects such an entry only until a repricing. Reviewers of an entry should check the depth, as they check that the code reads no state. - **Precompiles differ by chain; identifiers do not.** Anyone can register an entry on a chain that lacks a precompile its verifier calls, and get the same identifier as everywhere else. A call to a missing precompile succeeds with no return data, and a verifier that does not check for it can then answer wrongly either way. [Adapter](#adapter) therefore requires the adapter to revert when a precompile it depends on is missing; the reference adapter probes all four that its verifiers call. Likewise, a verifier that gives a precompile a fixed amount of gas turns a repricing into a clean rejection, and supplying more gas does not change that; [Adapter](#adapter) requires all-gas calls (EZKL's generated verifiers make them). Registrants should still test each entry on every chain where it is used. - **A copy can die, and its identifier does not.** An entry does not depend on the copies that were shown to `register`, or on any other. If one is destroyed, presenters use another, and the addresses in `VerifierRegistered` should be checked for code before use. An identifier is a hash, so it cannot bring back code that nobody kept: parties that rely on an identifier should keep the runtime code of its adapter and target, with which anyone can deploy a new copy. - **`Unverifiable` is not a soft `Invalid`.** A consumer that times out repeated `Unverifiable` answers into a rejection would reintroduce the failure this ERC removes; [Outcomes](#outcomes) forbids it. Host protocols' deadlines and exits, such as `reclaim` and `claimRefund`, are where funds return. They are not verdicts on the proof. - **Presenters are untrusted.** Proofs are public once broadcast, and anyone may present one. That is why [Outcomes](#outcomes) requires the destination of funds not to depend on who presents the proof. Presenters also choose the copies and the gas. The code hashes decide which copies count, and steps 4 and 6 decide what the gas can mean, so a bad choice reverts or reads `Unverifiable`, and leaves the way open for the next presenter. - **An ERC-8004 request hash can be opened first for another agent.** The Validation Registry keys a request by `requestHash` alone and stores the agent named by whoever opens it first. [ERC-8004: validator](#erc-8004-validator) therefore has a validator accept only request hashes that commit to `agentId`, the chain and the validator, and read `getValidationStatus(requestHash)` and refuse to respond if the stored `agentId` is not that agent. - **Input commitments must be fresh.** A proof is reusable for every payment or request with the same `(verifierId, inputCommitment)`. [Statement](#statement) therefore asks for fresh randomness in the input commitment, drawn after the verifier is named; the two-step record relies on that freshness to keep one record to one payment. - **Records.** A third party can record only the true outcome of the exact bytes it submits, so it cannot pin `Invalid` on someone else's proof: other bytes give another key, and no choice of copies or gas makes a valid proof `Invalid`. Recording `Invalid` costs the recorder gas and blocks nothing. ## Copyright Copyright and related rights waived via [CC0](../LICENSE.md).