CLI Reference

Lof ships with three binaries: lof for compiling .lof source files, lofit for Groth16 setup/proving/verification, and lof-witness-gen for producing witness calculators from IR artifacts. This page documents the commands, default outputs, and common options for each tool.

lof — language compiler

The lof CLI parses, type checks, and compiles .lof circuits. All commands require a file with the .lof extension.

lof <command> [options]

Commands

lof check

lof check path/to/circuit.lof [--verbose]
  • Runs the parser and type checker without emitting artifacts.
  • --verbose prints the source, pipeline status, and additional diagnostics.
  • Fails if the file is missing a proof block or violates visibility/type rules.

lof compile

lof compile path/to/circuit.lof \
  [--target {r1cs|wasm}] \
  [--output <dir>] \
  [--generate-templates] \
  [--skip-wasm] \
  [--verbose]
  • Default target is r1cs. Artifacts are copied into build/, with companion directories inputs/, keys/, and proofs/ created alongside the source.
  • --generate-templates writes <name>_public.json and <name>_witness.json under inputs/ using the signal names from the compiled circuit.
  • --output overrides the root directory used for the generated folders when targeting WebAssembly.
  • --target wasm first compiles to R1CS, then reuses lofit package-web to create a browser-oriented bundle (keys, prover WASM, witness helpers). Use --skip-wasm to emit the source tree without running wasm-pack.
  • --verbose surfaces pipeline stages and tracing output.

lof parse

lof parse path/to/circuit.lof [--pretty] [--verbose]
  • Parses a .lof file and prints the AST to stdout.
  • --pretty formats the debug output with indentation.
  • --verbose echoes the source and parsing stages before dumping the AST.

lof version

lof version
  • Prints the current crate version (identical to --version).

Generated filesystem layout

Running lof compile (target r1cs) produces:

  • build/<name>.r1cs — constraint system
  • build/<name>.ir — intermediate representation (if IR generation is enabled)
  • inputs/<name>_public.json and inputs/<name>_witness.json (when --generate-templates is passed)
  • empty keys/ and proofs/ directories ready for lofit lof compile --target wasm creates a web package containing build/, keys/, inputs/, proofs/, witness/, and prover/ folders plus integration examples.

lofit — proving toolkit

lofit consumes the artifacts emitted by lof to perform Groth16 setup, proof generation, verification, and web packaging. Unless otherwise specified, it infers file names from the base name of the supplied R1CS file and defaults to the build/, inputs/, keys/, and proofs/ directories produced earlier.

lofit <command> [options]

Commands

lofit setup

lofit setup --input build/circuit.r1cs \
  [--proving-key keys/circuit_pk.bin] \
  [--verification-key keys/circuit_vk.bin]
  • Generates a Groth16 proving key and verification key.
  • If paths are omitted, keys are written to keys/<name>_pk.bin and keys/<name>_vk.bin.

lofit prove

lofit prove --input build/circuit.r1cs \
  [--proving-key keys/circuit_pk.bin] \
  [--public-inputs inputs/circuit_public.json] \
  [--witness inputs/circuit_witness.json] \
  [--output proofs/circuit_proof.bin]
  • Reads the R1CS and proving key, loads public inputs from JSON, and derives the witness.
  • If the witness JSON exists, partially supplied values are respected; otherwise the witness is derived from constraints alone.
  • Writes the Groth16 proof to the selected --output path (default proofs/<name>_proof.bin) and emits full_witness.json alongside the proof.
  • Set the environment variable LOFIT_VERBOSE=1 for constraint-level debug output.

lofit verify

lofit verify \
  [--verification-key keys/circuit_vk.bin] \
  [--proof proofs/circuit_proof.bin] \
  [--public-inputs inputs/circuit_public.json] \
  [--input build/circuit.r1cs]
  • Validates a Groth16 proof against the verification key and public inputs.
  • The optional --input flag helps infer the circuit base name when your files do not follow the default naming convention.

lofit package-web

lofit package-web --input build/circuit.r1cs \
  [--output dist/circuit] \
  [--skip-wasm]
  • Produces a distributable directory containing R1CS, keys, JSON templates, a witness calculator, and a prover WASM bundle with JS/TS bindings.
  • --skip-wasm copies the generated source tree without running wasm-pack (useful when Rust→WASM toolchains are unavailable).
  • Invoked automatically by lof compile --target wasm, but can be run independently for custom packaging workflows.

lofit version

lofit version
  • Prints the current lofit crate version.

lof-witness-gen — witness calculator generator

lof-witness-gen converts an IR file (.ir) into both a Rust witness calculator and a WASM project scaffold.

lof-witness-gen path/to/circuit.ir [output_dir]
  • When output_dir is omitted, files are placed next to the IR source.
  • Emits <name>_witness.rs (Rust helper) and <name>_witness_wasm/ (WASM project with Cargo.toml and src/lib.rs).
  • The generated README at the end of the command outlines next steps for building with wasm-pack.

Typical workflow recap

  1. Compile: lof compile circuits/mul.lof --generate-templates
  2. Setup keys: lofit setup --input circuits/build/mul.r1cs
  3. Populate inputs: edit circuits/inputs/mul_public.json and mul_witness.json
  4. Generate proof: lofit prove --input circuits/build/mul.r1cs
  5. Verify proof: lofit verify --input circuits/build/mul.r1cs
  6. Package for the web (optional): lofit package-web --input circuits/build/mul.r1cs Refer back to the command sections above for optional flags and environment hooks.