Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article examines ERC7992, a proposed standard interface for verifying ML model inference results onchain using zero-knowledge proofs.

This walkthrough is based on the specification linked below.

I also cover other EIPs, BIPs, SLIPs, CAIPs, ENSIPs, RFCs, and ACPs.

Overview

ERC7992 defines a standard interface for cryptographically verifying machine learning (ML) inference results onchain. It uses an approach called ZKML (Zero-Knowledge Machine Learning) to prove and verify, through zero-knowledge proofs, that a particular model produced a specific output for a specific input.

Zero-knowledge proofs

A cryptographic technique that allows someone to prove knowledge of a fact without disclosing the underlying information. For example, you can prove that you know a password without revealing the password itself.

The proposal consists of two main components. The first is a registry, which registers hashes of ML model weights, architecture, proof circuits, and verifying keys onchain. The second is a verifier, which checks submitted zero-knowledge proofs to establish the correctness of inference results.

For more information on ERC165, see the following article.

[ERC165] Checking Whether a Contract Supports a Specific Interface

The following diagram shows the overall ZKML workflow. The original diagrams and Mermaid labels in this article are retained in Japanese.

Overall ZKML workflow

An ML model performs inference offchain, and a zero-knowledge proof is generated alongside the result. The proof is submitted to an onchain verifier and checked against the model commitment registered in the registry.

Contracts compliant with ERC7992 implement ERC165, allowing supported interfaces to be detected.

Motivation

The Trust Problem Between Smart Contracts and AI

Smart contracts cannot directly execute large ML models. Gas costs and the computational limits of the EVM make running models with millions of parameters onchain impractical.

Projects currently use one of the following three approaches, none of which provides the desired cryptographic guarantees.

Approach Description Limitation
Trusting a centralized server An offchain server returns the inference result. A dishonest server can go undetected.
Simplifying the model A drastically reduced model runs onchain. Accuracy declines substantially, making it impractical.
Social committees Multiple parties agree on the correctness of the result. Consensus is costly and provides no cryptographic guarantee.

For example, a DeFi protocol using AI for risk assessment needs a way to verify that an inference result was actually computed correctly by a specific model. Otherwise, funds could move based on fraudulent results.

Why ZKML Needs a Standard

ZKML (Zero-Knowledge Machine Learning) uses zero-knowledge proofs to bridge this trust gap. A prover can demonstrate that a particular model produced a particular output for a particular input without revealing model weights or input data.

Without a standard interface, however, every dApp and verifier combination requires a custom implementation. Different ABIs, registry schemas, and event definitions proliferate, undermining interoperability.

ERC7992 addresses this problem by turning verifiable ML inference into a reusable Ethereum primitive. Just as ERC20 and ERC721 established standards for tokens, ERC7992 aims to do the same for verification of AI outputs.

For more information on ERC20, see the following article.

[ERC20] A Beginner's Guide to ERC20

For more information on ERC721, see the following article.

[ERC721] A Beginner's Guide to ERC721

Specification

Terminology and Identifiers

The following table summarizes the main concepts and identifiers used in ERC7992.

Term Type Description
Model Commitment Struct Groups hashes of the model weights, architecture, proof circuit, and verifying key. It serves as the registered model's fingerprint.
modelId uint256 A unique identifier issued by the registry when a model is registered.
inputCommitment bytes32 A hash commitment to the private inference input. Domain separation is required, and a nonce or salt should be included for replay protection.
output bytes The ABI-encoded public inference output. Its schema is application-specific.
proof bytes The zero-knowledge proof as bytes.
proofSystemId bytes4 A four-byte identifier for the proof system, curve, and version.

Domain separation

A mechanism for preventing hashes used for different purposes from being confused with one another. For example, including a prefix such as "ZKML_MODEL_V1" in the hash calculation helps prevent collisions with hashes generated in other contexts.

Calculating proofSystemId

proofSystemId is calculated as follows.

javascript
bytes4(keccak256(abi.encodePacked(<canonical-proof-system-name-and-version>)))

<canonical-proof-system-name-and-version> is a lowercase, hyphen-separated string.

Proof system Example string
Groth16 (BN254 curve) "groth16-bn254-v1"
Plonk (BN254 curve) "plonk-bn254-v2"
STARK "stark-airfoo-v1"

