Clean: An Embedded DSL and Formal Verification Framework for ZK Circuits in Lean4

2025-03-27

Researchers have developed Clean, an embedded domain-specific language (DSL) and formal verification framework in Lean4 for building zero-knowledge (ZK) circuits. ZK circuits are prone to bugs, and Clean aims to improve correctness by allowing users to define circuits in Lean4, specify their desired properties, and formally prove them. This project is part of the zkEVM Formal Verification Project, aiming to provide infrastructure and tooling for formal verification of zkEVMs. Clean supports four basic operations for defining circuits: witness, assert, lookup, and subcircuit, and offers a monadic interface for enhanced usability. At its core is the FormalCircuit structure, which tightly packages—in a dependently-typed way—the circuit definition, assumptions, specification, soundness, and completeness proofs. Large circuits can be formally verified by recursively replacing subcircuit constraints with their (formally verified) specifications. The framework has successfully verified simple circuits like 8-bit addition, with future plans to add more low-level gadgets, define common hash function circuits, and build a formally verified minimal VM for a subset of RISC-V.

Development zero-knowledge proof