Lof is a domain-specific language and end-to-end toolkit for authoring zero-knowledge circuits and producing Groth16 proofs over BN254. It couples a strong, security-focused type system with a Rust compiler for the .lof language, a proving and verification CLI, witness generator utilities, and JavaScript helpers for browser and Node runtimes.
- Ergonomic
.loflanguage with parser, type checker, and IR/R1CS back ends lofCLI to check, compile, and package circuits (including web-ready bundles) with rich diagnosticslofitCLI for Groth16 setup/proving/verification plus asset packaging- Built-in WASM packaging for prover bundles (
lof compile --target wasm,lofit package-web) - Witness calculator generation via
lof-witness-gen(Rust and WASM targets) - Optional TypeScript toolkits for loading circuits in Node (
@lof/toolkit-node) and browsers (@lof-lang/toolkit-browser)
lof/– compiler front-end and CLI for the Lof languagelofit/– proving, verification, and Web/WASM packaging toolinglof-witness-gen/– IR-driven witness calculator generatorpackages/– JavaScript toolkits for Node and browser integrationstests/– integration fixtures plus shell runners for parser/typechecker/compiler suites
- Rust toolchain (stable, via
rustup) - Optional:
wasm-packfor building web prover bundles - Optional: Node.js ≥ 18 if you plan to consume the JS toolkits
cargo build --all
# or install the binaries locally
cargo install --path lof
cargo install --path lofit
cargo install --path lof-witness-gen
# make install (release build + version check) is also available
make installproof Multiply {
input a: field;
input b: field;
let c = a * b in
assert c === a * b;
c
}
- Type-check your source:
lof check path/to/circuit.lof --verbose - Compile to R1CS and IR:
lof compile path/to/circuit.lof --generate-templates- Produces
build/,inputs/,keys/, andproofs/directories alongside your source - JSON templates for public inputs and witness assignments land in
inputs/
- Produces
- Generate keys (Groth16):
lofit setup --input build/circuit.r1cs - Create a proof:
lofit prove --input build/circuit.r1cs --public-inputs inputs/circuit_public.json --witness inputs/circuit_witness.json - Verify the proof:
lofit verify --verification-key keys/circuit_vk.bin --proof proofs/circuit_proof.bin --public-inputs inputs/circuit_public.json
The lof compile command requires a .lof extension and can be re-run safely; artifacts in the source directory are refreshed each time.
- Quick bundle generation:
lof compile circuit.lof --target wasm --output dist/circuit - Standalone packaging via
lofit:lofit package-web --input build/circuit.r1cs --output dist/circuit --skip-wasm
Both paths create a directory containing R1CS, Groth16 keys, witness calculator sources, and the prover WASM bundle. When wasm-pack is installed the prover bindings are rebuilt; otherwise the tool falls back to the prebuilt artifacts shipped with lofit.
packages/toolkit-nodeexposes helpers for loading verification keys and verifying proofs in Node environmentspackages/toolkit-browserwraps the web assets emitted bylof compile --target wasmwith ergonomic TypeScript APIs
Consult each package's README for API details and usage examples.
cargo test --allruns Rust unit tests across the workspacemake test-fastexecutes formatting, linting, and unit suitesmake test-integration(or the individual scripts undertests/scripts/) runs parser, typechecker, and compiler integration checks against the.loffixtures
cargo fmt --allandcargo clippy --all-targets --all-featureskeep the codebase tidy- Use
make helpto list the most common development and verification commands - Verbose compiler output (
--verbose) is useful when diagnosing parser/typechecker issues
Licensed under either of
- Apache License, Version 2.0 (
LICENSE-APACHE) - MIT License (
LICENSE-MIT)
at your option.