---
eip: 8274
title: AI Inference Proof Verification
description: Separates on-chain AI inference proof verification into an application layer (IAgentVerifier) and an algorithm layer (IProofVerifier)
author: JimmyShi22 (@JimmyShi22) <jimmyshixiang22@gmail.com>, Damonzwicker (@damonzwicker), TMerlini (@TMerlini), babyblueviper1 (@babyblueviper1)
discussions-to: https://ethereum-magicians.org/t/erc-8274-ai-inference-proof-verification/28083
status: Draft
type: Standards Track
category: ERC
created: 2026-05-26
requires: 165
---

## Abstract

On-chain artificial intelligence (AI) inference can be verified through multiple proof paradigms — zero-knowledge machine learning (zkML), optimistic machine learning (opML), trusted execution environment (TEE), oracle, multisig, and others — but no common interface exists between them. Every protocol that needs verified AI inference today must write a separate adapter per proof system, resulting in N×M integration complexity and vendor lock-in.

This ERC defines two verification layers and a declaration interface:

- **`IProofVerifier`** — the inner algorithm layer, implemented by proof system providers (zero-knowledge (ZK) teams, TEE vendors, oracle networks). Stateless. Answers: "is this proof cryptographically valid for this input and output?"
- **`IAgentVerifier`** — the outer application layer, implemented by application developers. Stateful. Wraps an `IProofVerifier`. Answers: "for this task, was this agent authorized to make this claim, and does the proof confirm it?"
- **`IAgentVerifiable`** — implemented by settlement contracts to declare which `IAgentVerifier` they use.

It also defines an optional `IAgentProofProfile` query extension for deployments whose active verifier configuration can be identified before a call.

The separation allows proof system providers and application developers to work independently: neither needs to know the other's internals.

## Motivation

Verification infrastructure already exists, but it is highly fragmented.

**Verification paradigms already live:**

| Paradigm    | Description                                                                              |
| ----------- | ---------------------------------------------------------------------------------------- |
| zkML        | Cryptographic proof that a specific model produced a given output from a given input     |
| opML        | Optimistic AI inference execution with a challenge window for fraud proofs               |
| TEE         | AI inference run inside a hardware-isolated enclave with a verifiable attestation report |
| Attestation | Off-chain inference result certified by one or more authorized signers — covers oracle gateways (e.g. Chainlink), multisig / actively validated service (AVS) validator networks (e.g. EigenLayer), and judgment validators |

**ERCs that need inference verification:**

- **[ERC-8183](./eip-8183.md)** (Agentic Commerce Protocol, ACP) — defines escrowed jobs where evaluators may need to verify submitted AI inference results
- **[ERC-8004](./eip-8004.md)** (Trustless Agents) — provides agent identity, reputation, and validation registries, but validators still need a way to check inference proofs
- **[ERC-8001](./eip-8001.md)** (Agent Coordination) — routes multi-agent task results through opaque `executionData` bytes with no inference verification module
- **[ERC-7007](./eip-7007.md)** (Verifiable AI-Generated Content Token) — accepts opaque `bytes proof` with no model identifier or proof-system identifier

The problem: these two sides cannot talk to each other. Every protocol that needs verified AI inference today must write a separate adapter per proof system — resulting in vendor lock-in and N×M integration complexity. What's missing is a standard verifier interface that sits in the middle. This ERC provides exactly that:

```
Verification Backends   This ERC                ERCs

                   ╔══════════════════╗
   zkML        ─┐  ║  AI Inference    ║  ┌─ ERC-8183 (Agentic Commerce)
   opML        ─┤  ║  Proof           ║  ├─ ERC-8004 (Trustless Agents)
   TEE         ─┼─►║  Verification    ║◄─┼─ ERC-8001 (Agent Coordination)
   Attestation ─┘  ║  Interfaces      ║  └─ ERC-7007 (AI-Generated Content Token)
                   ╚══════════════════╝
```

Application developers need to know what a verification result establishes and whether the trust assumptions behind it are acceptable for their application. They can make that decision without implementing the underlying checks. Verification providers, in turn, evaluate the evidence for a claimed input and output and return a result without needing to know how the application will use it.

A common interface gives both parties an agreed way to request verification and report the result. Applications and verification services can then be developed independently and integrated without a custom adapter for each pairing.

## 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.

---

### IProofVerifier — Inner Algorithm Layer

`IProofVerifier` is the inner algorithm layer. Three defining properties:

- **Stateless** — holds no configuration about which agent, model, or session is being verified; all context is passed through parameters on every call
- **Verification algorithm specific** — encapsulates the cryptographic verification logic of one proof system (ZK, TEE, optimistic, or attestation)
- **Implemented by proof system providers** — the parties who implement cryptographic verification for a specific proof system (e.g. ZK teams, TEE vendors, oracle networks, attestation gateway operators); called by agent developers from within `IAgentVerifier`, with no knowledge of the agent context above

```solidity
pragma solidity ^0.8.0;

/// @title IProofVerifier
/// @notice Stateless cryptographic verification interface for AI inference proof backends.
/// Implemented by proof system providers independently of any calling context.
/// Answers: "is this proof cryptographically valid for this input and output?"
interface IProofVerifier {
    /// @notice Verify an AI inference proof.
    /// @param inputHash  Commitment to the model input (hash scheme is backend-specific).
    /// @param outputHash Commitment to the model output (hash scheme is backend-specific).
    /// @param metadata   Invariant deployment configuration — fields stable across calls
    ///                   for this verifier deployment (e.g. ZK circuit key, TEE enclave hash,
    ///                   signer registry address). Stored by IAgentVerifier; callers never
    ///                   encode or see this field.
    /// @param proof      Per-inference cryptographic evidence (e.g. ZK proof bytes,
    ///                   EIP-712 signature, TEE attestation report).
    /// @return True if the proof is cryptographically valid for the given input and output.
    function verify(
        bytes32 inputHash,
        bytes32 outputHash,
        bytes calldata metadata,
        bytes calldata proof
    ) external returns (bool);

    /// @notice Proof system identifier in "{paradigm}/{variant}" format.
    function proofSystem() external view returns (string memory);

    /// @notice Collision-resistant description of this verifier's verification
    /// type and configuration version. Meaning is scoped to this verifier address.
    /// SHOULD equal keccak256(abi.encode(proofSystem(), deploymentSalt)) where
    /// deploymentSalt is a backend-specific constant (e.g. verifier runtime bytecode
    /// hash, circuit commitment hash, enclave measurement).
    function proofProfile() external view returns (bytes32);
}
```