This approach generates deterministic identifiers across implementations and reduces the risk of collisions.

Registry

The registry is a contract that registers and manages commitments to ML models. By recording a model's fingerprint onchain, it allows the verifier to identify which model a proof should be checked against.

Here is the complete registry interface.

javascript
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

interface IERCZKMLRegistry /* is IERC165 */ {
    struct ModelCommitment {
        bytes32 modelHash;     // weights + architecture hash
        bytes32 circuitHash;   // arithmetic circuit / AIR hash
        bytes32 vkHash;        // verifying key hash
        bytes4  proofSystemId; // keccak-based identifier
        string  uri;           // optional off-chain metadata (IPFS/HTTP)
    }

    event ModelRegistered(
        uint256 indexed modelId,
        address indexed owner,
        ModelCommitment commitment
    );

    event ModelUpdated(
        uint256 indexed modelId,
        ModelCommitment oldCommitment,
        ModelCommitment newCommitment
    );

    event ModelDeprecated(uint256 indexed modelId);

    error ModelNotFound(uint256 modelId);
    error NotModelOwner(uint256 modelId, address caller);
    error ModelDeprecated(uint256 modelId);

    function registerModel(ModelCommitment calldata commitment)
        external
        returns (uint256 modelId);

    function updateModel(uint256 modelId, ModelCommitment calldata newCommitment)
        external;

    function deprecateModel(uint256 modelId) external;

    function getModel(uint256 modelId)
        external
        view
        returns (ModelCommitment memory commitment, bool deprecated, address owner);
}

The ModelCommitment Struct

ModelCommitment is a collection of data that cryptographically establishes a model's identity. Each field holds a hash representing a different aspect of the model, making it possible to check that a registered model has not been altered.

Field Type Description
modelHash bytes32 Hash of the model weights and architecture. It serves as the model's fingerprint and is consistent for the same model.
circuitHash bytes32 Hash of the arithmetic circuit or AIR (Algebraic Intermediate Representation). Identifies the circuit used to verify model inference with a zero-knowledge proof.
vkHash bytes32 Hash of the verifying key. Establishes the identity of the key used to verify proofs.
proofSystemId bytes4 Identifier of the proof system in use, such as Groth16, Plonk, or STARK.
uri string Optional URI for offchain metadata (IPFS or HTTP), which may contain a model description, information about training data, or a license.

registerModel

javascript
function registerModel(ModelCommitment calldata commitment)
    external
    returns (uint256 modelId);

Registers a new model commitment in the registry. When a model owner calls this function, the registry assigns and returns a unique modelId. The ModelRegistered event is emitted when registration is complete.

  • Parameters

    • commitment
      • The model commitment data to register.
  • Return value

uint256 The unique model ID issued by the registry.

updateModel

javascript
function updateModel(uint256 modelId, ModelCommitment calldata newCommitment)
    external;

Updates an existing model commitment. This function is used when the commitment needs to change, for example after retraining the model or improving the circuit. Only the model owner can call it. The ModelUpdated event is emitted when the update is complete.

  • Parameters
    • modelId
      • The ID of the model to update.
    • newCommitment
      • The new commitment data.

Updating a commitment may invalidate proofs generated against the old commitment. Consumers can pin a specific combination of modelId and commitment hash, or check the deprecation flag before an update.

deprecateModel

javascript
function deprecateModel(uint256 modelId) external;

Marks a model as deprecated. Verification of new proofs for deprecated models is refused. Only the model owner can call this function. The ModelDeprecated event is emitted when deprecation is set.

  • Parameters
    • modelId
      • The ID of the model to deprecate.

getModel

javascript
function getModel(uint256 modelId)
    external
    view
    returns (ModelCommitment memory commitment, bool deprecated, address owner);

Retrieves commitment information for a specified model ID. When a verifier checks a proof for a model, it looks up the commitment through this function.

  • Parameters

    • modelId
      • The ID of the model to retrieve.
  • Return values

ModelCommitment The model commitment data. bool The deprecation flag. If true, the model is deprecated. address The model owner's address.

Events

ModelRegistered
javascript
event ModelRegistered(
    uint256 indexed modelId,
    address indexed owner,
    ModelCommitment commitment
);

Emitted when a new model is registered in the registry.

