Glossary

ZKML (Zero-Knowledge Machine Learning)

ZKML applies zero-knowledge proofs to machine learning, enabling verifiable AI inference without revealing model weights or input data.

Key Takeaways

  • ZKML uses zero-knowledge proofs to verify that a machine learning model produced a specific output, without revealing the model's weights, the input data, or both.
  • The core technique is arithmetization: converting ML operations (matrix multiplications, activation functions) into arithmetic circuits that a zk-SNARK or zk-STARK proof system can verify.
  • Circuit size grows with model complexity, making large neural networks like transformers impractical today. Current frameworks handle image classifiers, linear models, and compact CNNs, but full-scale language models remain out of reach for production use.

What Is ZKML?

ZKML (zero-knowledge machine learning) is a set of techniques that apply zero-knowledge proof systems to machine learning inference. The goal is to let one party prove to another that a specific ML model produced a specific output from a specific input, without exposing the model's parameters, the input data, or both.

In traditional ML deployments, users must trust that the model operator actually ran the claimed model and did not tamper with the output. There is no way to independently verify the computation without re-running the model yourself, which requires access to the weights. ZKML closes this gap by producing a cryptographic proof of correct inference that anyone can verify cheaply, even a smart contract on a blockchain.

The field sits at the intersection of two rapidly evolving domains: zero-knowledge cryptography and deep learning. It draws on advances in verifiable computation to make AI outputs trustworthy in adversarial environments where the model operator, the data provider, or both may be untrusted.

How It Works

Running ML inference inside a zero-knowledge proof system involves three stages: arithmetization, proof generation, and verification.

Arithmetization

The first step converts the ML model into an arithmetic circuit: a system of polynomial equations over a large prime field. Each operation the model performs (matrix multiplication, addition, activation function) becomes a set of constraints in this circuit. Solving the constraint system is mathematically equivalent to computing the model's forward pass.

In practice, frameworks like EZKL accept a model exported in the ONNX (Open Neural Network Exchange) format and compile it into a circuit automatically. The model's computational graph is decomposed into primitive operations, each mapped to circuit gadgets in categories such as shape operations, arithmetic operations, pointwise non-linear operations (like ReLU or sigmoid), and specialized layers.

A critical challenge at this stage is quantization. ML models typically use floating-point arithmetic, but zero-knowledge proof systems operate over finite fields (integers modulo a prime). Converting between these representations introduces rounding errors and significant overhead. The prover must demonstrate that every intermediate value satisfies the quantized constraints, which inflates circuit size relative to the original model.

Proof Generation

Once the circuit is defined, the prover executes the ML inference and generates a zero-knowledge proof that the computation was performed correctly. The proof attests that:

  • A specific model (identified by a commitment to its weights) was used
  • A specific input was provided
  • The output is the correct result of running that model on that input

Depending on the privacy requirements, the prover can designate any combination of model weights, inputs, and outputs as public or private. The proof is valid regardless of which values are hidden.

Verification

A verifier checks the proof without re-running the model. Verification is orders of magnitude cheaper than proof generation: it typically requires constant or logarithmic time regardless of model size. This asymmetry is what makes ZKML useful for on-chain verification, where a smart contract can check a proof in a single transaction.

Example Workflow with EZKL

EZKL is an open-source framework (built on the Halo2 proof system) that automates the ZKML pipeline. A simplified workflow looks like this:

# 1. Export your trained model to ONNX format
import torch
torch.onnx.export(model, sample_input, "model.onnx")

# 2. Generate the circuit settings
ezkl gen-settings --model model.onnx

# 3. Compile the model into a circuit
ezkl compile-circuit --model model.onnx

# 4. Run inference and generate a proof
ezkl prove --witness input.json

# 5. Verify the proof (can be done on-chain)
ezkl verify --proof proof.json

For small models (such as MNIST digit classification), EZKL can generate proofs in under a second. As model complexity grows, proof generation time and memory requirements increase dramatically.

Privacy Modes

ZKML supports two primary privacy configurations, each addressing a different trust problem:

Model Integrity (Private Weights)

The model operator wants to prove that a specific proprietary model produced a given output without revealing the model's architecture or weights. This is relevant for commercial AI providers who need to demonstrate that they used the advertised model, not a cheaper substitute, while protecting their intellectual property.

In this mode, the model weights are the private witness, while the input and output are public. The verifier can confirm the output came from the committed model without learning anything about the model itself.

Data Privacy (Private Inputs)

The data owner wants to run inference on sensitive data without revealing it to the model operator. Medical diagnosis, financial credit scoring, and biometric matching are typical scenarios: the user sends a proof that the model classified their data a certain way, without the data ever leaving their device.

In this mode, the input data is the private witness, while the model and output are public. The verifier can confirm that the output corresponds to a valid input without learning what the input was.

Use Cases

On-Chain AI Verification

Smart contracts cannot natively run ML models: the computation is too expensive for on-chain execution. Today, blockchain applications that depend on AI outputs rely on oracles that introduce trust assumptions. The smart contract must trust that the oracle operator actually ran the model and reported the result honestly.

ZKML replaces this trust with cryptographic verification. The model runs off-chain, the prover generates a proof of correct inference, and the smart contract verifies the proof on-chain. This is directly relevant to the oracle problem: ZKML can eliminate the need for trusted intermediaries when AI outputs drive on-chain logic.

Early demonstrations include Modulus Labs' RockyBot (an on-chain trading bot whose decisions are verified via ZK proofs of recurrent model inference) and Leela vs. the World (a verified on-chain chess engine). Giza, built on StarkNet, provides a platform for deploying ZKML models using the ONNX format.

Verifiable Model Evaluation