#### `verify()`

`verify()` takes four parameters with distinct roles:

- **`inputHash`** — commitment to the model input. The hash scheme is backend-specific and MUST be documented by each implementation.
- **`outputHash`** — commitment to the model output. The hash scheme is backend-specific and MUST be documented by each implementation.
- **`metadata`** — invariant configuration that does not change between calls for a given deployment: ZK circuit verification key, TEE enclave hash, signer registry address, etc. This is deployment-time configuration owned by `IAgentVerifier`; the settlement contract never encodes or sees it.
- **`proof`** — per-inference cryptographic evidence specific to this inference event: ZK proof bytes, [EIP-712](./eip-712.md) signature, TEE attestation report, or multisig aggregate.

`inputHash` and `outputHash` are interpreted within the concrete verifier configuration that processes the call. Consumers MUST NOT assume commitments produced under different verifier configurations are comparable unless those configurations explicitly declare the same canonical encoding and hash scheme. Matching `proofProfile()` values from different verifier addresses is not, by itself, such a declaration.

When verification completes, `IProofVerifier.verify()` returns `true` for a valid proof and `false` for an invalid proof. If verification cannot be completed, for example because the proof or metadata cannot be decoded, the call reverts.

#### `proofSystem()`

Identifies what kind of proof system this verifier implements. Returns a `{paradigm}/{variant}` string:

- **`paradigm`** — the verification paradigm, determining the trust model and security assumptions (see table below)
- **`variant`** — the specific implementation within that paradigm

It is RECOMMENDED that each component use only lowercase letters from the American Standard Code for Information Interchange (ASCII), digits, and hyphens (for example, `zk/sp1`). The table gives examples; implementations may define additional paradigms and variants. Names describe backend types and need not be unique. This ERC defines no naming registry.

| Paradigm      | Trust model                                                                                                                                     | Security assumptions                                                                                             | `proofSystem()` examples                                             |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| `zk`          | Mathematical: ZK circuit proves a specific model produced a given output from a given input                                                     | Soundness of the ZK proving system and correctness of the circuit                                                | `zk/sp1`, `zk/ezkl`                                                  |
| `op`          | Economic: execution is assumed correct within a challenge window; fraud proofs slash the submitter                                              | At least one honest challenger is watching within the challenge window                                           | `op/ora`                                                             |
| `tee`         | Hardware: a trusted enclave attests that execution occurred in an isolated environment                                                          | Trustworthiness of the hardware manufacturer; no side-channel or supply-chain compromise                         | `tee/nitro`, `tee/marlin`                                            |
| `attestation` | Authoritative: one or more authorized signers certify the result — covers oracle gateways, multisig validator networks, and judgment validators | Authorized signer set is not compromised; accountability is reputational or stake-based depending on the variant | `attestation/multisig`, `attestation/wyriwe`, `attestation/judgment` |

#### `proofProfile()`

Returns a collision-resistant `bytes32` description of the verification type and configuration version reported by the verifier. For example, it can distinguish circuit versions within `zk/sp1` or enclave measurements within `tee/nitro`.

`proofProfile()` is self-reported and MUST be interpreted in the scope of the concrete `IProofVerifier` address. Two addresses returning the same value MAY implement different verification behavior. A consumer MUST NOT trust an unknown verifier address solely because it reports a recognized `proofProfile()`. The trust and review target is the verifier address, its deployed code, and any upgrade authority; the profile describes the verification type/version used by that address.

A conformant implementation MUST change `proofProfile()` whenever verification semantics or any behavior-affecting configuration not supplied through `metadata` changes. For a proxy or otherwise upgradeable verifier, consumers MUST evaluate the active implementation and upgrade governance; the verifier address is a stable trust handle, not evidence that its code is immutable.

Using the verifier runtime bytecode hash as `deploymentSalt` is one reference derivation for an immutable on-chain verifier because consumers can independently recompute it. It is not the only conformant derivation: a ZK verifier MAY use a circuit verifying-key commitment, a TEE verifier MAY use an enclave measurement, and other backends MAY use an equivalent independently reviewable component appropriate to their trust model.

---

### IAgentVerifier — Outer Application Layer

`IAgentVerifier` is the outer application layer. Three defining properties:

- **Stateful** — stores deployment-time configuration: which `IProofVerifier`(s) to use, agent authorization rules, `metadata` to pass to the inner verifier, and optionally task tracking state
- **Application layer** — orchestrates agent-specific authorization and verification logic; shields settlement contracts from proof-system differences so callers invoke the same `verify()` interface regardless of whether the backend is ZK, TEE, or attestation
- **Implemented by agent developers** — the parties who deploy verification services for their agents, configuring authorization rules and `IProofVerifier` backends; called by settlement protocols (e.g. ERC-8183) via `IAgentVerifiable`, with the cryptographic internals remaining the exclusive concern of proof system providers

