You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
CPerezz d1a6dac988
change: regresion to 0.4
3 months ago
.github/workflows remove deprecated feature flag from CI 4 months ago
benches Use `PrimeField` as generic bound across the codebase (#67) 4 months ago
src Merge branch 'master' into release-0.5 4 months ago
test-vectors remove unused files 4 months ago
tests Merge branch 'master' into release-0.5 4 months ago
.gitignore gitignore ptau files 4 months ago
Cargo.lock change: regresion to 0.4 3 months ago
Cargo.toml change: regresion to 0.4 3 months ago
LICENSE-APACHE chore: add mit/apache dual license 2 years ago
LICENSE-MIT chore: add mit/apache dual license 2 years ago
README.md Rust limitation no longer applies; warning about circom/arkworks diff 4 months ago
rust-toolchain.toml removed unused `version` key from `rust-toolchain.toml`, use latest stable 4 months ago

README.md

ark-circom

Arkworks bindings to Circom's R1CS, for Groth16 Proof and Witness generation in Rust.

Github Actions

Documentation

Clone the repository and run cd ark-circom/ && cargo doc --open

Add ark-circom to your repository

[dependencies]

ark-circom = { git = "https://github.com/gakonst/ark-circom.git" }

Example

// Load the WASM and R1CS for witness and proof generation
let cfg = CircomConfig::<Bn254>::new(
    "./test-vectors/mycircuit.wasm",
    "./test-vectors/mycircuit.r1cs",
)?;

// Insert our public inputs as key value pairs
let mut builder = CircomBuilder::new(cfg);
builder.push_input("a", 3);
builder.push_input("b", 11);

// Create an empty instance for setting it up
let circom = builder.setup();

// Run a trusted setup
let mut rng = thread_rng();
let params = generate_random_parameters_with_reduction(circom, &mut rng)?;

// Get the populated instance of the circuit with the witness
let circom = builder.build()?;

let inputs = circom.get_public_inputs().unwrap();

// Generate the proof
let proof = prove(&params, circom, &mut rng)?;

// Check that the proof is valid
let pvk = process_vk(&params.vk)?;
let verified = verify_with_processed_vk(&pvk, &inputs, &proof)?;
assert!(verified);

Running the tests

Tests require the following installed:

  1. solc. We also recommend using solc-select for more flexibility.
  2. ganache-cli

Features

Notes

The prover key generated by circom differs from the one generated by arkworks' groth16 library. While the format is the same, it represents different values. Circom 'prepares' the powers of tau by converting them to Lagrange base, i.e. from s^i.G -> L_i(s).G. This affects the witness generation process, and the caller needs to ensure the correct R1CSToQAP implementer is used:

Acknowledgements

This library would not have been possibly without the great work done in:

Special shoutout to Kobi Gurkan for all the help in parsing SnarkJS' ZKey file format.