Garaga
State-of-the-art Elliptic Curve operations and SNARKS verification for Cairo & Starknet šŗ.
Install / Use
/learn @keep-starknet-strange/GaragaREADME
About
State-of-the-art Elliptic Curve tooling and SNARKS verification for Cairo & Starknet šŗ.
Garaga enables efficient elliptic curve operations on Starknet. It achieves state of the art performance by
- using a dedicated builtin made by Starkware for emulated modular arithmetic
- using a suite of non-deterministic techniques for extension field multiplication, pairings, and multi scalar multiplication to reduce the number of steps to verify results.
Garaga currently supports:
- Scalar & Multi-scalar multiplication for any Weirstrass curve, including BN254, BLS12_381, SECP256/R1, and ED25519. You can add the one you need by specifying the curve parameters.
- Pairing operations for BN254 and BLS12_381.
- Groth16 smart contract verifiers generators for BN254 and BLS12_381.
- Noir smart contract verifiers generators for ultra keccak honk flavour.
Architecture overview
Garaga consists of a Pythonic backend with Rust bindings and CairoZero / Cairo libraries.
- The Pythonic backend is here to define emulated modular arithmetic circuits that can be compiled to Cairo or Cairo1 code. It also handles witnesses generation for the non-deterministic computations, smart contract contract generation for a given proof system and elliptic curve, and calldata generation from a given proof.
- The CairoZero / Starknet interfaces are responsible for composing and calling the circuits, as well as adding all the extra logic needed to make the algorithms work (Fiat-Shamir heuristic, SNARKS verifiers algorithms, etc).
Quickstart : deploying a SNARK verifier on Starknet
Currently, only Groth16 on BN254 and BLS12_381 is supported with automatic support for json files coming from SnarkJS and Gnark.
-
Create a new directory for you project, and bring the jsons files for verification key, proof file and public inputs inside it.
-
Install the garaga pip package with
pip install garaga. Python 3.10+ is required and a virtual environment is recommended. Entergaragain your terminal to get started. -
Run the
garaga gencommand in your terminal to generate the code for the SNARK verifier given your verification key. -
Edit the generated smart contract to fit the needs of your dapp.
-
Create an environment file
.secretsfollowing the.secrets.templatefile in the root of this repository, containing the Starkner RPC url, your account address, and the private key. -
Run the
garaga declarecommand in your terminal to declare the smart contract on Starknet and obtain its class hash. Note that this is an expensive operation. -
Run the
garaga deploycommand in your terminal using the class hash obtained in the previous step to get the contract address. -
Run the
garaga verify-onchaincommand in your terminal using the contract address, the verification key, the proof and the public inputs to verify the proof against the SNARK verifier contract.
For more details, please refer to the documentation.
Developer setup
To get started with Garaga, you'll need to have some tools and dependencies installed. Here's everything you need:
Prerequisites
Ensure you have the following installed:
- Rust - Required for building the
garaga_rsextension. - Scarb 2.16.1 - The Cairo package manager. Comes with Cairo inside.
Python 3.10-3.14 is used for development but does not need to be installed manually ā make setup will auto-install it via uv if it's not already available. Make sure you have GMP installed for the fastecdsa python package. See here for linux and here for macos.
Optionally :
- pprof - A tool for visualization and analysis of profiling data. Requires Go.
- graphviz - Necessary for generating graphical representations of profiling data.
Setup
Clone the repository and run the setup command from the root:
make setup
This will automatically:
- Install uv if not present
- Install Python 3.14 via uv if no compatible version (3.10-3.14) is found
- Create a virtual environment and install all dependencies
- Build the Rust extension
The setup is idempotent ā running it again will update dependencies without recreating the virtual environment.
Before proceeding, activate the virtual environment by running source venv/bin/activate.
Cairo Benchmarks
š Click on any section below to expand and view detailed benchmark tables with test performance metrics.
Note: Click on the test name to view the profiling image. Resources shown in the table for contracts include extra costs due to the foundry logic. Check the profile file for more details.
<details> <summary><strong>contracts</strong></summary> <details> <summary><strong>āāā groth16_example_bls12_381_integrationtest::test_contract</strong></summary>| Test Name | Steps | Range Check | Range Check 96 | Poseidon | Add Mod | Mul Mod | Sierra Gas | |------------------------------------------------------------------------------------------------|---------|---------------|------------------|------------|-----------|-----------|--------------| | test_verify_groth16_proof_bls12_381 | 353,527 | 10,972 | 90,280 | 586 | 7,506 | 10,868 | 49,754,798 |
</details> <details> <summary><strong>āāā groth16_example_bn254_integrationtest::test_contract</strong></summary>| Test Name | Steps | Range Check | Range Check 96 | Poseidon | Add Mod | Mul Mod | Sierra Gas | |----------------------------------------------------------------------------------------|---------|---------------|------------------|------------|-----------|-----------|--------------| | test_verify_groth16_proof_bn254 | 228,557 | 9,785 | 67,149 | 509 | 5,401 | 8,754 | 34,080,559 |
</details> <details> <summary><strong>āāā noir_ultra_keccak_honk_example_integrationtest::test_contract</strong></summary>| Test Name | Steps | Range Check | Range Check 96 | Bitwise | Poseidon | Add Mod | Mul Mod | Sierra Gas | |------------------------------------------------------------------------------------------------|-----------|---------------|------------------|-----------|------------|-----------|--------
Related Skills
node-connect
334.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
82.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
334.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
82.3kCommit, push, and open a PR