```solidity
pragma solidity ^0.8.0;

import "./IProofVerifier.sol";

/// @title IAgentVerifier
/// @notice Stateful application-layer verification interface.
/// Implemented by application developers. Wraps one or more IProofVerifier(s).
/// Answers: "for this task, was this agent authorized to make this claim,
/// and does the proof confirm it?"
interface IAgentVerifier {
    /// @notice SHOULD be emitted whenever verify() returns normally, including when valid is false.
    /// Carries the raw preimage fields of verificationDigest, enabling any observer
    /// to independently recompute the digest and confirm inclusion per the Observation Commitment Protocol (OCP)
    /// (recompute → compare → confirm).
    event VerificationCompleted(
        bytes32 indexed taskId,
        bytes32 indexed agentId,
        bytes32 indexed verificationDigest,
        bool    valid,
        bytes32 inputHash,
        bytes32 outputHash,
        bytes32 agentProofProfile,
        uint256 timestamp,
        bytes   instanceId,          // identifier of this verifier deployment; see Verification Commitment
        bytes   chainId               // identifier of the chain; see Verification Commitment
    );

    /// @notice Verify an agent's inference claim for a specific task.
    /// @param taskId     Task identifier. Binds verification to a single task.
    ///                   Callers SHOULD encode uint256 IDs as bytes32
    ///                   (e.g. ERC-8183 jobId, settlement periodId).
    /// @param agentId    Identity of the agent that performed the inference.
    ///                   Checked against the implementation's stored authorization config.
    /// @param inputHash  Commitment to the model input.
    /// @param outputHash Commitment to the model output.
    /// @param proof      Cryptographic evidence, passed unchanged to the inner IProofVerifier(s).
    /// @return valid              Whether the agent is authorized and the proof is valid.
    /// @return verificationDigest Domain-bound semantic commitment to this verification event.
    ///                            Computed from taskId, agentId, inputHash, outputHash, valid,
    ///                            agentProofProfile, block.timestamp, instanceId, and chainId.
    ///                            Returned for both true and false results. MAY be used as an on-chain
    ///                            audit anchor (e.g. the reason argument to ERC-8183 complete or reject).
    /// @dev NOT view — implementations MAY write state (e.g. single-use taskId tracking).
    function verify(
        bytes32 taskId,
        bytes32 agentId,
        bytes32 inputHash,
        bytes32 outputHash,
        bytes calldata proof
    ) external returns (bool valid, bytes32 verificationDigest);

}
```

Implementations with a single active verifier configuration MAY expose the following optional extension for callers that need to query `agentProofProfile` before invoking `verify()`. It is separate from `IAgentVerifier` so the base interface and its [ERC-165](./eip-165.md) interface ID remain unchanged. Implementations whose selected verifier or metadata depends on call inputs SHOULD define a query that accepts the corresponding routing inputs instead.

```solidity
interface IAgentProofProfile {
    function agentProofProfile() external view returns (bytes32);
}
```

#### Stateful Design

`IAgentVerifier.verify()` returns `valid = false` when a check rejects the claim, including when the agent is unauthorized or a task is rejected under the application's replay policy. If an exception prevents a verdict, the call reverts. Each `IAgentVerifier` implementation MUST document its policy for repeated verification attempts, including whether callers can retry after failure or repeat verification after success.

`IAgentVerifier` is stateful by design. Its state falls into two categories:

**Application state** — deployment-time application rules specific to the agent. What to store here is left to the implementation; typical examples include agent authorization configuration (allowlist, registry reference, on-chain role), task state for single-use enforcement, model or policy requirements, and accepted time windows.

**`IProofVerifier` reference(s) and `metadata`** — which proof backend(s) to call and the invariant `metadata` to pass each one. Typical examples include a single `IProofVerifier` address with its corresponding circuit key or enclave hash encoded as `metadata`, or a keyed mapping of verifiers for multi-paradigm deployments. Both are set at deployment and SHOULD be immutable; `metadata` encoding is specific to each `IProofVerifier` and opaque to callers above.

This ERC does not mandate the internal structure of `IAgentVerifier` implementations. Implementations MAY use a single `IProofVerifier`, an array, a mapping, or any other arrangement. The `verify()` signature above and the behavioral and commitment requirements below apply regardless of that arrangement.

For a verification attempt using a single inner verifier, `IAgentVerifier` MUST derive `agentProofProfile` from the concrete inner verifier configuration selected for that attempt:

```solidity
agentProofProfile = keccak256(abi.encode(
    verifierAddress,
    IProofVerifier(verifierAddress).proofProfile(),
    keccak256(metadata)
));
```

Here `metadata` is the exact invariant byte string configured for, and when invoked passed to, that verifier. This address-scoped composition prevents equal self-reported `proofProfile()` values at different addresses from being treated as equivalent verification behavior.

If multiple inner verifiers contribute to one attempt, the implementation MUST document and use a deterministic composition that commits to every participating `(verifierAddress, proofProfile, keccak256(metadata))` tuple and to the aggregation or routing policy version. It MUST NOT treat a shared self-reported profile as evidence that different addresses behave equivalently. The resulting `agentProofProfile` MUST be included in `VerificationCompleted` and `verificationDigest` as specified below.

If application checks reject an attempt before invoking an inner verifier, `agentProofProfile` MUST commit to the configuration selected or that would have been selected for that attempt. If no verifier configuration can be selected, the implementation MUST define and document a deterministic sentinel profile. The reference implementation below has one configured backend and therefore commits to that backend on both passing and failing attempts.

#### Verification Commitment

`verify()` returns `(bool valid, bytes32 verificationDigest)`. The `verificationDigest` is a domain-bound semantic commitment to the full verification event — it identifies *what* was verified, *where* (which chain and which deployment), and *when* — but does not guarantee uniqueness across distinct calls with identical parameters within the same block. Exact occurrence identity is supplied by the event's inclusion proof (the transaction and log index), not by the digest.

