Circom
Install Circom
Direct Binary
You can download the latest release from https://github.com/iden3/circom/releases
From Source
Requires Rust curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Use Playground
You can also build and try out circuits on zkREPL.
https://zkrepl.dev/?gist=168c24e72f4f492d998ab00dee82e21e
Understand your Circuit
Today we will build this simple circuit that creates a zero knowledge proof of knowing the factors of a number without revealing the number.
- The circuit takes three inputs,
a
,b
,ab
. a
&b
are private inputs,ab
is a public input.- The circuit has one output,
1
if valid,0
if invalid.
Full Circuit
Setup your Project
Fork the template, https://github.com/anudit/circom-template. It simplifies the process of compiling Circom circuits in a highly customizable way.
Your project structure should look something like this.
You'll need to download the Powers of Tau file from https://storage.googleapis.com/zkevm/ptau/powersOfTau28_hez_final_20.ptau
and save it inside the build
directory.
You can find the other PTau files here https://github.com/iden3/snarkjs/blob/master/README.md#7-prepare-phase-2
Install the dependencies,
Build & Test your Circuit
Now the fun part.
Your circuit files should be present in build/CheckMult
directory.
Your logs should look like this.
On-chain Verification
- Your Solidity/Vyper/Fe Verifier should be present in
build/CheckMult/CheckMultVerifier.(sol/vy/fe)
- Tutorial on On-chain Verification
More Reading
- Learn Circom: https://learn.0xparc.org/materials/circom/learning-group-1/circom-1
- Build optimzed graphs of your circuits: https://github.com/iden3/circom-witnesscalc, Only for circom
<2.2.0