Chromia
Start Building

08 / 19Module 1: Writing Circom circuitsAdvanced

Circom circuits: compile

Setup Circom circuits

Start with the Circom circuits. You must compile them before you can produce the proving and verification keys.

bash
cd circom_circuit

Next, install the dependencies:

bash
npm install

Compile Circom circuits

This step compiles every circuit and produces its proving and verification keys.

bash
chmod +x compile_complete.sh 

Run the compilation:

bash
./compile_complete.sh

When it finishes, you should see these files:

  • shield_operation.zkey & shield_operation_verification_key.json
  • unshield_operation.zkey & unshield_operation_verification_key.json
  • private_transfer.zkey & verification_key.json

Compilation covers three tasks:

  • Translating each readable .circom source file into a constraint system (.r1cs).
  • Running a trusted setup that outputs a proving key (.zkey) and a verification key (verification_key.json). The client relies on the proving key to create proofs, while the blockchain relies on the verification key to check them.
  • Building WebAssembly (.wasm) versions of the circuits so they run efficiently in the browser.
Written for this site from Chromia’s public course. Code samples are the course’s own.