The preimage is:

```
keccak256(abi.encode(
    taskId, agentId, inputHash, outputHash,
    valid, agentProofProfile, block.timestamp,
    instanceId, chainId
))
```

- **`instanceId: bytes`** — canonical identifier of the deployment instance that emitted this verification, encoded per-chain. On Ethereum: `abi.encodePacked(address(this))`. On Solana: the program address in its canonical encoding. `instanceId` has exactly one job — *which* deployment — and does not encode proof-backend type or scheme; that information is already fully carried by `proofSystem()` (the paradigm, e.g. `"tee/nitro"`, `"zk/sp1"`) and `agentProofProfile` (the exact-config discriminator within that paradigm — circuit version, enclave measurement, committee pubkey — committed as a `bytes32` hash via `proofProfile()`). Overloading `instanceId` with a class/scheme tag would duplicate a distinction the interface already makes elsewhere; keeping it a plain per-chain address keeps each field's job singular — `proofSystem()` answers "what kind," `agentProofProfile` answers "which exact config," `instanceId` answers "which deployment."

- **`chainId: bytes`** — identifies the chain as the 8-bit Unicode Transformation Format (UTF-8) encoding of its Chain Agnostic Improvement Proposal 2 (CAIP-2) identifier (`namespace:reference`, e.g. `eip155:1` for Ethereum mainnet). On Ethereum: `bytes(string.concat("eip155:", <decimal-ASCII of block.chainid>))` — see the reference implementation below for a dependency-free conversion. This is a digest-encoding change, not a documentation clarification: `chainId` moves from `abi.encode(block.chainid)` (32-byte, zero-padded `uint256`) to UTF-8 CAIP-2 bytes (variable-length ASCII) — the `bytes` application binary interface (ABI) *type* stays the same, but every digest computed after adopting this encoding differs from one computed under the prior wording.

Including `valid`, the address-scoped `agentProofProfile`, `block.timestamp`, `instanceId`, and `chainId` ensures that the same inputs verified by different inner verifier configurations, on different chains, by different outer deployments, at different times, or with different outcomes, produce different digests. `block.timestamp` makes the digest self-contained — the verification time is encoded directly rather than requiring block lookup. `instanceId` and `chainId` prevent cross-deployment and cross-chain collisions when the digest is used as a detached audit anchor.

`VerificationCompleted` SHOULD be emitted on every normally returning call, including when `valid` is `false`, carrying the same fields as the preimage. A reverted call leaves no event log. This follows the commitment model of the Observation Commitment Protocol (OCP): any external observer can independently verify a `VerificationCompleted` record by applying the recompute → compare → confirm inclusion procedure, without calling any contract and trusting any intermediary.

