garaga 0.18.2
State-of-the-art Elliptic Curve operations and SNARKS verification for Cairo & Starknet
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:
Garaga consists of a Pythonic backend with Rust bindings and CairoZero / Cairo libraries.
Currently, only Groth16 on BN254 and BLS12_381 is supported with automatic support for json files coming from SnarkJS and Gnark.
pip install garaga
. Python3.10 is mandatory and a virtual environment is recommended. Enter garaga
in your terminal to get started.
garaga gen
command in your terminal to generate the code for the SNARK verifier given your verification key.
.secrets
following the .secrets.template
file in the root of this repository, containing the Starkner RPC url, your account address, and the private key.
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.
garaga deploy
command in your terminal using the class hash obtained in the previous step to get the contract address.
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.
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:
python3.10
is a valid command in your terminal. The core language used for development. Make sure you have the correct dependencies installed (in particular, GMP) for the fastecdsa
python package. See here for linux and here for macos.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
.
π 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.
contracts βββ groth16_example_bls12_381_integrationtest::test_contract Test Name Steps Range Check Range Check 96 Poseidon Add Mod Mul Mod Sierra Gas test_verify_groth16_proof_bls12_381 245,251 12,083 61,344 597 5,325 7,504 34,856,467 βββ groth16_example_bn254_integrationtest::test_contract Test Name Steps Range Check Range Check 96 Poseidon Add Mod Mul Mod Sierra Gas test_verify_groth16_proof_bn254 251,542 11,215 75,704 681 6,341 9,662 37,807,323 βββ noir_ultra_keccak_honk_example_integrationtest::test_contract Test Name Steps Range Check Range Check 96 Bitwise Poseidon Add Mod Mul Mod Sierra Gas test_verify_ultra_keccak_honk_proof 1,300,439 68,874 412,841 3,180 608 45,756 43,622 197,008,212 βββ noir_ultra_keccak_zk_honk_example_integrationtest::test_contract Test Name Steps Range Check Range Check 96 Bitwise Poseidon Add Mod Mul Mod Sierra Gas test_verify_ultra_keccak_zk_honk_proof 1,399,701 73,900 451,836 3,476 608 49,914 48,030 213,261,292 βββ noir_ultra_starknet_honk_example_integrationtest::test_contract Test Name Steps Range Check Range Check 96 Poseidon Add Mod Mul Mod Sierra Gas test_verify_ultra_starknet_honk_proof 1,166,626 61,827 412,707 1,139 45,742 43,606 181,520,015 βββ noir_ultra_starknet_zk_honk_example_integrationtest::test_contract Test Name Steps Range Check Range Check 96 Poseidon Add Mod Mul Mod Sierra Gas test_verify_ultra_starknet_zk_honk_proof 1,262,593 66,624 451,761 1,191 49,911 48,024 197,292,403 βββ risc0_verifier_bn254_integrationtest::test_contract Test Name Steps Range Check Range Check 96 Bitwise Poseidon Add Mod Mul Mod Sierra Gas test_verify_r0_groth16_proof_bn254 290,849 14,593 91,204 6,698 681 8,151 11,240 48,116,829 βββ sp1_verifier_bn254_integrationtest::test_contract Test Name Steps Range Check Range Check 96 Bitwise Poseidon Add Mod Mul Mod Sierra Gas test_verify_sp1_groth16_proof_bn254 269,236 13,584 91,460 2,230 681 8,167 11,264 43,312,567 garaga βββ crypto::mmr::tests Test Name Steps Range Check Sierra Gas test_trailing_ones 549 62 59,240 βββ ec::ec_ops_g2::tests Test Name Steps Range Check Range Check 96 Add Mod Mul Mod Sierra Gas test_ec_mul_g2 122,500 1,075 93,069 8,793 10,239 25,743,860 βββ hashes::poseidon_bn254::tests Test Name Steps Range Check Range Check 96 Add Mod Mul Mod Sierra Gas test_run_poseidon_grumpkin_circuit_1 16,108 328 6,393 353 919 2,628,034 βββ tests β βββ autogenerated β β βββ ecdsa_tests Test Name Steps Range Check Range Check 96 Add Mod Mul Mod Sierra Gas test_ecdsa_SECP256R1 16,574 1,074 20,022 2,367 2,184 4,717,358 test_ecdsa_SECP256K1 21,452 2,084 15,629 1,810 1,592 4,544,172 β β βββ eddsa_tests Test Name Steps Range Check Range Check 96 Bitwise Add Mod Mul Mod Sierra Gas test_eddsa_32_64B 100,238 14,068 20,418 3,288 2,388 2,236 15,968,656 test_eddsa_16_32B 59,460 7,748 20,496 1,656 2,394 2,244 10,507,580 test_eddsa_0_0B 58,375 7,686 20,521 1,656 2,395 2,246 10,397,578 β β βββ msm_tests Test Name Steps Range Check Range Check 96 Add Mod Mul Mod Sierra Gas test_msm_SECP256R1_3P 23,742 1,577 29,835 3,546 3,252 6,935,138 test_msm_SECP256K1_3P 30,945 3,088 23,194 2,707 2,359 6,656,970 test_msm_SECP256R1_2P 15,910 1,054 19,865 2,363 2,166 4,628,974 test_msm_SECP256K1_2P 20,601 2,062 15,369 1,799 1,564 4,423,530 test_msm_SECP256R1_1P 8,262 531 9,945 1,182 1,084 2,346,886 test_msm_SECP256K1_1P 10,621 1,038 7,697 900 783 2,245,724 β β βββ pairing_tests Test Name Steps Range Check Range Check 96 Poseidon Add Mod Mul Mod Sierra Gas test_BN254_mpcheck_3P_2F_with_extra_miller_loop_result 77,448 574 59,838 681 4,505 8,043 17,364,401 test_BLS12_381_mpcheck_3P_2F_with_extra_miller_loop_result 65,720 368 45,634 597 3,501 5,901 13,815,825 test_BN254_mpcheck_2P_2F 61,456 462 33,232 607 1,731 4,702 11,575,107 test_BLS12_381_mpcheck_2P_2F 53,498 309 25,204 544 1,397 3,354 9,397,084 β β βββ schnorr_tests Test Name Steps Range Check Range Check 96 Add Mod Mul Mod Sierra Gas test_schnorr_SECP256K1 21,009 2,083 15,512 1,808 1,580 4,485,542 β β βββ tower_pairing_tests Test Name Steps Range Check Range Check 96 Add Mod Mul Mod Sierra Gas test_tower_pairing_BN254_3P 298,906 622 626,255 94,555 50,514 117,262,526 test_tower_pairing_BLS12_381_3P 268,002 812 544,901 87,847 37,874 100,452,202 test_tower_pairing_BN254_2P 244,049 546 486,548 73,494 38,661 91,944,672 test_tower_pairing_BLS12_381_2P 222,511 749 429,096 69,571 28,951 79,820,640 test_tower_pairing_BN254_1P 189,192 470 346,841 52,433 26,808 66,626,818 test_tower_pairing_BLS12_381_1P 177,020 686 313,291 51,295 20,028 59,189,078 test_tower_final_exp_BN254 134,382 394 207,134 31,372 14,955 41,313,664 test_tower_final_exp_BLS12_381 131,576 623 197,486 33,019 11,105 38,562,216 β βββ calldata_tests Test Name Steps Range Check Sierra Gas test_deserialize_full_proof_with_hints_bls12_381 63,341 5,339 6,707,830 β βββ sha512_tests Test Name Steps Range Check Bitwise Sierra Gas test_sha512_lorem_ipsum 115,350 18,467 4,904 15,686,722 test_size_zero 43,353 6,605 1,640 5,753,770 test_sha512_size_one 43,330 6,603 1,640 5,751,330 βββ utils β βββ drand::tests Test Name Steps Range Check Range Check 96 Bitwise Add Mod Mul Mod Sierra Gas test_decrypt_at_round 317,522 4,183 397,265 14,506 59,198 29,332 94,080,916 test_hash_to_curve 29,589 1,007 4,559 12,289 422 602 10,909,849 test_hash_to_two_bls_felts 25,468 936 74 12,289 2 8 9,786,243 test_isogeny 2,938 59 878 0 51 111 425,872 test_map_to_curve 729 12 264 0 6 39 113,460 test_drand_quicknet_public_key 307 4 158 0 14 17 53,316 β βββ neg_3::tests Test Name Steps Range Check Sierra Gas test_scalar_to_epns 6,904 929 755,430 test_scalar_to_epns_single 2,215 298 242,360 β βββ noir β β βββ honk_transcript::tests Test Name Steps Range Check Bitwise Poseidon Sierra Gas test_transcript_keccak 91,992 8,282 3,180 1 11,633,371 test_transcript_starknet 24,448 1,397 0 532 2,803,802 β β βββ zk_honk_transcript::tests Test Name Steps Range Check Bitwise Poseidon Sierra Gas test_zk_transcript_keccak 94,677 8,626 3,476 1 12,098,519 test_zk_transcript_starknet 26,179 1,507 0 584 3,010,134 β βββ risc0::risc0_utils_tests Test Name Steps Range Check Bitwise Sierra Gas test_receipt_claim 12,239 448 5,591 4,514,813 test_output_digest 4,896 179 2,230 1,802,220 β βββ sp1::tests Test Name Steps Range Check Sierra Gas test_convert_u32_to_u128 80 4 8,280π To regenerate these benchmarks: Run make profile-test
from the project root.
We warmly welcome contributions and support from the community! Here's how you can help Garaga grow and improve:
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.
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 PrimeThis project follows the all-contributors specification. Contributions of any kind welcome!
Version 0.18.2
Uploaded 1Β week ago
Size 10.7Β MB
Run the following command in your project dir
scarb add garaga@0.18.2
Or add the following line to your Scarb.toml
garaga = "0.18.2"