Regulators and auditors increasingly need to verify that deployed AI models meet stated performance, fairness, or safety criteria. ZKML allows a model operator to prove that their model achieves a claimed accuracy or satisfies a fairness metric on a benchmark dataset, without revealing the model's weights. The verifier can check the proof without needing access to the model itself.

This has applications in financial compliance (proving a credit model does not discriminate), healthcare (proving a diagnostic model meets accuracy thresholds), and AI auditing broadly.

Decentralized AI Marketplaces

In a decentralized marketplace where multiple parties offer AI inference services, buyers need assurance that the provider actually ran the specified model. ZKML proofs serve as receipts of correct computation: the buyer can verify that the output came from the model they paid for, not a cheaper or less accurate substitute.

Private Inference

Users can prove properties about their data without revealing the data itself. For example, a user could prove that their credit score (computed by a known model) exceeds a threshold without disclosing their financial history. This intersects with zero-knowledge compliance frameworks, where selective disclosure of computed results replaces full data sharing.

Current Frameworks and Projects

Several frameworks have emerged to make ZKML more accessible to developers:

FrameworkProof SystemModel FormatNotable Feature
EZKLHalo2ONNXAudited by Trail of Bits; Python, JS, CLI bindings
Modulus LabsRemainder (custom)CustomBenchmarked up to 18M parameter models
GizaSTARKs (StarkNet)ONNXDeploys ZKML models on StarkNet
ZKTorchProtocol-specificPyTorchParallel proof accumulation for speedup

These frameworks automate the arithmetization step, so developers can work with standard ML tooling (PyTorch, TensorFlow, ONNX) rather than writing circuits by hand.

Why It Matters

As AI systems increasingly influence financial decisions, identity verification, and automated trading, the ability to verify AI outputs without trusting the operator becomes critical. This is especially true in blockchain environments, where trustlessness is a core design principle.

For payment infrastructure, ZKML enables scenarios where AI-driven decisions (fraud detection, credit scoring, risk assessment) can be verified by counterparties without exposing proprietary models or sensitive user data. A payment processor could prove that its fraud model flagged a transaction for legitimate reasons, or a lending protocol could verify that a borrower meets underwriting criteria, all without centralized trust. For deeper context on how zero-knowledge proofs apply to financial systems, see the zero-knowledge proofs in Bitcoin research article.

Risks and Considerations

Scalability Constraints

Circuit size grows with model complexity. Each layer, each neuron, and each activation function adds constraints to the arithmetic circuit. A small image classifier (like MNIST) can be proved in under a second, but a distilled GPT-2 model reportedly required 66 minutes and 1 TB of RAM. Full-scale large language models remain far beyond practical ZKML today.

The fundamental bottleneck is the conversion of floating-point operations to finite field arithmetic. Transformer architectures, which dominate modern AI, are especially costly because their attention mechanisms involve dense matrix multiplications and softmax operations that expand dramatically when arithmetized.

Quantization Accuracy Loss

Converting a model from floating-point to fixed-point arithmetic for circuit compatibility introduces precision loss. The quantized circuit may produce slightly different outputs than the original model. For applications where exact numerical agreement matters (financial models, scientific computation), this discrepancy requires careful calibration and testing.

Trusted Setup Requirements

Some proof systems used in ZKML (notably Groth16-based zk-SNARKs) require a trusted setup ceremony. If the setup is compromised, proofs can be forged. Halo2-based systems (used by EZKL) and STARKs avoid this requirement, but they produce larger proofs or have higher verification costs.

Circuit Correctness

The arithmetized circuit must faithfully represent the original model. Bugs in the compilation step (mapping ONNX operations to circuit gadgets) could produce a circuit that proves a different computation than the one intended. This is analogous to compiler bugs in traditional software: the proof is only as trustworthy as the circuit it verifies. Audits (such as Trail of Bits' audit of EZKL) help but cannot guarantee correctness for all model architectures.

Hardware Requirements

Proof generation for even moderately sized models demands significant compute and memory. Specialized hardware (GPUs, FPGAs, or dedicated ZK prover ASICs) can accelerate proof generation, but this raises the barrier to entry and introduces centralization risk: if only well-funded operators can afford to generate proofs, the decentralization benefits of ZKML are diminished.

ZKML vs. Alternative Approaches

ZKML is not the only way to achieve verifiable or private AI inference. Other approaches include:

ApproachPrivacyVerifiabilityTradeoff
ZKMLModel and/or dataCryptographic (trustless)High proving cost; model size limits
TEEs (Trusted Execution Environments)Data in enclaveHardware attestationRelies on hardware vendor trust
Homomorphic EncryptionData (compute on ciphertext)None inherentlyExtreme computational overhead
Optimistic VerificationNoneChallenge-based (fraud proofs)Latency from challenge window

In practice, hybrid architectures are emerging that combine ZKML with TEEs or optimistic verification to balance cost, latency, and security guarantees.

Frequently Asked Questions

Can ZKML verify large language models?

Not yet at production scale. As of 2025, the largest models proven in academic settings have around 18 million parameters (benchmarked by Modulus Labs). Modern LLMs contain billions of parameters. Proof generation time and memory requirements scale with model size, making full-scale LLM verification impractical with current technology.

Does ZKML work with any ML framework?

Most ZKML frameworks accept models in the ONNX interchange format, which can be exported from PyTorch, TensorFlow, and other major ML frameworks. The model must be compatible with the circuit compiler's supported operations: not all layer types or activation functions may be available as circuit gadgets.

How does ZKML relate to ZK-rollups?

ZK-rollups use zero-knowledge proofs to verify batches of transactions for blockchain scaling. ZKML applies the same underlying proof systems to verify ML computations instead of transaction execution. Both rely on arithmetization and validity proofs, but the circuits encode different computations.

This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.