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

```toml [dependencies]

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

Example

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

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

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

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

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

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

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

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

Known limitations

Currently, due to an issue in our upstream (https://github.com/wasmerio/wasmer/issues/4072), this crate works as expected only up to Rust version 1.67.0; in newer Rust versions, wasmer is currently unsound.

Acknowledgements

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

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