- Notifications
You must be signed in to change notification settings - Fork128
Arkworks bindings to Circom's R1CS, for Groth16 Proof and Witness generation in Rust.
License
Apache-2.0, MIT licenses found
Licenses found
arkworks-rs/circom-compat
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Arkworks bindings to Circom's R1CS, for Groth16 Proof and Witness generation in Rust.
Clone the repository and runcd ark-circom/ && cargo doc --open
[dependencies]ark-circom ="0.5.0"
// Load the WASM and R1CS for witness and proof generationlet cfg =CircomConfig::<Bn254>::new("./test-vectors/mycircuit.wasm","./test-vectors/mycircuit.r1cs",)?;// Insert our public inputs as key value pairsletmut builder =CircomBuilder::new(cfg);builder.push_input("a",3);builder.push_input("b",11);// Create an empty instance for setting it uplet circom = builder.setup();// Run a trusted setupletmut rng =thread_rng();let params =generate_random_parameters_with_reduction(circom,&mut rng)?;// Get the populated instance of the circuit with the witnesslet circom = builder.build()?;let inputs = circom.get_public_inputs().unwrap();// Generate the prooflet proof =prove(¶ms, circom,&mut rng)?;// Check that the proof is validlet pvk =process_vk(¶ms.vk)?;let verified =verify_with_processed_vk(&pvk,&inputs,&proof)?;assert!(verified);
Tests require the following installed:
solc
. We also recommend usingsolc-select for more flexibility.ganache-cli
- Witness generation using Circom's WASM witness code
- ZKey parsing into Arkworks Proving Key over BN254
- Compatibility layer for Ethereum types, so that proofs can be used in Solidity verifiers
- Proof generations and verification using Arkworks
- CLI for common operations
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. froms^i.G
->L_i(s).G
. This affects the witness generation process, and the caller needs to ensure the correctR1CSToQAP
implementer is used:
- use
CircomReduction
for working with circom-generated files, - use
LibsnarkReduction
for setup produced using the arkworks backend.
This library would not have been possibly without the great work done in:
Special shoutout toKobi Gurkan for all the help in parsing SnarkJS' ZKey file format.
About
Arkworks bindings to Circom's R1CS, for Groth16 Proof and Witness generation in Rust.
Resources
License
Apache-2.0, MIT licenses found
Licenses found
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.