Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gakonst/ark-circom
Arkworks bindings to Circom's R1CS, for Groth16 Proof and Witness generation in Rust.
https://github.com/gakonst/ark-circom
Last synced: 4 months ago
JSON representation
Arkworks bindings to Circom's R1CS, for Groth16 Proof and Witness generation in Rust.
- Host: GitHub
- URL: https://github.com/gakonst/ark-circom
- Owner: arkworks-rs
- License: apache-2.0
- Created: 2021-07-26T09:35:24.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-08-23T17:21:18.000Z (4 months ago)
- Last Synced: 2024-08-23T19:15:04.562Z (4 months ago)
- Language: Rust
- Size: 6.27 MB
- Stars: 226
- Watchers: 10
- Forks: 107
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
- awesome-circom - ark-circom - Arkworks bindings to Circom's R1CS, for Groth16 Proof and Witness generation in Rust (Provers / Cryptographic primitives in other languages)
README
#
ark-circom
Arkworks bindings to Circom's R1CS, for Groth16 Proof and Witness generation in Rust.
![Github Actions](https://github.com/gakonst/ark-circom/workflows/Tests/badge.svg)
## 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.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(¶ms, circom, &mut rng)?;// Check that the proof is valid
let pvk = process_vk(¶ms.vk)?;
let verified = verify_with_processed_vk(&pvk, &inputs, &proof)?;
assert!(verified);
```## Running the tests
Tests require the following installed:
1. [`solc`](https://solidity.readthedocs.io/en/latest/installing-solidity.html). We also recommend using [solc-select](https://github.com/crytic/solc-select) for more flexibility.
2. [`ganache-cli`](https://github.com/trufflesuite/ganache-cli#installation)## Features
- [x] Witness generation using Circom's WASM witness code
- [x] ZKey parsing into Arkworks Proving Key over BN254
- [x] Compatibility layer for Ethereum types, so that proofs can be used in Solidity verifiers
- [x] Proof generations and verification using Arkworks
- [ ] CLI for common operations## 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`](https://github.com/poma/zkutil/)
- [`snarkjs`](https://github.com/iden3/snarkjs/)Special shoutout to [Kobi Gurkan](https://github.com/kobigurk/) for all the help in parsing SnarkJS' ZKey file format.