ERC-7992 Verifiable ML inference (ZKML) (Verifiable ML Model Inference (ZKML))

Draft · Other · created 2025-07-23

Standardizes a model registry and verifier interface so that smart contracts can verify, via zero-knowledge proof, the inference results of ML models they cannot execute directly.

Why it is needed

Smart contracts cannot execute large ML models directly, nor can they simply trust model output values passed by an oracle as-is. So far projects have taken one of three approaches: trusting a centralized server, simplifying the model to fit on-chain, or relying on a social consensus committee, none of which provide cryptographic guarantees. Zero-knowledge machine learning (ZKML) fills this trust gap by letting a prover show, concisely and privately, that a specific model produced a specific output from a specific input. But without a shared interface, the ABI and registry structure differ for every dApp/verifier pair, making them hard to combine and reuse.

What to implement

In depth

Model commitments and modelId

A ModelCommitment consists of modelHash (weights + architecture), circuitHash (the proof circuit or AIR), vkHash (verification key), proofSystemId, and an optional off-chain metadata uri. Calling registerModel issues a unique modelId corresponding to this commitment. Implementations may decide their own policy on whether to allow version updates under a single modelId or require a new modelId for every change, but that policy must be documented.

proofSystemId derivation rule

proofSystemId must be the first 4 bytes of bytes4(keccak256(abi.encodePacked(<proof-system-name-version>))). Here the string consists of lowercase letters and hyphens, for example forms like "groth16-bn254-v1", "plonk-bn254-v2", or "stark-airfoo-v1". This approach guarantees deterministic, collision-free identifiers across implementations.

Registry interface

IERCZKMLRegistry provides registerModel, updateModel, deprecateModel, and getModel. The registry must expose an owner for each model, and implementations must have some ownership/access-control mechanism, whether a simple owner store, ERC-173, or role-based access control. updateModel and deprecateModel can only be called by that model's owner, and getModel returns the current commitment content, deprecation status, and owner address together.

verifyInference behavior and errors

verifyInference first fetches the modelId's commitment from the registry and verifies the proof. It must revert if the proof is invalid (InvalidProof), does not match the model (ModelMismatch), the input commitment differs (InputCommitmentMismatch), the output does not match (OutputMismatch), the proof system is unsupported (UnsupportedProofSystem), or the model has been deprecated (VerificationRefused_ModelDeprecated). Completing successfully itself signifies validity, and it is recommended to emit an InferenceVerified event at that point. It is recommended that the verifier hold no state beyond emitting the event; stateful functionality can be added via extensions.

Input commitments and output schema

inputCommitment is a hash commitment over both private inputs and inputs declared as public; it must apply domain separation, and must include a nonce or salt when the case is one-time or potentially non-deterministic. output is ABI-encoded bytes, and consuming parties must agree on its schema; it can optionally be further verified with an outputCommitment, but that is not included in the minimal interface.

Optional storage extension

When replay is a concern (e.g. non-deterministic models or one-time inferences), inputCommitment must include a source of uniqueness such as a nonce or salt. IERCZKMLStorageExtension's verifyAndStoreInference verifies the proof and then stores a record under inferenceId = keccak256(abi.encodePacked(modelId, inputCommitment, output)), allowing modelId, inputCommitment, and output to be looked up again via getInference.

Design rationale

Having verifyInference return nothing on success and revert on failure eliminates an unnecessary boolean return, saving gas, and aligns with recent Solidity patterns such as OpenZeppelin's SafeERC20. Separating the registry from the verifier allows each to be upgraded independently, and keeping proof and output as opaque bytes avoids binding the standard to a specific proof system or output schema.

Proposal status

This ERC is currently in Draft status, meaning it is a draft whose details may still change or whose discussion may remain stalled.

Things to watch out for

Original ERC · ← ERCs