Home

Awesome

<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 />

GitHub Workflow 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

Garaga currently supports:

Following supported schemes will be

Architecture overview

Architecture Overview

Garaga consists of a Pythonic backend with Rust bindings and CairoZero / Cairo libraries.

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. Python3.10 is mandatory 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:

Optionally :

Setup

Once you have the prerequisites installed, clone the repository, and set up your development environment with the following command. Be sure to run this command from the root of the repository.

make setup

At this point, you should have everything you need to start developing with Garaga. Before proceeding, make sure to activate the virtual environment by running source venv/bin/activate.

Benchmarks

OPWeight in stepsComment
MULMOD8Equivalent cost of a*b % p with the modulo builtin in VM steps
ADDMOD4Equivalent cost of a+b % p with the modulo builtin in VM steps
ASSERT_EQ2Equivalent cost of a==b % p with the modulo builtin in VM steps
RLC28Cost of writing a field element to the value segment and retrieving random coefficients
POSEIDON 4 LIMBS17Cost of hashing the 4 limbs of 384 bits emulated field element with Poseidon
circuitMULMODADDMODASSERT_EQPOSEIDONRLC~steps
Derive Point From X6200056
Fp6 SQUARE_TORUS1222071324
Fp12 SQUARE25110131480
Fp12 MUL36220131612
Fp6 MUL_TORUS36340132688
MSM 1 points15012805202544
MSM 2 points19416606403240
MSM 3 points23820407603936
MSM 10 points546470016008808
MSM 50 points230619900640036648
Miller n=1 BLS12_381267226861377906347588
Miller n=1 BN254330332281778286653130
Miller n=2 BLS12_381441845252738126369558
Miller n=2 BN254563955763538526681898
Miller n=3 BLS12_381616463644098346391528
Final Exp BN2544681721831931317102236
Miller n=3 BN2547975792452987666110666
Final Exp BLS12_3815123905632333384127627
MultiPairing n=1 BN2547984104461802759383155366
MultiPairing n=1 BLS12_3817795117421403123447175215
MultiPairing n=2 BN25410320127943562783383184134
MultiPairing n=2 BLS12_3819541135812763145447197185
MultiPairing n=3 BN25412656151425322807383212902
MultiPairing n=3 BLS12_38111287154204123167447219155
BLS12FinalExp Fp12 Karabina No EXTF Trick777443002000234200

Support & How to Contribute

We warmly welcome contributions and support from the community! Here's how you can help Garaga grow and improve:

Reporting Issues & Requesting Features

Contributing to Garaga

Showing Support

Every contribution, whether it's code, feedback, or spreading the word, greatly benefits everyone and is deeply appreciated. Thank you for being a part of Garaga's journey!

Security

Garaga follows good practices of security, but 100% security cannot be assured. Garaga is provided "as is" without any warranty. Use at your own risk.

For more information and to report security issues, please refer to our security documentation.

License

This project is licensed under the MIT license.

See LICENSE for more information.

Acknowledgements

Resources

Note: This list is not exhaustive, and is not intended to be.

Contributors

For a full list of all authors and contributors, see the contributors page.

Thanks goes to these wonderful people (emoji key):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tbody> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/feltroidprime"><img src="https://avatars.githubusercontent.com/u/96737978?v=4?s=100" width="100px;" alt="Feltroid Prime"/><br /><sub><b>Feltroid Prime</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/garaga/commits?author=feltroidprime" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/abdelhamidbakhta"><img src="https://avatars.githubusercontent.com/u/45264458?v=4?s=100" width="100px;" alt="Abdel @ StarkWare "/><br /><sub><b>Abdel @ StarkWare </b></sub></a><br /><a href="https://github.com/keep-starknet-strange/garaga/commits?author=abdelhamidbakhta" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/tekkac"><img src="https://avatars.githubusercontent.com/u/98529704?v=4?s=100" width="100px;" alt="Tarik K."/><br /><sub><b>Tarik K.</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/garaga/commits?author=tekkac" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/bacharif"><img src="https://avatars.githubusercontent.com/u/22233193?v=4?s=100" width="100px;" alt="Bachir Arif"/><br /><sub><b>Bachir Arif</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/garaga/commits?author=bacharif" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/rdubois-crypto"><img src="https://avatars.githubusercontent.com/u/103030189?v=4?s=100" width="100px;" alt="Renaud Dubois"/><br /><sub><b>Renaud Dubois</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/garaga/commits?author=rdubois-crypto" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://raugfer.com/"><img src="https://avatars.githubusercontent.com/u/725060?v=4?s=100" width="100px;" alt="Rodrigo Ferreira"/><br /><sub><b>Rodrigo Ferreira</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/garaga/commits?author=raugfer" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/luiz-lvj"><img src="https://avatars.githubusercontent.com/u/64055364?v=4?s=100" width="100px;" alt="Luiz Vasconcelos Júnior"/><br /><sub><b>Luiz Vasconcelos Júnior</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/garaga/commits?author=luiz-lvj" title="Code">💻</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="http://shramee.me/"><img src="https://avatars.githubusercontent.com/u/11048263?v=4?s=100" width="100px;" alt="Shramee Srivastav"/><br /><sub><b>Shramee Srivastav</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/garaga/commits?author=shramee" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/akinovak"><img src="https://avatars.githubusercontent.com/u/28649205?v=4?s=100" width="100px;" alt="Andrija Novakovic"/><br /><sub><b>Andrija Novakovic</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/garaga/commits?author=akinovak" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/Liam-Eagen"><img src="https://avatars.githubusercontent.com/u/5618692?v=4?s=100" width="100px;" alt="Liam Eagen"/><br /><sub><b>Liam Eagen</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/garaga/commits?author=Liam-Eagen" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/petscheit"><img src="https://avatars.githubusercontent.com/u/10947187?v=4?s=100" width="100px;" alt="Paul Etscheit"/><br /><sub><b>Paul Etscheit</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/garaga/commits?author=petscheit" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/stefanMadzharov"><img src="https://avatars.githubusercontent.com/u/83451593?v=4?s=100" width="100px;" alt="stefanMadzharov"/><br /><sub><b>stefanMadzharov</b></sub></a><br /><a href="https://github.com/keep-starknet-strange/garaga/commits?author=stefanMadzharov" title="Code">💻</a></td> </tr> </tbody> <tfoot> <tr> <td align="center" size="13px" colspan="7"> <img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg"> <a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a> </img> </td> </tr> </tfoot> </table> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> <!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the all-contributors specification. Contributions of any kind welcome!