-
Notifications
You must be signed in to change notification settings - Fork 268
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
chore!: change ec_add to unsafe implementation (but much better perf) #8374
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
af52e3d
change ec_add to unsafe implementation (but much better perf)
guipublic 7602e38
Merge branch 'master' into gd/unsafe_ec_add
guipublic 5ee3307
Merge branch 'master' into gd/unsafe_ec_add
guipublic a7a54e1
Merge branch 'master' into gd/unsafe_ec_add
guipublic 48edb7d
Merge branch 'master' into gd/unsafe_ec_add
guipublic 2fbb666
Merge branch 'master' into gd/unsafe_ec_add
guipublic ccfcaac
Merge branch 'master' into gd/unsafe_ec_add
TomAFrench 43f6a23
Merge branch 'master' into gd/unsafe_ec_add
guipublic 096b2ee
Merge branch 'master' into gd/unsafe_ec_add
guipublic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,17 @@ bb::stdlib::cycle_group<Builder> to_grumpkin_point(const WitnessOrConstant<FF>& | |
bool has_valid_witness_assignments, | ||
Builder& builder) | ||
{ | ||
using bool_ct = bb::stdlib::bool_t<Builder>; | ||
auto point_x = to_field_ct(input_x, builder); | ||
auto point_y = to_field_ct(input_y, builder); | ||
auto infinite = bool_ct(to_field_ct(input_infinite, builder)); | ||
// We assume input_infinite is boolean, so we do not add a boolean gate | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pedantic point: if |
||
bool_t infinite(&builder); | ||
if (!input_infinite.is_constant) { | ||
infinite.witness_index = input_infinite.index; | ||
infinite.witness_bool = get_value(input_infinite, builder) == FF::one(); | ||
} else { | ||
infinite.witness_index = IS_CONSTANT; | ||
infinite.witness_bool = input_infinite.value == FF::one(); | ||
} | ||
|
||
// When we do not have the witness assignments, we set is_infinite value to true if it is not constant | ||
// else default values would give a point which is not on the curve and this will fail verification | ||
|
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
Oops, something went wrong.
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.
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.
From this comment it looks like the ACIR representation of an ecc point doesn't allow for a point at infinity?
What happens if I have two constant points,
A
andB
whereA = -B
, and I computeA+B
in noir? Is the compiler clever enough to return a point at infinity, or will the compiler cause the current code path (i.e.acir_format::create_ec_add_constraint
) to be executed?If it's the latter then I think it's better if we throw an error for the case where
infinite.is_constant()
is triggered, because the alternative is weird undefined behavior. If we're planning to fix the ACIR serialization in the near term we can skip, but if we forget about this issue it will cause us problems in the future because, if I understand correctly, the current implementation produces either undefined behavior or underconstrained code (i.e. the case where we add a constant point with its inverse)