Parameter Type indexed Description
modelId uint256 yes The assigned model ID.
owner address yes The model owner's address.
commitment ModelCommitment no The registered commitment data.
ModelUpdated
javascript
event ModelUpdated(
    uint256 indexed modelId,
    ModelCommitment oldCommitment,
    ModelCommitment newCommitment
);

Emitted when a model commitment is updated. It includes both the old and new commitments, allowing changes to be tracked.

Parameter Type indexed Description
modelId uint256 yes The ID of the updated model.
oldCommitment ModelCommitment no The commitment before the update.
newCommitment ModelCommitment no The commitment after the update.
ModelDeprecated
javascript
event ModelDeprecated(uint256 indexed modelId);

Emitted when a model is deprecated.

Parameter Type indexed Description
modelId uint256 yes The ID of the deprecated model.

Errors

Error Description
ModelNotFound(uint256 modelId) Returned if the specified model ID does not exist.
NotModelOwner(uint256 modelId, address caller) Returned when the caller is not the model owner. Used for permission checks in updateModel and deprecateModel.
ModelDeprecated(uint256 modelId) Returned when an operation is attempted on a deprecated model.

Verifier

The verifier is a contract that accepts zero-knowledge proofs and verifies the correctness of ML inference results onchain. It retrieves the model commitment from the registry and checks whether the submitted proof is valid against that commitment.

Here is the complete verifier interface.

javascript
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

interface IERCZKMLVerifier /* is IERC165 */ {
    event InferenceVerified(
        uint256 indexed modelId,
        bytes32 indexed inputCommitment,
        bytes   output,
        address indexed caller
    );

    error InvalidProof();
    error ModelMismatch();
    error InputCommitmentMismatch();
    error OutputMismatch();
    error UnsupportedProofSystem(bytes4 proofSystemId);
    error VerificationRefused_ModelDeprecated(uint256 modelId);

    function verifyInference(
        uint256 modelId,
        bytes32 inputCommitment,
        bytes calldata output,
        bytes calldata proof
    ) external;

    function proofSystemOf(uint256 modelId) external view returns (bytes4);
    function registry() external view returns (address registryAddress);
}

verifyInference

javascript
function verifyInference(
    uint256 modelId,
    bytes32 inputCommitment,
    bytes calldata output,
    bytes calldata proof
) external;

The core function for verifying ZK proofs. It retrieves the model commitment from the registry and checks whether the proof is valid against it. It must revert if verification fails; emitting the InferenceVerified event on success is recommended. The function has a void return type (no return value) to avoid returning a redundant boolean: failure reverts, while success returns normally. A call that does not revert indicates successful verification; a revert indicates failure.

The following diagram shows the verifyInference workflow.

sequenceDiagram
    participant Caller as 呼び出し元
    participant Verifier as 検証器
    participant Registry as レジストリ

    Caller->>Verifier: verifyInference(modelId, inputCommitment, output, proof)
    Verifier->>Registry: getModel(modelId)
    Registry-->>Verifier: commitment, deprecated, owner
    alt 非推奨モデル
        Verifier-->>Caller: revert VerificationRefused_ModelDeprecated
    else 証明検証
        Verifier->>Verifier: 証明をコミットメントに対して検証
        alt 検証失敗
            Verifier-->>Caller: revert InvalidProof / ModelMismatch / etc.
        else 検証成功
            Verifier-->>Caller: InferenceVerified イベント発行(推奨)
        end
    end

When the caller submits a proof, the verifier first obtains the model commitment from the registry. If the model is deprecated, the call reverts. Otherwise, proof verification proceeds. Emitting the InferenceVerified event is recommended after successful verification.

Parameter Type Description
modelId uint256 Identifier of a model registered in the registry.
inputCommitment bytes32 Hash commitment to the private input. A nonce or salt should be included for replay protection.
output bytes ABI-encoded public inference output.
proof bytes Zero-knowledge proof as bytes.

The verifier is fundamentally stateless and only emits events. When persistent state is required, use the storage extension described below.

proofSystemOf

javascript
function proofSystemOf(uint256 modelId) external view returns (bytes4);

Returns the ID of the proof system used by the specified model. Consumers can check which proof system to use before generating a proof.

  • Parameters

    • modelId
      • The target model ID.
  • Return value

bytes4 The proof system identifier.

registry

javascript
function registry() external view returns (address registryAddress);

Returns the address of the registry contract referenced by the verifier.

  • Return value

