Arkworks bindings to Circom's R1CS, for Groth16 Proof and Witness generation in Rust.
Clone the repository and run cd ark-circom/ && cargo doc --open
```toml [dependencies]
ark-circom = { git = "https://github.com/gakonst/ark-circom.git" } ```
```rust
// Load the WASM and R1CS for witness and proof generation
let cfg = CircomConfig::
// 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(¶ms, circom, &mut rng)?;
// Check that the proof is valid let pvk = processvk(¶ms.vk)?; let verified = verifywithprocessedvk(&pvk, &inputs, &proof)?; assert!(verified); ```
Tests require the following installed:
1. solc
. We also recommend using solc-select for more flexibility.
2. ganache-cli
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.
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.