garaga 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of garaga might be problematic. Click here for more details.

garaga-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Keep StarkNet Strange
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
garaga-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,4 @@
1
+ Metadata-Version: 2.1
2
+ Name: garaga
3
+ Version: 0.1.0
4
+ License-File: LICENSE
garaga-0.1.0/README.md ADDED
@@ -0,0 +1,213 @@
1
+ <div align="center">
2
+ <h1>Garaga</h1>
3
+ <img src="docs/images/logo.png" height="200">
4
+ <br />
5
+ <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>
6
+ -
7
+ <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>
8
+ -
9
+ <a href="https://github.com/keep-starknet-strange/garaga/discussions">Ask a Question</a>
10
+ </div>
11
+
12
+ <div align="center">
13
+ <br />
14
+
15
+ [![GitHub Workflow Status](https://github.com/keep-starknet-strange/garaga/actions/workflows/test.yml/badge.svg)](https://github.com/keep-starknet-strange/garaga/actions/workflows/test.yml)
16
+ [![Project license](https://img.shields.io/github/license/keep-starknet-strange/garaga.svg?style=flat-square)](LICENSE)
17
+ [![Pull Requests welcome](https://img.shields.io/badge/PRs-welcome-ff69b4.svg?style=flat-square)](https://github.com/keep-starknet-strange/garaga/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
18
+
19
+ [![Exploration_Team](https://img.shields.io/badge/Exploration_Team-29296E.svg?&style=for-the-badge&logo=data:image/svg%2bxml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJhIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODEgMTgxIj48ZGVmcz48c3R5bGU+LmJ7ZmlsbDojZmZmO308L3N0eWxlPjwvZGVmcz48cGF0aCBjbGFzcz0iYiIgZD0iTTE3Ni43Niw4OC4xOGwtMzYtMzcuNDNjLTEuMzMtMS40OC0zLjQxLTIuMDQtNS4zMS0xLjQybC0xMC42MiwyLjk4LTEyLjk1LDMuNjNoLjc4YzUuMTQtNC41Nyw5LjktOS41NSwxNC4yNS0xNC44OSwxLjY4LTEuNjgsMS44MS0yLjcyLDAtNC4yN0w5Mi40NSwuNzZxLTEuOTQtMS4wNC00LjAxLC4xM2MtMTIuMDQsMTIuNDMtMjMuODMsMjQuNzQtMzYsMzcuNjktMS4yLDEuNDUtMS41LDMuNDQtLjc4LDUuMThsNC4yNywxNi41OGMwLDIuNzIsMS40Miw1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yLjk2LS4wOCw2LjI4LDIuNDYsOC4xNiw0LjI3LDQuMTQsOC4yOSw4LjU1LDEyLjk1LDEyLjk1LDAsMCwxLjMsLjkxLDEuNDIsMi4wN2wtMTMuMzQtMy42M1oiLz48L3N2Zz4=)](https://github.com/keep-starknet-strange)
20
+ </div>
21
+
22
+
23
+ </details>
24
+
25
+ ## About
26
+
27
+ > State-of-the-art Elliptic Curve tooling and SNARKS verification for Cairo & Starknet 🐺.
28
+
29
+ Garaga can enable efficient elliptic curve pairing and scalar multiplication operations on Starknet.
30
+ It achieves state of the art performance by
31
+ - using a dedicated builtin made by Starkware for emulated modular arithmetic
32
+ - using a suite of non-deterministic techniques for extension field multiplication, pairings, and multi scalar multiplication to reduce the number of steps to verifiy results.
33
+
34
+ This is a work in progress, and is not yet ready for production use.
35
+
36
+ Here are some interesting use cases enabled by Garaga:
37
+ - SNARKs on StarkNet: Groth16 and Plonk (in the near future).
38
+ - KZG cryptographic commitment scheme.
39
+ - Identity-based encryption schemes.
40
+ - Attribute-based encryption schemes.
41
+ - BLS (Boneh–Lynn–Shacham) Digital Signature scheme.
42
+
43
+
44
+ ## Architecture overview (in progress.)
45
+
46
+
47
+
48
+ Garaga consists of a Pythonic backend and CairoZero / Starknet interfaces.
49
+ - The Pythonic backend is here to define emulated modular arithmetic circuits that can be compiled to Cairo or Cairo1 code.
50
+ It also handles witnesses generation for the non-deterministic computations.
51
+ - 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, etc).
52
+
53
+
54
+ ## Getting Started
55
+
56
+ To get started with Garaga, you'll need to have some tools and dependencies installed. Here's everything you need:
57
+
58
+ ### Prerequisites
59
+
60
+ Ensure you have the following installed:
61
+ - [Python 3.10](https://www.python.org/downloads/) - The core language used for development.
62
+ - [Go](https://golang.org/doc/install) - Required for profiling and testing.
63
+ - [pprof](https://github.com/google/pprof) - A tool for visualization and analysis of profiling data.
64
+ - [graphviz](https://graphviz.org/download/) - Necessary for generating graphical representations of profiling data.
65
+ - A functional [SageMath](https://www.sagemath.org/download.html) installation or an operational [Docker](https://www.docker.com/get-started/) daemon with non-sudo privileges.
66
+
67
+ ### Setup
68
+
69
+ 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.
70
+
71
+
72
+ ```bash
73
+ make setup
74
+ ```
75
+
76
+ 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`.
77
+ ### Compile & Run .cairo files (interactive script!)
78
+
79
+ ```bash
80
+ make run
81
+ ```
82
+
83
+ ## Benchmarks
84
+
85
+
86
+
87
+ | OP | Weight in steps | Comment |
88
+ |------------------|-------------------|-----------------------------------------------------------------------------------------|
89
+ | MULMOD | 8 | Equivalent cost of a*b % p with the modulo builtin in VM steps |
90
+ | ADDMOD | 4 | Equivalent cost of a+b % p with the modulo builtin in VM steps |
91
+ | ASSERT_EQ | 2 | Equivalent cost of a==b % p with the modulo builtin in VM steps |
92
+ | RLC | 28 | Cost of writing a field element to the value segment and retrieving random coefficients |
93
+ | POSEIDON 3 LIMBS | 14 | Cost of hashing the first 3 limbs of 384 bits emulated field element with Poseidon |
94
+ | POSEIDON 4 LIMBS | 17 | Cost of hashing the 4 limbs of 384 bits emulated field element with Poseidon |
95
+
96
+
97
+ | circuit | MULMOD | ADDMOD | ASSERT_EQ | POSEIDON | RLC | ~steps |
98
+ |-------------------------------------------|----------|----------|-------------|------------|-------|----------|
99
+ | Derive Point From X | 6 | 2 | 0 | 0 | 0 | 56 |
100
+ | Fp6 SQUARE_TORUS | 12 | 22 | 0 | 7 | 1 | 324 |
101
+ | Fp12 SQUARE | 25 | 11 | 0 | 13 | 1 | 480 |
102
+ | Fp12 MUL | 36 | 22 | 0 | 13 | 1 | 612 |
103
+ | Fp6 MUL_TORUS | 36 | 34 | 0 | 13 | 2 | 688 |
104
+ | MSM 1 points | 150 | 128 | 0 | 52 | 0 | 2544 |
105
+ | MSM 2 points | 194 | 166 | 0 | 64 | 0 | 3240 |
106
+ | MSM 3 points | 238 | 204 | 0 | 76 | 0 | 3936 |
107
+ | MSM 10 points | 546 | 470 | 0 | 160 | 0 | 8808 |
108
+ | MSM 50 points | 2306 | 1990 | 0 | 640 | 0 | 36648 |
109
+ | Miller n=1 BLS12_381 | 2672 | 2686 | 137 | 790 | 63 | 47588 |
110
+ | Miller n=1 BN254 | 3303 | 3228 | 177 | 828 | 66 | 53130 |
111
+ | Miller n=2 BLS12_381 | 4418 | 4525 | 273 | 812 | 63 | 69558 |
112
+ | Miller n=2 BN254 | 5639 | 5576 | 353 | 852 | 66 | 81898 |
113
+ | Miller n=3 BLS12_381 | 6164 | 6364 | 409 | 834 | 63 | 91528 |
114
+ | Final Exp BN254 | 4681 | 7218 | 3 | 1931 | 317 | 102236 |
115
+ | Miller n=3 BN254 | 7975 | 7924 | 529 | 876 | 66 | 110666 |
116
+ | Final Exp BLS12_381 | 5123 | 9056 | 3 | 2333 | 384 | 127627 |
117
+ | MultiPairing n=1 BN254 | 7984 | 10446 | 180 | 2759 | 383 | 155366 |
118
+ | MultiPairing n=1 BLS12_381 | 7795 | 11742 | 140 | 3123 | 447 | 175215 |
119
+ | MultiPairing n=2 BN254 | 10320 | 12794 | 356 | 2783 | 383 | 184134 |
120
+ | MultiPairing n=2 BLS12_381 | 9541 | 13581 | 276 | 3145 | 447 | 197185 |
121
+ | MultiPairing n=3 BN254 | 12656 | 15142 | 532 | 2807 | 383 | 212902 |
122
+ | MultiPairing n=3 BLS12_381 | 11287 | 15420 | 412 | 3167 | 447 | 219155 |
123
+ | BLS12FinalExp Fp12 Karabina No EXTF Trick | 7774 | 43002 | 0 | 0 | 0 | 234200 |
124
+
125
+ ## Support & How to Contribute
126
+
127
+ We warmly welcome contributions and support from the community! Here's how you can help Garaga grow and improve:
128
+
129
+ ### Reporting Issues & Requesting Features
130
+
131
+ - **Spot a bug? Have a feature request?** Check out our [issues page](https://github.com/keep-starknet-strange/garaga/issues) to see if it's already been reported or to open a new issue.
132
+
133
+ ### Contributing to Garaga
134
+
135
+ - **Interested in contributing?** Please take a moment to read our [contribution guidelines](docs/CONTRIBUTING.md) for details on how to get started. Your contributions make the open-source community an incredible place for learning, inspiration, and creation.
136
+
137
+ ### Showing Support
138
+
139
+ - **Love Garaga?** Give us a [star on GitHub](https://github.com/keep-starknet-strange/garaga) to show your support.
140
+ - **Spread the word:** Share your excitement about Garaga on social platforms like Twitter, [Dev.to](https://dev.to/), [Medium](https://medium.com/), or your personal blog.
141
+ - **Join the conversation:** Connect with us and other Garaga enthusiasts on our [Telegram group](https://t.me/GaragaPairingCairo).
142
+
143
+ 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!
144
+
145
+
146
+ ## Security
147
+
148
+ Garaga follows good practices of security, but 100% security cannot be assured.
149
+ Garaga is provided **"as is"** without any **warranty**. Use at your own risk.
150
+
151
+ _For more information and to report security issues, please refer to our
152
+ [security documentation](docs/SECURITY.md)._
153
+
154
+ ## License
155
+
156
+ This project is licensed under the **MIT license**.
157
+
158
+ See [LICENSE](LICENSE) for more information.
159
+
160
+ ## Acknowledgements
161
+
162
+ - Huge props to [tekkac](https://github.com/tekkac) and [feltroidprime](https://github.com/feltroidprime) for their initial work on provable pairing-based cryptography in StarkNet.
163
+ - Credits to [Nethermind](https://github.com/NethermindEth/) for their [initial work on optimized modular arithmetic](https://github.com/NethermindEth/research-basic-Cairo-operations-big-integers/tree/main/lib).
164
+ - [Herodotus](https://www.herodotus.dev/) for supporting this project.
165
+ - [Gnark project](https://github.com/ConsenSys/gnark-crypto) and team, especially [yelhousni](https://github.com/yelhousni) for his amazing knowledge and support.
166
+ - [OnlyDust](https://www.onlydust.xyz/) and [Starkware](https://starkware.co/).
167
+ - Liam Eagen and Andrija Novakovic for their support and amazing research.
168
+ ## Resources
169
+ - Craig Costello, [Pairing for beginners](https://static1.squarespace.com/static/5fdbb09f31d71c1227082339/t/5ff394720493bd28278889c6/1609798774687/PairingsForBeginners.pdf)
170
+ - Y. El Housni, "Pairings in Rank-1 Constraint Systems," Cryptology ePrint Archive, Report 2022/1162, 2022. Available: [https://eprint.iacr.org/2022/1162](https://eprint.iacr.org/2022/1162).
171
+ - feltroidprime. "Faster Extension Field multiplications for Emulated Pairing Circuits." HackMD, [https://hackmd.io/@feltroidprime/B1eyHHXNT](https://hackmd.io/@feltroidprime/B1eyHHXNT).
172
+ - Liam Eagen, "Zero Knowledge Proofs of Elliptic Curve Inner Products from Principal Divisors and Weil Reciprocity," Cryptology ePrint Archive, Report 2022/596, 2022. Available: [https://eprint.iacr.org/2022/596](https://eprint.iacr.org/2022/596)
173
+ - Andrija Novakovic and Liam Eagen, "On Proving Pairings," Cryptology ePrint Archive, Paper 2024/640, 2024. Available: [https://eprint.iacr.org/2024/640](https://eprint.iacr.org/2024/640)
174
+
175
+ > **Note:** This list is not exhaustive, and is not intended to be.
176
+
177
+
178
+ ## Contributors
179
+ For a full list of all authors and contributors, see
180
+ [the contributors page](https://github.com/keep-starknet-strange/garaga/contributors).
181
+
182
+ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
183
+
184
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
185
+ <!-- prettier-ignore-start -->
186
+ <!-- markdownlint-disable -->
187
+ <table>
188
+ <tbody>
189
+ <tr>
190
+ <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>
191
+ <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>
192
+ <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>
193
+ <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>
194
+ <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>
195
+ </tr>
196
+ </tbody>
197
+ <tfoot>
198
+ <tr>
199
+ <td align="center" size="13px" colspan="7">
200
+ <img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg">
201
+ <a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a>
202
+ </img>
203
+ </td>
204
+ </tr>
205
+ </tfoot>
206
+ </table>
207
+
208
+ <!-- markdownlint-restore -->
209
+ <!-- prettier-ignore-end -->
210
+
211
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
212
+
213
+ This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
@@ -0,0 +1,12 @@
1
+ [project]
2
+ name = "garaga"
3
+ version = "0.1.0"
4
+
5
+
6
+ [tool.isort]
7
+ profile = "black"
8
+
9
+ [tool.autoflake]
10
+ in_place = true
11
+ remove_unused_variables = true
12
+ remove_all_unused_imports = true
garaga-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ Metadata-Version: 2.1
2
+ Name: garaga
3
+ Version: 0.1.0
4
+ License-File: LICENSE
@@ -0,0 +1,7 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/garaga.egg-info/PKG-INFO
5
+ src/garaga.egg-info/SOURCES.txt
6
+ src/garaga.egg-info/dependency_links.txt
7
+ src/garaga.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ cairo
2
+ fustat
3
+ precompiled_circuits