Efficient pairing library using polynomial representation of field elements, written in Cairo 🐺.
Garaga can enable efficient pairing operations in StarkNet, by using polynomial representation of field elements. This is a work in progress, and is not yet ready for production use.
Here are some interesting use cases enabled by Garaga:
- SNARKs on StarkNet: Groth16 and Plonk (in the near future).
- KZG cryptographic commitment scheme.
- Identity-based encryption schemes.
- Attribute-based encryption schemes.
- BLS (Boneh–Lynn–Shacham) Digital Signature scheme.
In progress.
To get started with Garaga, you'll need to have some tools and dependencies installed. Here's everything you need:
Ensure you have the following installed:
- Python 3.10 - The core language used for development.
- Go - Required for profiling and testing.
- pprof - A tool for visualization and analysis of profiling data.
- graphviz - Necessary for generating graphical representations of profiling data.
Once you have the prerequisites installed, you can set up your development environment with the following steps:
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
.
make run
OP | Weight in steps |
---|---|
MULMOD | 8 |
ADDMOD | 4 |
ASSERT_EQ | 2 |
RLC | 28 |
POSEIDON BN254 | 15 |
POSEIDON BLS12_381 | 19 |
circuit | MULMOD | ADDMOD | ASSERT_EQ | POSEIDON | RLC | ~steps |
---|---|---|---|---|---|---|
Double Step BLS12_381 | 22 | 9 | 2 | 0 | 0 | 216 |
Double Step BN254 | 24 | 11 | 2 | 0 | 0 | 240 |
Fp6 SQUARE_TORUS | 12 | 16 | 0 | 7 | 1 | 307 |
Double-and-Add Step BLS12_381 | 32 | 13 | 4 | 0 | 0 | 316 |
Triple Step | 36 | 14 | 4 | 0 | 0 | 352 |
Double-and-Add Step BN254 | 36 | 17 | 4 | 0 | 0 | 364 |
Mul L by L | 18 | 8 | 0 | 11 | 1 | 391 |
Fp12 SQUARE | 25 | 11 | 0 | 13 | 1 | 493 |
Mul LL by L | 26 | 13 | 0 | 13 | 1 | 509 |
Mul by L | 28 | 15 | 0 | 13 | 1 | 533 |
Mul LL by LL | 32 | 18 | 0 | 13 | 1 | 577 |
Mul by LL | 34 | 20 | 0 | 13 | 1 | 601 |
Fp12 MUL | 36 | 22 | 0 | 13 | 1 | 625 |
Fp6 MUL_TORUS | 36 | 34 | 0 | 13 | 2 | 701 |
Miller n=1 BLS12_381 | 4934 | 3995 | 137 | 1580 | 131 | 89414 |
Miller n=1 BN254 | 5982 | 4801 | 177 | 1810 | 153 | 98848 |
Final Exp BN254 | 4686 | 6059 | 3 | 1931 | 317 | 99571 |
Final Exp BLS12_381 | 5128 | 7117 | 3 | 2333 | 384 | 124577 |
Miller n=2 BLS12_381 | 8026 | 6235 | 273 | 2276 | 199 | 138510 |
Miller n=2 BN254 | 10128 | 7855 | 353 | 2740 | 241 | 160998 |
Miller n=3 BLS12_381 | 11350 | 8707 | 409 | 3088 | 267 | 192594 |
MultiPairing n=1 BN254 | 10668 | 10860 | 180 | 3741 | 470 | 198419 |
MultiPairing n=1 BLS12_381 | 10062 | 11112 | 140 | 3913 | 515 | 213991 |
Miller n=3 BN254 | 14450 | 11085 | 529 | 3758 | 329 | 226580 |
BLS12FinalExp Fp12 Karabina No EXTF Trick | 7774 | 43002 | 0 | 0 | 0 | 234200 |
MultiPairing n=2 BN254 | 14814 | 13914 | 356 | 4671 | 558 | 260569 |
MultiPairing n=2 BLS12_381 | 13154 | 13352 | 276 | 4609 | 583 | 263087 |
MultiPairing n=3 BLS12_381 | 16478 | 15824 | 412 | 5421 | 651 | 317171 |
MultiPairing n=3 BN254 | 19136 | 17144 | 532 | 5689 | 646 | 326151 |
Final Exp BN254 | Final Exp BLS12_381 | Miller n=1 BLS12_381 | Miller n=1 BN254 | Miller n=2 BLS12_381 | Miller n=2 BN254 | Miller n=3 BLS12_381 | Miller n=3 BN254 | |
---|---|---|---|---|---|---|---|---|
MUL_TORUS | 62 | 33 | 0 | 0 | 0 | 0 | 0 | 0 |
EXTF_SQUARE | 0 | 0 | 63 | 65 | 63 | 65 | 63 | 65 |
EXTF_MUL_DENSE | 62 | 33 | 0 | 0 | 5 | 22 | 63 | 66 |
SQUARE_TORUS | 189 | 315 | 0 | 0 | 0 | 0 | 0 | 0 |
Double Step | 0 | 0 | 58 | 44 | 116 | 88 | 174 | 132 |
Double-and-Add Step | 0 | 0 | 4 | 21 | 8 | 42 | 12 | 63 |
Triple Step | 0 | 0 | 1 | 0 | 2 | 0 | 3 | 0 |
MUL_L_BY_L | 0 | 0 | 5 | 22 | 68 | 88 | 73 | 110 |
MUL_LL_BY_LL | 0 | 0 | 0 | 0 | 5 | 22 | 5 | 23 |
MUL_LL_BY_L | 0 | 0 | 0 | 0 | 0 | 0 | 58 | 44 |
MUL_BY_L | 0 | 0 | 58 | 44 | 0 | 0 | 0 | 0 |
MUL_BY_LL | 0 | 0 | 5 | 22 | 58 | 44 | 5 | 21 |
We warmly welcome contributions and support from the community! Here's how you can help Garaga grow and improve:
- Spot a bug? Have a feature request? Check out our issues page to see if it's already been reported or to open a new issue.
- Interested in contributing? Please take a moment to read our contribution guidelines for details on how to get started. Your contributions make the open-source community an incredible place for learning, inspiration, and creation.
- Love Garaga? Give us a star on GitHub to show your support.
- Spread the word: Share your excitement about Garaga on social platforms like Twitter, Dev.to, Medium, or your personal blog.
- Join the conversation: Connect with us and other Garaga enthusiasts on our Telegram group.
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!
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.
This project is licensed under the MIT license.
See LICENSE for more information.
- Huge props to tekkac and feltroidprime for their initial work on provable pairing-based cryptography in StarkNet.
- Credits to Nethermind for their initial work on optimized modular arithmetic.
- Herodotus for supporting this project.
- Gnark project and team, especially yelhousni for his amazing knowledge and support.
- OnlyDust and Starkware.
- Craig Costello, Pairing for beginners
- Y. El Housni, "Pairings in Rank-1 Constraint Systems," Cryptology ePrint Archive, Report 2022/1162, 2022. Available: https://eprint.iacr.org/2022/1162.
- feltroidprime. "Faster Extension Field multiplications for Emulated Pairing Circuits." HackMD, https://hackmd.io/@feltroidprime/B1eyHHXNT.
Note: This list is not exhaustive, and is not intended to be.
For a full list of all authors and contributors, see the contributors page.
Thanks goes to these wonderful people (emoji key):
Feltroid Prime 💻 |
Abdel @ StarkWare 💻 |
Tarik K. 💻 |
Bachir Arif 💻 |
Renaud Dubois 💻 |
||
Add your contributions |
This project follows the all-contributors specification. Contributions of any kind welcome!