The Icicle Snark implementation in this repository provides efficient proof generation using both CUDA, CPU backends. This guide covers installation, execution, and integration into your own Rust or other projects.
For a deeper dive into performance benchmarks and optimizations, check out our blog post: ICICLE-Snark: The Fastest Groth16 Implementation in the World
For a short video explainer illustrating how to use ICICLE-Snark and switching between backends, see here:
Click the image to watch the demo
cd icicle/
cmake -DCMAKE_BUILD_TYPE=Release -DCURVE=bn254 -DCUDA_BACKEND=local -S . -B build
cmake --build build -j
- Define the environment variable
ICICLE_BACKEND_INSTALL_DIR
to point to the backend build directory:
export ICICLE_BACKEND_INSTALL_DIR=path
B5B0
/icicle/build/backend
To execute a proof, specify the paths for the witness file, zkey file, and output paths for the proof and public JSONs.
cargo run --release
prove --witness ./witness.wtns --zkey ./circuit.zkey --proof ./proof.json --public ./public.json --device CUDA
prove --witness ./witness.wtns --zkey ./circuit.zkey --proof ./proof.json --public ./public.json --device CPU
You can integrate Icicle Snark into your Rust project using the provided icicle_snark
library.
cargo add icicle-snark
or add the following to your Cargo.toml
[dependencies]
icicle-snark = { git = "https://github.com/ingonyama-zk/icicle-snark" }
use icicle_snark::{groth16_prove, CacheManager};
fn main() {
let mut cache_manager = CacheManager::default();
let witness = "./witness.wtns";
let zkey = "./circuit_final.zkey";
let proof = "./proof.json";
let public = "./public.json";
let device = "CUDA"; //CPU
for _ in 0..10 {
groth16_prove(witness, zkey, proof, public, device, &mut cache_manager).unwrap();
}
}
Navigate to examples/python folder to see example usage
We benched the code on 2 different setups:
- 4080 & i9–13900K
- 4090 & Ryzen 9 9950X
We used the circuits in the MoPro’s benchmark repository to compare the proving systems.
- Complex Circuits: These circuits are for pure benchmarking purposes. It allows us to compare the performance of the provers based on a number of constraints.
- Anon Aadhaar: Anon Aadhaar is a zero-knowledge protocol that allows Aadhaar ID owners to prove their identity in a privacy preserving way.
- Aptos Keyless: Aptos Keyless lets users create self-custodial Aptos accounts with OIDC credentials (e.g., Google, Apple) instead of secret keys or mnemonics.
In production it’s more likely that a project is going to prove the same circuits. To utilize this we are using the Cache system. However the other tools we compare are CLI so they terminate after one proving. To keep things fair we provide both benchmarks with and without cache.
We have provided some sample circuits under benchmark folder. However to run the prover you need to generate .zkey and .wtns files. You can use snarkjs to do that. We have prepared a setup.sh
script that generates the witness and zkey files for testing purposes only. You can execute this script inside the circuit folder you want to test.
cd benchmark/path
source ../../scripts/setup.sh
This software has not been audited and should not be used in production environments. Use at your own risk.