SkillAgentSearch skills...

Garaga

State-of-the-art Elliptic Curve operations and SNARKS verification for Cairo & Starknet 🐺.

Install / Use

/learn @keep-starknet-strange/Garaga

README

<div align="center"> <h1>Garaga</h1> <img src="docs/images/logo.png" height="200"> <br /> <a href="https://github.com/keep-starknet-strange/garaga/issues/new?assignees=&labels=bug&template=01_BUG_REPORT.md&title=bug%3A+">Report a Bug</a> - <a href="https://github.com/keep-starknet-strange/garaga/issues/new?assignees=&labels=enhancement&template=02_FEATURE_REQUEST.md&title=feat%3A+">Request a Feature</a> - <a href="https://github.com/keep-starknet-strange/garaga/discussions">Ask a Question</a> </div> <div align="center"> <br />

CI Status Project license Pull Requests welcome

Exploration_Team

</div> </details>

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

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.

  1. Create a new directory for you project, and bring the jsons files for verification key, proof file and public inputs inside it.

  2. Install the garaga pip package with pip install garaga. Python 3.10+ is required and a virtual environment is recommended. Enter garaga in your terminal to get started.

  3. Run the garaga gen command in your terminal to generate the code for the SNARK verifier given your verification key.

  4. Edit the generated smart contract to fit the needs of your dapp.

  5. Create an environment file .secrets following the .secrets.template file in the root of this repository, containing the Starkner RPC url, your account address, and the private key.

  6. Run the garaga declare command in your terminal to declare the smart contract on Starknet and obtain its class hash. Note that this is an expensive operation.

  7. Run the garaga deploy command in your terminal using the class hash obtained in the previous step to get the contract address.

  8. Run the garaga verify-onchain command 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_rs extension.
  • 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

View on GitHub
GitHub Stars257
CategoryDevelopment
Updated6d ago
Forks86

Languages

Cairo

Security Score

100/100

Audited on Mar 18, 2026

No findings