address The registry contract address.

Events

InferenceVerified
javascript
event InferenceVerified(
    uint256 indexed modelId,
    bytes32 indexed inputCommitment,
    bytes   output,
    address indexed caller
);

Emitted when inference verification succeeds.

Parameter Type indexed Description
modelId uint256 yes The ID of the verified model.
inputCommitment bytes32 yes Hash commitment to the input.
output bytes no The public inference output.
caller address yes The address that called verification.

Errors

Error Description
InvalidProof() Returned when the proof is invalid.
ModelMismatch() Returned when the proof is valid but is not bound to the model identified by the specified modelId.
InputCommitmentMismatch() Returned when the input commitment does not match the proof.
OutputMismatch() Returned when the output does not match the proof or commitment.
UnsupportedProofSystem(bytes4 proofSystemId) Returned when the verifier does not support the proof system.
VerificationRefused_ModelDeprecated(uint256 modelId) Returned when verification for a deprecated model is refused.

Storage Extension

The base verifier is stateless. This optional extension interface persists verified inference records when auditability or deterministic settlement is required.

javascript
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

interface IERCZKMLStorageExtension {
    event InferenceStored(bytes32 indexed inferenceId);

    function verifyAndStoreInference(
        uint256 modelId,
        bytes32 inputCommitment,
        bytes calldata output,
        bytes calldata proof
    ) external returns (bytes32 inferenceId);

    function getInference(bytes32 inferenceId)
        external
        view
        returns (uint256 modelId, bytes32 inputCommitment, bytes memory output);
}

verifyAndStoreInference

javascript
function verifyAndStoreInference(
    uint256 modelId,
    bytes32 inputCommitment,
    bytes calldata output,
    bytes calldata proof
) external returns (bytes32 inferenceId);

Verifies a proof and stores the successfully verified inference record onchain. The call reverts if the proof is invalid. The InferenceStored event is emitted once storage is complete.

inferenceId is calculated as keccak256(abi.encodePacked(modelId, inputCommitment, output)). If replay is a concern, a nonce or salt must be embedded in inputCommitment.

  • Return value

bytes32 The unique identifier of the stored inference record.

getInference

javascript
function getInference(bytes32 inferenceId)
    external
    view
    returns (uint256 modelId, bytes32 inputCommitment, bytes memory output);

Retrieves a previously stored inference record. Other contracts use this function to reference past verification results. For example, if a DeFi protocol uses AI inference results to decide insurance claims, it can retrieve past inference records through this function to help resolve disputes.

  • Parameters

    • inferenceId
      • The ID of the inference record to retrieve.
  • Return values

uint256 The model ID. bytes32 The hash commitment to the input. bytes The public inference output.

Additional Design Considerations

Separating the Registry and Verifier

ERC7992 separates the registry and verifier into different contracts to prioritize modularity. The registry manages model registration information, while the verifier focuses on proof verification logic.

Architecture separating the registry and verifier

This separation allows teams to upgrade the verifier independently. For example, when adding support for a new proof system (moving from STARK to a next-generation scheme), the verifier can be replaced while retaining the registry data. Conversely, changes to registry management policies do not affect the verifier.

Why the Function Returns void

The absence of a return value from verifyInference follows the same pattern as OpenZeppelin's SafeERC20. The two outcomes, reverting on failure and returning normally on success, eliminate a redundant boolean return value. The caller can determine the verification result simply by checking whether the function completed successfully.

Replay Protection with Nonces

Embedding a nonce or salt in inputCommitment helps prevent reuse of a proof for the same model, input, and output. Replay protection is especially important in the following cases.

  • The model's output is nondeterministic (the same input may yield different outputs across executions).
  • The inference result is used in a one-time decision (such as deciding an insurance claim).

When using the storage extension, including a nonce in inputCommitment is also important to avoid collisions in inferenceId.

Deterministic Design of proofSystemId

proofSystemId is calculated deterministically using keccak to reduce collisions and ambiguity. Verifiers supporting multiple proof systems must reliably determine which one to use for verification. Manually assigning IDs risks duplication, whereas hashing a canonical string produces the same ID regardless of who computes it, enabling predictable dispatch.

Proof System Pluggability

