Add additional check to avoid infinite loop #61
Merged
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.
Issue:
If we call
ecZZ_mulmuladd_S_asm( -Gx, -Gy, 1, 1)
then the current implementation hangs indefinitely in the for loop:FreshCryptoLib/solidity/src/FCL_elliptic.sol
Lines 369 to 372 in 027cb87
This occurs because the method currently checks for
u == 0 and v ==0
before determiningif((H0==0)&&(H1==0))
. With coordinates-Gx
and-Gy
, this check is true which results in bothu
andv
being set to 0. Then the loop referenced above searches for the MSB of 0.Fix:
We can easily address this by re-checking if
u == v == 0
and returning early inside this specific condition.