This repository was archived by the owner on Apr 18, 2025. It is now read-only.
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.
Description
EVM behaviour is as follows:
is_success == false
is_success == false
G1::identity
(with random valid G2) then skip pair while computing miller loopG2::identity
(with random valid G1) then skip pair while computing miller loopBefore PR
Before this PR, the inputs to the ECC Circuit were possibly different from the inputs to EVM. Specifically, in the case where
(G1::identity, G2::identity)
were input to EVM, we replaced them with(G1::identity, G2::generator)
for the ECC Circuit.The problem with this approach:
We were struggling to handle valid vs invalid inputs. The case where
(G1::identity, G2::random)
or(G1::random, G2::identity)
was not coveredAfter PR
The Ecc Circuit now handles the exact same input as provided to EVM. There is no "swapping" of inputs. The padded pair (to make 4 pairs) is also
(G1::identity, G2::identity)
.We use several conditions to appropriately pass
pairs
to the multi miller loop algorithm, so that we avoid panic in all cases.is_zero_pair
covers:G1: (0, 0)
andG2: random valid
G2: (0, 0, 0, 0)
andG1: random valid
are_pairs_zero
represents whether all pairs satisfyis_zero_pair
(G1::random, G2::random)
pairing_check == false
multi_miller_loop
would panicpairing_check == false
ifis_valid == false
G1: (0, 0)
andG2: random valid
orG2: (0, 0, 0, 0)
andG1: random valid
then(G1::identity, G2::generator)
are_pairs_zero == true
thenpairing_check == 1
althoughmulti_miller_loop
panicsIssue Link
Closes #868
Type of change