`verificationDigest` MAY be stored as an on-chain audit anchor by the settlement contract (e.g. as the `reason` argument to ERC-8183's `complete` or `reject` function).

---

### IAgentVerifiable — Declaration Interface

Settlement contracts MUST implement `IAgentVerifiable` to declare which `IAgentVerifier` they use and MUST emit an `AgentVerifierUpdated(bytes data)` event on any change.

The `data` field is a neutral envelope whose encoding is chosen by the deployment. Two recommended encodings are:

- **Simplest (address tracking):** `abi.encode(previousVerifier, newVerifier)` — sufficient for deployments that only need to record which verifier address was active before and after the switch.
- **Extended (versioned lineage):** a richer encoding that carries structured identifiers for the upgrade — for example, a namespace identifier and a transition identifier within that namespace, enabling consumers to reconstruct a full verifier upgrade history from an off-chain state chain.

Deployments MAY use other encodings. The event provides the `bytes` slot; the deployment defines the encoding, and consumers decode accordingly.

```solidity
pragma solidity ^0.8.0;

import "./IAgentVerifier.sol";

/// @title IAgentVerifiable
/// @notice Interface for settlement contracts that declare which agent verifier they use.
interface IAgentVerifiable {
    /// @notice Returns the agent verifier used by this contract.
    function getAgentVerifier() external view returns (IAgentVerifier);

    /// @notice MUST be emitted when the agent verifier changes.
    /// @param data Encoding of the verifier change, chosen by the deployment.
    ///        Recommended: abi.encode(previousVerifier, newVerifier).
    event AgentVerifierUpdated(bytes data);
}
```

---

### Interface Detection

It is RECOMMENDED that all implementations support [ERC-165](./eip-165.md):

```solidity
// IProofVerifier
function supportsInterface(bytes4 interfaceId) external view returns (bool) {
    return interfaceId == type(IProofVerifier).interfaceId
        || interfaceId == type(IERC165).interfaceId;
}

// IAgentVerifier
function supportsInterface(bytes4 interfaceId) external view returns (bool) {
    return interfaceId == type(IAgentVerifier).interfaceId
        || interfaceId == type(IERC165).interfaceId;
}
```

An implementation of the optional `IAgentProofProfile` extension MUST additionally return `true` for `type(IAgentProofProfile).interfaceId`.

---

## Rationale

### Primitive: OCP as the Unifying Model

OCP is a system-agnostic verification primitive: given the emitted event data, any observer can independently verify a commitment without trusting the system that produced it or relying on any contract. It defines the minimum procedure any proof system must satisfy:

```
recompute → compare → confirm inclusion
```

This ERC adopts OCP as the unifying model for `IAgentVerifier` events — not only because every proof backend satisfies the primitive, but because `VerificationCompleted` maps directly onto it: the event is the observation, `verificationDigest` is the commitment, and the emitted fields are the preimage.

`verificationDigest` is computed from `(taskId, agentId, inputHash, outputHash, valid, agentProofProfile, block.timestamp, instanceId, chainId)`. The event carries those same fields alongside the digest, making every record self-describing and independently auditable:

- **On-chain**: `IAgentVerifier` computes the digest from the verification parameters and includes it in `VerificationCompleted`
- **Off-chain**: apply all three steps — recompute from emitted fields, compare, confirm event inclusion

`confirm inclusion` requires reading event logs, which is off-chain only. `IProofVerifier.verify()` verifies the backend proof. An external observer uses the `VerificationCompleted` record to recompute and compare the digest and confirm inclusion. The same primitive thus covers both contexts without requiring contracts to fetch their own logs.

`agentProofProfile` in the digest commits to the selected inner verifier address, its self-reported profile, and the configured metadata, ensuring that the same inputs verified by different inner configurations produce different digests.

### Architecture: Two Composable, Opaque Layers

The split between `IAgentVerifier` (outer application layer) and `IProofVerifier` (inner algorithm layer) exists because two independent parties must implement the standard:

- **Proof system providers** implement `IProofVerifier`. They know their cryptographic details but not the calling application context. `IProofVerifier` is **stateless** — one deployed instance serves many `IAgentVerifier` deployments without redeployment; `metadata` carries all invariant configuration and is owned by `IAgentVerifier`.
- **Agent developers** implement `IAgentVerifier`. They know their application rules but should not be coupled to a specific proof system. `IAgentVerifier` is **stateful** — authorization rules, model requirements, and task tracking belong in state.

Settlement contracts can call `IAgentVerifier` to apply application rules without knowing the backend's `metadata` encoding. A contract that calls `IProofVerifier` directly needs to handle that encoding and any application-level checks itself. The two-layer boundary keeps each party isolated:

```
IAgentVerifier.verify(taskId, agentId, inputHash, outputHash, proof)
  → check taskId (if single-use)
  → check agentId authorization (if needed)
  → delegate to IProofVerifier(s) internally
  → compute verificationDigest
  → return (valid, verificationDigest)
```

**Opacity.** The two-layer design achieves opacity at every level:

- Settlement contracts are **opaque to the proof backend** — they call `IAgentVerifier.verify()` the same way regardless of whether the backend is ZK, TEE, or attestation.
- `IAgentVerifier` is **opaque to the settlement contract** — its internal verifier configuration, `metadata` encoding, and authorization rules are not exposed to callers.

### Query: Input Provenance (WYRIWE)

`inputHash` commits to whatever input was provided but says nothing about its origin. A verifier confirms "this model produced this output from this input" — not whether the input was legitimate.

What You Read Is What You Execute (WYRIWE) fills this gap with a three-commitment scheme:

```
rawInputHash             = keccak256(raw_user_input)
sanitizationPipelineHash = keccak256(utf8(sanitization_spec_uri) || rawInputHash)
inputHash                = keccak256(sanitized_input)
```

`IProofVerifier.verify()`'s `inputHash` maps directly to WYRIWE's `input_hash` — same field, same construction. `WyriweProofVerifier` implements `IProofVerifier` and can be used as a backend by an `IAgentVerifier`.

Consumers that need input provenance can use WYRIWE alongside `verify()`. This ERC does not prescribe how `inputHash` is derived.

### Result: Proof Anchoring

`verify()` confirms cryptographic validity but not *when* the proof was generated. A consumer can confirm "this proof checks out" but not "the proof was committed before any action was taken."

Proof anchoring is one optional way to show that a proof existed by a given block. In this example, an agent records a hash of the encoded proof (`proofHash`) in an on-chain registry. A consumer hashes the proof using the same encoding and hash function and compares the result with the value recorded in that block. A match provides evidence that the proof existed by then. The application chooses the registry, encoding, and hash function.

The anchor check is an application-layer concern — it belongs in `IAgentVerifier`, not `IProofVerifier`. Implementations can accept a Merkle inclusion proof inside `proof` to confirm `proofHash` exists in the anchor registry.

| | Purpose |
|--|-------|
| `proofHash` (verdict anchor) | "This verdict was committed at time T" — **verdict commitment** |
| `verificationDigest` | "This verification event occurred with these parameters" |
| OCP inputHash (input anchor) | "This task input was committed at time T" — **input commitment** |

The input anchor records when the task input was committed. The verdict anchor records when the verdict was committed and supplies the `committed_at` value in the [Judgment Validator example](#judgment-validator--attestationjudgment).

---

## Backwards Compatibility

No backwards compatibility issues. This ERC introduces new interfaces and does not modify any existing standard.

---

## Reference Implementation

### Coding in Practice

The following three examples form a complete composable stack. Each layer is independently deployable; Layer 2 wraps Layer 1 and Layer 3 wraps Layer 2.

#### Layer 1 — IProofVerifier: Proof System Backend

`SP1ProofVerifier` implements the ZK paradigm. `proofSystem()` is declared `public` so `proofProfile()` can call it internally. This immutable reference derives its profile from the deployed runtime bytecode hash; the outer `AgentVerifier` separately commits to the concrete address and `programVKey` metadata.

```solidity
pragma solidity ^0.8.0;

import "./IProofVerifier.sol";

/// @title SP1ProofVerifier
/// @notice IProofVerifier implementation for inference proofs from the SP1 zero-knowledge virtual machine.
///
/// metadata: abi.encode(bytes32 programVKey)
///   programVKey — SP1 verification key identifying the ZK circuit for this model
/// proof: SP1 proof bytes (Plonk or Groth16 format)
contract SP1ProofVerifier is IProofVerifier {

    function verify(
        bytes32 inputHash,
        bytes32 outputHash,
        bytes calldata metadata,
        bytes calldata proof
    ) external returns (bool) {
        bytes32 programVKey = abi.decode(metadata, (bytes32));
        // Verify the SP1 ZK proof: circuit identified by programVKey produced
        // outputHash from inputHash. Delegates to SP1 Plonk verifier contract.
        // Full implementation omitted; see SP1 documentation.
        // Replace the following revert with a call to the SP1 verifier that reverts on invalid proofs.
        revert("SP1 verification not implemented");
        return true;
    }

    function proofSystem() public pure returns (string memory) {
        return "zk/sp1";
    }

    function proofProfile() external view returns (bytes32) {
        return keccak256(abi.encode(proofSystem(), address(this).codehash));
    }
}
```

#### Layer 2 — IAgentVerifier: Wraps IProofVerifier

`AgentVerifier` is constructed with an `IProofVerifier` instance (e.g. `SP1ProofVerifier` from Layer 1), deployment `metadata`, and an authorized agent set. The inner verifier configuration is held in contract state — the settlement contract in Layer 3 never sees `metadata` or the verifier address. This example chooses an application policy in which a successful verification consumes `taskId`, while a failed verification may be retried; other replay policies remain conformant.

```solidity
pragma solidity ^0.8.0;

import "./IAgentVerifier.sol";
import "./IAgentProofProfile.sol";
import "./IProofVerifier.sol";
import "./IERC165.sol";

/// @title AgentVerifier
/// @notice IAgentVerifier implementation wrapping a single IProofVerifier backend.
///
/// metadata is stored at deployment and passed to the inner verifier on every call.
contract AgentVerifier is IAgentVerifier, IAgentProofProfile, IERC165 {

    IProofVerifier private immutable _verifier;
    bytes private _metadata;

    mapping(bytes32 => bool) private _authorizedAgents;
    mapping(bytes32 => bool) private _usedTasks;

    constructor(
        IProofVerifier verifier_,
        bytes memory metadata_,
        bytes32[] memory authorizedAgents_
    ) {
        _verifier = verifier_;
        _metadata = metadata_;
        for (uint256 i = 0; i < authorizedAgents_.length; i++) {
            _authorizedAgents[authorizedAgents_[i]] = true;
        }
    }

    function agentProofProfile() public view override returns (bytes32) {
        return keccak256(abi.encode(
            address(_verifier),
            _verifier.proofProfile(),
            keccak256(_metadata)
        ));
    }

    function supportsInterface(bytes4 interfaceId) external pure override returns (bool) {
        return interfaceId == type(IAgentVerifier).interfaceId
            || interfaceId == type(IAgentProofProfile).interfaceId
            || interfaceId == type(IERC165).interfaceId;
    }

    function verify(
        bytes32 taskId,
        bytes32 agentId,
        bytes32 inputHash,
        bytes32 outputHash,
        bytes calldata proof
    ) external override returns (bool valid, bytes32 verificationDigest) {
        if (!_usedTasks[taskId] && _authorizedAgents[agentId]) {
            valid = _verifier.verify(inputHash, outputHash, _metadata, proof);
            if (valid) _usedTasks[taskId] = true;
        }

        bytes32 profile = agentProofProfile();
        uint256 ts = block.timestamp;
        bytes memory instanceId = abi.encodePacked(address(this));
        // chainId: UTF-8 bytes of the CAIP-2 identifier, e.g. "eip155:1"
        bytes memory chainId = bytes(string.concat("eip155:", _toDecimalString(block.chainid)));
        verificationDigest = keccak256(abi.encode(
            taskId, agentId, inputHash, outputHash, valid, profile, ts,
            instanceId, chainId
        ));

        emit VerificationCompleted(
            taskId, agentId, verificationDigest, valid, inputHash, outputHash,
            profile, ts, instanceId, chainId
        );
    }

    /// @dev Minimal decimal-ASCII conversion, dependency-free by design (matches this
    ///      ERC's convention of relative-only imports in reference implementations).
    function _toDecimalString(uint256 value) private pure returns (string memory) {
        if (value == 0) return "0";
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) { digits++; temp /= 10; }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + (value % 10)));
            value /= 10;
        }
        return string(buffer);
    }
}
```

#### Layer 3 — Settlement Contract (ERC-8183): Wraps IAgentVerifier

`ProofEvaluator` implements `IAgentVerifiable`, declares its `IAgentVerifier` via `getAgentVerifier()`, and calls `verify()` at settlement time. The evaluator passes `verificationDigest` as the `reason` argument to ERC-8183's `complete` or `reject` function.

```solidity
pragma solidity ^0.8.0;

import "./IAgentVerifiable.sol";
import "./IAgentVerifier.sol";

interface IACP {
    function complete(uint256 jobId, bytes32 reason, bytes calldata data) external;
    function reject(uint256 jobId, bytes32 reason, bytes calldata data) external;
}

contract ProofEvaluator is IAgentVerifiable {
    IAgentVerifier private _agentVerifier;
    IACP private immutable _acp;

    constructor(IAgentVerifier agentVerifier_, IACP acp_) {
        _agentVerifier = agentVerifier_;
        _acp = acp_;
        emit AgentVerifierUpdated(abi.encode(address(0), address(agentVerifier_)));
    }

    function getAgentVerifier() external view returns (IAgentVerifier) {
        return _agentVerifier;
    }

    function settle(
        uint256 jobId,
        bytes32 agentId,
        bytes32 inputHash,
        bytes32 outputHash,
        bytes calldata proof
    ) external {
        bytes32 taskId = bytes32(jobId);
        (bool valid, bytes32 verificationDigest) =
            _agentVerifier.verify(taskId, agentId, inputHash, outputHash, proof);

        if (valid) _acp.complete(jobId, verificationDigest, "");
        else       _acp.reject(jobId, verificationDigest, "");
    }
}
```

### Composability in Practice

#### ERC-8183 — Agentic Commerce

ERC-8183 defines a job lifecycle where an evaluator calls `complete()` or `reject()` after assessing a submission. Four decisions apply directly:

**Evaluator `settle()` entry point.** The evaluator implements `IAgentVerifiable`; the verifier is resolved at settlement via `getAgentVerifier()` — no pre-registration required. The caller supplies only agent-level claims:

```solidity
settle(jobId, agentId, inputHash, outputHash, proof)
```

`metadata` and the verifier address are owned by `IAgentVerifier` internally.

**Settlement reason.** Passing `verificationDigest` as the `bytes32 reason` argument to `complete` or `reject` gives observers a domain-bound commitment they can independently verify. Exact occurrence identity is supplied by the event's inclusion proof, not by the digest.

**`verify()` returns `bool`.** No reconstruction needed:

```solidity
(bool valid, bytes32 verificationDigest) =
    getAgentVerifier().verify(bytes32(jobId), agentId, inputHash, outputHash, proof);

if (valid) ACP.complete(jobId, verificationDigest, "");
else       ACP.reject(jobId, verificationDigest, "");
```

**Input provenance.** This example uses WYRIWE and computes `inputHash` as `keccak256(sanitized_input)`. Other integrations use the encoding and hash function documented by their verifier.

#### WYRIWE — Input Provenance

WYRIWE makes `IProofVerifier`'s `inputHash` auditable. The base interface commits to a value — WYRIWE commits to *how that value was derived*, binding the signed inference receipt to the provenance chain that produced its input.

**Triple-hash chain** (normative in WYRIWE):

```
rawInputHash             = keccak256(raw_user_input)
sanitizationPipelineHash = keccak256(utf8(sanitization_spec_uri) || rawInputHash)
inputHash                = keccak256(sanitized_input)
```

`sanitizationPipelineHash` binds the public pipeline spec to *this specific raw input* (a pipeline commitment cannot be replayed against a different input), and `inputHash` commits to the exact bytes the model received. The verification invariant: given the three hashes and the public spec at `sanitization_spec_uri`, any verifier can recompute the pipeline over the raw input and confirm `inputHash` — no party is trusted to assert it. The sentinel case (no transformation) is a provable claim, not an assumption: `sanitizationPipelineHash = keccak256(utf8(IDENTITY_SENTINEL_CID) || rawInputHash)`.

**Two commitments, two auditor questions** (they are complementary, not contradictory): `sanitizationPipelineHash` proves *a specific pipeline was declared and bound to a specific raw input* — faithful application is the prover's commitment, not something the hash alone enforces. `inputHash` proves *what the model actually received*. A conformant implementation produces both; the verification invariant (recompute the pipeline over the raw input, confirm `inputHash`) is what ties declaration to delivery.

**Inner layer.** In this example, `proofSystem()` returns `"attestation/wyriwe"`, and `verify()` interprets its parameters as follows:

- `inputHash` identifies the exact input the model received.
- `outputHash` identifies the inference output covered by the receipt.
- `metadata` identifies the agent, the registry address used for signing, and the signer the verifier expects.
- `proof` carries the receipt details, including the model hash, input provenance hashes, commitment, and timestamp, together with the signature.

The verifier checks that the receipt binds the agent, model, input, output, and timestamp together and verifies the signature against the expected signer. If the application requires that signer to be authorized for the agent, the outer verifier checks that relationship.

**Judgment as provenance one layer up.** WYRIWE's judgment-composition section (Section 9) specifies how to link a proposal, a verdict on that proposal, and the recorded execution. The proposal corresponds to the raw input, the verdict records the validator's decision about the proposal, and the executed action corresponds to the sanitized input. The verdict commits to the hash of the proposal it judges. The Judgment Validator subsection below illustrates this with an `attestation/judgment` verifier.

**Confidence and aggregation.** WYRIWE attestations do not carry a verdict score — they carry a tamper-evident receipt of what ran. How confidence is derived from judgment records, and how verdicts from several validators are weighted, is application policy in `IAgentVerifier`; the Judgment Validator subsection below describes two such policies as examples.

#### Judgment Validator — `attestation/judgment`

This optional example illustrates what an `IProofVerifier` can establish for a **judgment claim**: a validator examined a proposed action and issued a verdict on it. Verification establishes that the named validator signed that verdict for that exact input. It does not establish that the verdict is correct or that the action is sound, and it does not require a scoring, weighting or aggregation policy.

In this example, `proofSystem()` returns `"attestation/judgment"`, and `verify()` interprets its parameters as follows:

- `inputHash` commits to the proposed action the validator examined.
- `outputHash` commits to the verdict artifact: the exact bytes of the verdict the validator issued. The implementation documents the artifact encoding and hash function so that anyone holding the artifact can recompute `outputHash`.
- `metadata` identifies the validator or validators the deployment accepts and the signature scheme used to verify them.
- `proof` contains the validator's signature and any other data needed by the documented scheme.

When used with WYRIWE Section 9, this verifier takes `rawProposalHash` as `inputHash` and `verdictHash` as `outputHash`.

The verifier checks a signature over a payload binding `inputHash`, `outputHash` and the validator identity. The implementation documents the exact payload encoding. Including a domain separator identifying the scheme and this example helps prevent a signature made for another purpose from being accepted as a verdict. To bind a verdict to a particular verifier, the signed verdict can also name the consuming instance. In WYRIWE, the verdict preimage includes `intended_verifier` when that instance is known, and a verifier rejects a verdict that names another instance.

The verifier returns `true` only when the signature is valid under the documented scheme, the signer is a validator identified in `metadata`, and the signed payload binds the exact `inputHash` and `outputHash` passed to `verify()`. A valid signature over different hashes returns `false`. The result does not depend on the verdict's content: a validly signed rejection verifies as `true`, just like a validly signed approval.

A `true` result establishes only the verdict's authenticity; it does not mean that the action is sound or that the verdict approves it. An `IAgentVerifier` that gates settlement on the verdict's content obtains the verdict artifact, checks that it recomputes to `outputHash`, and applies its own documented policy to the content. This example prescribes no verdict artifact format and no policy for weighting or aggregating verdicts from multiple validators.

**Inner-layer wiring.** A judgment verifier returns `"attestation/judgment"` from `proofSystem()` and checks the validator's signature over a payload binding the verdict commitment (`outputHash`), the proposed action (`inputHash`) and the validator identity. One production validator signs with schnorr over a Nostr event; the scheme is described by `proofProfile()` and committed to by the outer `agentProofProfile`. An example verdict artifact:

```json
{
  "verdict": "approve | approve_with_concerns | reject",
  "confidence": 0.85,
  "issues": ["<machine-readable concern>", "..."]
}
```

Verdicts in this example are trinary, not binary. A judgment claim carries no execution-environment measurement: unlike a `tee/*` claim, there is no enclave whose code could be measured.

**Commit-before-outcome timing.** A verdict is only useful as evidence if it was committed before the outcome it is judged against. Applications that rely on this can include two fields in the signed verdict artifact:

- `committed_at` — when the *verdict* was committed, taken from an anchor of the verdict itself (for example a proof-anchoring entry whose hash is the verdict's identifier). This is a different commitment from an observation anchor of the *input*, which records when the task was issued; the chain is input commitment → verdict commitment → settlement, and the two anchors should not be substituted for one another.
- `judgment_type` — what `committed_at` is compared with: for `outcome_verifiable` judgments (Type A), the settlement of the realized outcome; for `consensus_weighted` judgments (Type B), the reveal.

Checking these orderings is part of the consumer's policy, not of `verify()`.

**From non-deterministic judgment to a deterministic bool.** The interface output is deterministic even though judgment is not. Two example aggregation policies for `IAgentVerifier`:

- **Type A — outcome-verifiable.** Validator weights are derived as a pure function of settled commit-reveal records (verdicts committed on-chain before outcomes, revealed after), recomputable by any party from chain state, with no trusted updater. This is trustless only where outcomes settle on-chain; outcomes settled off-chain need an outcome oracle, and the aggregation inherits its trust assumptions, so such records should be distinguishable from on-chain-settled ones.
- **Type B — non-verifiable.** Usage-based weight should count distinct counterparties with their own at-stake identity, not call volume, and should be capped relative to outcome-derived weight, to guard against self-dealing.

The resulting bool gates settlement like any other backend (see the ERC-8183 wiring above): authenticity from the inner layer, policy over the verdict and the validators' derived weights at the outer layer.

**Accountability records.** Validators that publish a track record make it more useful as evidence when the record includes losses as well as wins, when outcomes settle somewhere the validator cannot edit, and when the pre-outcome timestamp is anchored at issue time to a system the validator does not control. Keeping commitment evidence and outcome evidence separately addressable lets a dispute check one without the other.

**Execution binding.** Under WYRIWE Section 9, the validator signs the verdict artifact. When execution is recorded, the executing agent's attestor signs the `JudgmentExecutionAttestation` linking the proposal and verdict hashes to the recorded action hash. Consumers apply their own ordering policy to the verdict and execution timestamps.

**Deployment experience.** A production judgment validator relay-anchors every verdict at issue time, publishes losses as well as wins, and has settled a judgment attestation on-chain through commit-reveal, with the verdict's commit time checkably earlier than its reveal. A cross-stack trace on the same validator binds a registry identity, through a signed pre-action verdict, to the executed action. These are offered as reference experience, not as a required format.

---

## Security Considerations

**IProofVerifier trust boundary**

This ERC defines the interface but does not vet `IProofVerifier` implementations. Interface conformance alone gives agent developers no assurance about backend security. Before configuring a backend, they can independently assess its cryptographic assumptions, audit status, and known attack surface. A backend that always returns `true`, uses a broken circuit, or accepts replayed attestations will silently undermine the entire verification chain.

**Trust chain**

```
settlement contract → IAgentVerifier → IProofVerifier[]
```

An independent audit of each link covers the implementations that settlement contracts and agent developers rely on. Interface conformance alone gives no assurance about the security of either verifier. Because `IAgentVerifier` does not expose its internal verifier set, consumers can check the full deployment configuration at setup time.

**Replay and repeated execution policy**

`IProofVerifier` does not define replay protection. A valid proof over `(inputHash, outputHash)` may replay across contexts if the underlying proof system does not bind to a chain ID, contract address, or nonce.

This ERC does not impose universal single-use semantics. An `IAgentVerifier` can reject every duplicate attempt, allow retry after a failed attempt, allow repeated successful verification, or apply another application-defined policy. An `IAgentVerifier` can enforce single use with a stable application-defined key such as `taskId` or `(taskId, agentId)`.

`verificationDigest` is an audit commitment, not a replay nullifier: because it includes `block.timestamp`, repeated calls can produce different digests. Callers can determine whether a task is single-use by checking the application's replay policy.

**Verification commitment self-containment**

`VerificationCompleted` is designed to be independently verifiable without querying any contract state. On-chain state is mutable — contracts may be upgraded, storage may change, and authorization rules may evolve. If reconstructing or confirming a `verificationDigest` required reading live contract state, historical records would become unverifiable as that state changed. The event carries all preimage fields alongside the digest precisely so that any observer can verify a past event against the immutable log alone, independent of current contract state.

---

## Copyright

Copyright and related rights waived via [CC0](../LICENSE.md).
