A modular zero-knowledge proof toolkit optimized for mobile devices.
This project makes use of Noir's nargo
to compile circuits and generate test artifacts. Make sure to walk through the Quick Start section to install the noir toolchain. Note that we require a specific version of the toolchain, so make sure to override the version with the following command.
noirup --version v1.0.0-beta.11
NOTE: The example below is being run for single example
poseidon-rounds
. You can use different example to run same commands.
Compile the Noir circuit:
cd noir-examples/poseidon-rounds
nargo compile
Generate the Noir Proof Scheme:
cargo run --release --bin provekit-cli prepare ./target/basic.json -o ./noir-proof-scheme.nps
Generate the Noir Proof using the input Toml:
cargo run --release --bin provekit-cli prove ./noir-proof-scheme.nps ./Prover.toml -o ./noir-proof.np
Verify the Noir Proof:
cargo run --release --bin provekit-cli verify ./noir-proof-scheme.nps ./noir-proof.np
Generate inputs for Gnark circuit:
cargo run --release --bin provekit-cli generate-gnark-inputs ./noir-proof-scheme.nps ./noir-proof.np
Recursively verify in a Gnark proof (reads the proof from ../ProveKit/prover/proof
):
cd ../../recursive-verifier
go run .
Benchmark against Barretenberg:
Note: You can install Barretenberg from here.
Note: You can install hyperfine using brew on OSX:
brew install hyperfine
.
cd noir-examples/poseidon-rounds
cargo run --release --bin provekit-cli prepare ./target/basic.json -o ./scheme.nps
hyperfine 'nargo execute && bb prove -b ./target/basic.json -w ./target/basic.gz -o ./target' '../../target/release/provekit-cli prove ./scheme.nps ./Prover.toml'
The provekit-cli
application has written custom memory profiler that prints basic info about memory usage when application
runs. To run binary with profiling enabled run it with cargo --features profiling
param or compile with it.
cargo run --release --bin provekit-cli --features profiling prove ./noir-proof-scheme.nps ./Prover.toml -o ./noir-proof.np
Tracy tool website. To install tracy tool on OSX use brew: brew install tracy
.
Important: integration is done with
Tracy Profiler 0.11.1
. It is newest version available from brew. Newer version may require updating dependencies as tracy is using its own protocol between app and tracy tool that changes with each major version.
TLDR; Tracy is an interactive tool to profile application. There is integration plugin for rust that works with
standard tracing annotation. For now it is integrated into provekit-cli
binary only. Collecting profiling data requires
tracy to run during application profiling. You may noticed that it makes application to run much longer but mostly
due to data transfer between the application and the tracy running along.
Usage:
- Start tracy from command line
tracy
- Leave all fields with defaults and just click
Connect
button. It will cause tracy to start listening on the localhost for incoming data. - Compile
noir-r1cs-profiled
binary.
cargo build --release --bin provekit-cli --features profiling
- (OSX only) If you want to check call stacks additional command needs to be run (base on tracy instruction). The
command must be run against each binary that is being profiled by tracy. This will create directory next to the
binary provided with
.dSYM
suffix (ex.../../target/profiled-cli.dSYM
). Directory will contain the debug symbols and paths extracted with different format that is compatible with tracy tool. It must be rerun after each changes made toprovekit-cli
app.
dsymutil ../../target/release/provekit-cli
- Now start the application to profile:
../../target/release/provekit-cli prove ./noir-proof-scheme.nps ./Prover.toml -o ./noir-proof.np
- Go back to tracy tool. You should see that it receives data. App is interactive.
Samply tool website with instructions to install. It will start local server and open a webpage with interactive app to view results. This does not require to run binary with profiling enabled.
samply record -r 10000 -- ./../../target/release/provekit-cli prove ./noir-proof-scheme.nps ./Prover.toml -o ./noir-proof.np
Cargo instruments tool website with instructions to install. It will open results using built-in Instruments app. Results are interactive.
cargo instruments --template Allocations --release --bin provekit-cli prove ./noir-proof-scheme.nps ./Prover.toml -o ./noir-proof.np
Samply tool website with instructions to install. It will start local server and open a webpage with interactive app to view results. This does not require to run binary with profiling enabled.
samply record -r 10000 -- ./../../target/release/provekit-cli prove ./noir-proof-scheme.nps ./Prover.toml -o ./noir-proof.np
Run the benchmark suite:
cargo test -p provekit-bench --bench bench
ProveKit follows a modular architecture with clear separation of concerns:
provekit/common/
- Shared utilities, core types, and R1CS abstractionsprovekit/r1cs-compiler/
- R1CS compilation logic and Noir integrationprovekit/prover/
- Proving functionality with witness generationprovekit/verifier/
- Verification functionality
tooling/cli/
- Command-line interface (provekit-cli
)tooling/provekit-bench/
- Benchmarking infrastructuretooling/provekit-gnark/
- Gnark integration utilities
skyscraper/
- Optimized field arithmetic for M31/CM31 fieldsplayground/
- Research and experimental implementations
noir-examples/
- Example circuits and test programsgnark-whir/
- Go-based recursive verification using Gnark
This project depends on the following libraries, which are developed in lockstep: