zkkit compile
Compile Circom circuits into R1CS constraints and WASM files
Description
The compile command wraps the circom compiler to compile your circuit files into R1CS constraint systems and WASM witness generation files. zkkit executes the circom CLI with optimized flags.
Under the hood: This command runs circom [circuit] --r1cs --wasm -o outputs
Usage
bash
zkkit compile [circuit-file]Options
-o, --outputSpecify output directory (default: build/)--optimizeEnable circuit optimization
Examples
Compile a specific circuit:
bash
zkkit compile circuits/multiplier.circomCompile with optimization enabled:
bash
zkkit compile circuits/multiplier.circom --optimizeOutput Files
circuit.r1cs- R1CS constraint systemcircuit.wasm- WebAssembly witness generatorcircuit.sym- Symbol information
Implementation
View how this command works under the hood:
src/commands/compile.js
import { run } from "../utils/exec.js";
export default async function compile(opts = {}) {
const { circuit = "circuits/schema.circom" } = opts;
await run(`circom ${circuit} --r1cs --wasm -o outputs`);
console.log("✔ Circuit compiled");
}What it does:
- Takes circuit path as parameter (defaults to
circuits/schema.circom) - Executes the Circom compiler with
--r1csflag to generate constraint system - Uses
--wasmflag to generate WebAssembly binary - Outputs compiled files to the
outputs/directory - Returns success message when compilation completes