-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ZIR-181: Add Elliptic Curve BigInt circuits #41
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…stant and avoid dynamic allocations
Mostly for 'must panic' tests
github-actions
bot
changed the title
Add Elliptic Curve BigInt circuits
ZIR-181: Add Elliptic Curve BigInt circuits
Sep 24, 2024
shkoo
approved these changes
Sep 25, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't speak to the math stuff, but the rest looks good!
Commit rebased with updated message to mollify GitHub signed commit verifier
tzerrell
force-pushed
the
tzerrell/bigint-ec-mul
branch
from
October 2, 2024 20:13
0e26472
to
e774c4a
Compare
(I force-pushed the last few commits to mollify the verified-commit checker. No changes to the code in these new commits) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds Elliptic Curve functions/ZKRs based on the BigInt dialect, with operations for verifying add/sub/neg/mul/double plus point equality and verifying point on curve. Includes curve parameters for secp256k1 as well as a tiny custom curve for testing purposes.
This represents curves as Weierstrass curves and points in affine coordinates. This is good for fast computations in our particular case, but does preclude representing the zero point or calculations involving it, causing some minor incompleteness (which is typically cryptographically irrelevant). Due to the lack of control flow in the recursion circuit, this is slightly more incomplete than similar systems, particularly in multiply, where if a zero would be computed when multiplying by a scalar that differs from the actual scalar by a single bit, then the multiply can't go through (as both branches are computed and combined during the double-and-add algorithm). An alternative approach using an arbitrary offset point would allow people to avoid this problem in specific cases (by choosing a different arbitrary offset point), although the general problem would still exist (it's just in different places depending on the offset), and in that implementation this arbitrary offset must be provided to all multiplies, which did not seem like the best tradeoffs to me.
This produces a lot of ZKRs for unit testing. This can make compile/testing time a bit slow -- I've tried to trim them to achieve a good balance of testing perf & coverage, but I'm definitely open to suggestions for improvement here.
This includes @shkoo's work making compile times faster through BigInt macros (7b2e4bf)
Developed in conjunction with risc0/risc0#2371, which includes a test suite.