proof and output use the bytes type to avoid dependence on a particular proof system or schema. Even when using different proof systems such as Groth16, Plonk, or STARK, the ABI does not need to change. Identification through proofSystemId and internal dispatch allow the verifier to route processing to the appropriate verification logic.

Compatibility

Relationship with Existing Standards

ERC7992 is fully backward compatible with existing standards.

Standard Relationship
ERC165 Used for interface detection, following the same pattern as ERC721 and ERC1155.
ERC20/ERC721 No dependency on token ownership standards; can coexist with existing protocols with minimal conflicts.

The registry interface returns the owner associated with each modelId. Ownership management is implementation-specific: simple owner storage, ERC173, or role-based access control can be chosen according to the project's requirements.

For more information on ERC1155, see the following article.

[ERC1155] A Beginner's Guide to ERC1155

Security

Replay Attacks

When uniqueness of an inference result matters, inputs must include a nonce or salt. Without a nonce, an earlier valid proof may be reused, allowing the same inference result to be treated as verified multiple times. When using the storage extension, tracking consumed inferenceId values is another possible mitigation.

Risks of Updating Model Commitments

Updating a commitment through updateModel may cause proofs generated against the old commitment to fail verification. Consumers should use one of the following approaches to address this risk.

  • Pin a specific combination of modelId and commitment hash.
  • Check the deprecated flag in advance.
  • Implement a versioning policy (issue a new modelId for a new commitment).

Hash Domain Separation

To prevent hash collisions across contexts, use a prefix such as "ZKML_MODEL_V1" for domain separation. Without domain separation, a hash generated by another protocol could accidentally match a ZKML commitment.

Ambiguity in Output Data

Because output is of type bytes, malicious byte strings can be supplied as outputs if the schema is not specified. Consuming contracts must agree on an output schema in advance or perform additional verification of an output commitment.

Denial of Service (Expensive Verification)

ZK proof verification consumes substantial gas. Submitting many verification requests can create a denial-of-service risk by exhausting the gas available to a contract and disrupting service. Possible mitigation approaches include the following.

  • Perform preliminary verification offchain and verify only a concise attestation onchain.
  • Batch or aggregate multiple proofs for verification.
  • Separate verification-only calls from storage writes so users can choose the cost they incur.
  • Use events alone when persistent storage is unnecessary, since event emission costs less gas than persisting an audit trail in storage.

Reference Implementation

The following is a reference implementation of an ERC7992 verifier contract. It illustrates the basic flow of retrieving a model commitment from the registry and verifying a proof.

contracts/ZKMLVerifier.sol
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

import "./IERCZKMLRegistry.sol";
import "./IERCZKMLVerifier.sol";

contract ZKMLVerifier is IERCZKMLVerifier {
    IERCZKMLRegistry public immutable override registry;

    constructor(IERCZKMLRegistry _registry) {
        registry = _registry;
    }

    function verifyInference(
        uint256 modelId,
        bytes32 inputCommitment,
        bytes calldata output,
        bytes calldata proof
    ) external override {
        (IERCZKMLRegistry.ModelCommitment memory cm, bool deprecated,) =
            registry.getModel(modelId);

        if (deprecated) revert ModelDeprecated(modelId);

        // Dispatch based on proofSystemId. Example only.
        // bool ok = VerifierLib.verify(proof, cm.vkHash, inputCommitment, output);
        bool ok = _dummyVerify(proof, cm.vkHash, inputCommitment, output);
        if (!ok) revert InvalidProof();

        emit InferenceVerified(modelId, inputCommitment, output, msg.sender);
    }

    function proofSystemOf(uint256 modelId) external view override returns (bytes4) {
        (IERCZKMLRegistry.ModelCommitment memory cm,,) = registry.getModel(modelId);
        return cm.proofSystemId;
    }

    function _dummyVerify(
        bytes calldata,
        bytes32,
        bytes32,
        bytes calldata
    ) private pure returns (bool) {
        return true;
    }
}

In this reference implementation, the _dummyVerify function always returns true. A real production deployment must implement proof verification logic such as Groth16 or Plonk instead. Multiple proof systems can be supported by dispatching to an appropriate verification library based on proofSystemId.

References

Conclusion

This article covered how ERC7992 uses zero-knowledge proofs to verify ML model inference. I hope it helped clarify the mechanism.

If you have any questions, feel free to send me a DM on Twitter.

Twitter @cardene777

I also share technical content on other platforms.