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.
 
 
 
oskarth d0478d1538
When constraints are unsatisfied, show first one (#21)
2 years ago
.github/workflows Ensure Circom 1 tests pass with experimental Circom 2 support (#18) 2 years ago
benches feat: benchmarks (#3) 3 years ago
src When constraints are unsatisfied, show first one (#21) 2 years ago
test-vectors Initial Circom 2 support (#10) 3 years ago
tests replace i32 by u32 (#19) 2 years ago
.gitignore feat: benchmarks (#3) 3 years ago
Cargo.lock Ensure Circom 1 tests pass with experimental Circom 2 support (#18) 2 years ago
Cargo.toml circom2 proof generation (#14) 2 years ago
README.md doc: Fix Rust dependency in README (#16) 2 years 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::<Bn254, _, _>(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(circom, &params, &mut rng)?;

// Check that the proof is valid
let pvk = prepare_verifying_key(&params.vk);
let verified = verify_proof(&pvk, &proof, &inputs)?;
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

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.