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.circom

Compile with optimization enabled:

bash
zkkit compile circuits/multiplier.circom --optimize

Output Files

  • circuit.r1cs - R1CS constraint system
  • circuit.wasm - WebAssembly witness generator
  • circuit.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 --r1cs flag to generate constraint system
  • Uses --wasm flag to generate WebAssembly binary
  • Outputs compiled files to the outputs/ directory
  • Returns success message when compilation completes