#circom #prover #witness #circuit #verifying #generate #proofs

circom-prover

Circom prover is a Rust library for generating and verifying proofs for Circom circuits

3 releases

new 0.1.0 Feb 6, 2025

#825 in Parser implementations

Download history 377/week @ 2025-02-03

377 downloads per month

MIT/Apache

86KB
2K SLoC

Circom Prover

Circom prover is a Rust library for generating and verifying proofs for Circom circuits. It is designed to be used in cross-platform applications, and is compatible with the Mopro library.

Usage

Depends on the witness generation method, build the rust witness function first. For example, if you use the Rust Witness, please refer to the Rust Witness for more details.

Proof Generation

use std::collections::HashMap;
rust_witness::witness!(multiplier2);
use circom_prover::{prover::ProofLib, witness::WitnessFn, CircomProver};

// Prepare inputs
let mut inputs = HashMap::new();
inputs.insert("a".to_string(), vec!["1".to_string()]);
inputs.insert("b".to_string(), vec!["2".to_string()]);

// Prepare zkey path
let zkey_path = "./test-vectors/multiplier2_final.zkey".to_string();

// Generate proof
let result = CircomProver::prove(
    ProofLib::Arkworks,
    WitnessFn::RustWitness(multiplier2_witness),
    inputs,
    zkey_path,
).unwrap();

Proof Verification

// Verify proof
let valid = CircomProver::verify(
    ProofLib::Arkworks,
    result.proof,
    result.pub_inputs,
    zkey_path,
).unwrap();

Proof Deserialization

use ark_bn254::Bn254;
use circom_prover::{
    prover::{
        serialization::{deserialize_inputs, deserialize_proof},
    },
};
let deserialized_proof = deserialize_proof::<Bn254>(result.proof);
let deserialized_pub_inputs = deserialize_inputs::<Bn254>(result.pub_inputs);

Adapters

Witness Generation

Proof Generation

Performance

It speeds up circom proof by ~100x comparing to arkworks-rs/circom-compat in keccak256 circuits. We will provide more benchmarks with different adapters in the future. And you can also check the Mopro documentation for more benchmarks.

Community

Acknowledgements

This work is sponsored by PSE.

Dependencies

~2–10MB
~110K SLoC