Skip to content
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

Right pad incomplete point inputs for eip-196 #191

Merged

Conversation

garyschulte
Copy link
Contributor

In the gnark-crypto implementation of eip-196, incomplete scalar inputs are already right padded with zero. However, points also require this treatment.

  • in g1Add, right pad p0 and p1 points with zero if they are not the full 32 bytes
  • in g1Mul, right pad p0 point if it is not 32 bytes and check to see if the resulting point is in the field before returning 0

from eip-196 spec:

For both precompiled contracts, if the input is shorter than expected, it is assumed to be virtually padded with zeros at the end (i.e. compatible with the semantics of the CALLDATALOAD opcode). If the input is longer than expected, surplus bytes at the end are ignored.

@garyschulte garyschulte force-pushed the bugfix/eip-196-input-padding branch 2 times, most recently from 05f7a53 to 08711d2 Compare July 16, 2024 20:26
Signed-off-by: garyschulte <garyschulte@gmail.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
@garyschulte garyschulte enabled auto-merge (squash) July 17, 2024 16:12
@garyschulte garyschulte merged commit b3f1e6b into hyperledger:main Jul 17, 2024
11 checks passed
@garyschulte garyschulte deleted the bugfix/eip-196-input-padding branch July 17, 2024 16:44
@garyschulte garyschulte mentioned this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants