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

Update EIP-7212: Clarifications and improvements #7676

Merged
merged 7 commits into from
Oct 6, 2023

Conversation

nalinbhardwaj
Copy link
Contributor

@nalinbhardwaj nalinbhardwaj commented Sep 9, 2023

(in order of importance)

  • specify "Required Checks in Verification" more precisely
  • Malleability is removed from the spec
  • make choice of verification vs. recovery clearer

(in order of importance)
- specify "Required Checks in Verification" more precisely
- make choice of verification vs. recovery clearer
- todo add links to implementation
- one ??? that i didn't understand
@github-actions github-actions bot added c-update Modifies an existing proposal s-review This EIP is in Review t-core labels Sep 9, 2023
@eth-bot
Copy link
Collaborator

eth-bot commented Sep 9, 2023

✅ All reviewers have approved.

@eth-bot eth-bot changed the title Update EIP 7212: Clarifications and improvements Update EIP-7212: Clarifications and improvements Sep 9, 2023
@eth-bot eth-bot added the a-review Waiting on author to review label Sep 9, 2023
EIPS/eip-7212.md Outdated Show resolved Hide resolved
EIPS/eip-7212.md Outdated
- Verify that s is equal to or less than half of the order of the subgroup to prevent signature malleability.
- Verify that the point formed by (`x`, `y`) values is on the curve and both components are in between 0 and the `p` value of the curve.
- Verify that `r` and `s` values are valid scalar field elements, i.e. they are in `(0, n)` (exclusive) where `n` is the order of the subgroup.
- Verify that `s <= n // 2`, where `n` is the order of the subgroup to prevent signature malleability.
Copy link
Contributor Author

@nalinbhardwaj nalinbhardwaj Sep 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually suggest that this be deleted from this EIP to match compatibility exactly with the NIST specs which does not require this. In particular, if I understand correctly, at the moment a valid Implementation of P256 signing according to the NIST spec can fail this verifier. This would not be ideal for the purpose of this precompile.

It is anyway relatively straightforward/cheap to add these checks separately in EVM byte code if a contract implementation does want them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I respect the idea of having compatibility between the standard and precompiled contract implementation, but I think that if we remove the malleability check, most of the applications using this code will require additional storage and checks. As in ecrecover, the malleability issue is not in the standards, but implemented in the precompiled contract. Is there any case which we need malleable signatures?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/daimo-eth/daimo as an example application uses this precompile with AA wallets and does not require non-malleability (since nonces/userops are unique).

The case that strongly concerns me is that making this check inside the precompile means we would disagree from the NIST spec, and by extension signatures that by default are marked as valid by the most popular P256 implementations like subtlecrypto and noble and all the test suites like wycheproof will be marked as invalid. Further there could exist device secure enclave’s that return signatures marked as invalid unless the user first runs a transform on them. This would be really confusing for users and annoying for implementation devs, and seems like unnecessary complexity.

Also, adding this check seperately as-needed in some sort of wrapper contract would not require any extra storage. As far as computation cost goes, users are likely to be calling a hash function before calling this precompile anyway, so the cost of one comparison seems trivial compared to that.

Overall, I think the point of this precompile should be to be able to onboard popular implementations to Ethereum (that all follow the NIST spec), so we should match the spec. If you would like, we can add an example usage or note to the EIP where we emphasise the malleability.

@github-actions github-actions bot added the w-ci Waiting on CI to pass label Sep 9, 2023
EIPS/eip-7212.md Outdated Show resolved Hide resolved
@github-actions github-actions bot added w-ci Waiting on CI to pass and removed w-ci Waiting on CI to pass labels Sep 10, 2023
@github-actions github-actions bot removed the w-ci Waiting on CI to pass label Sep 23, 2023
@github-actions github-actions bot added the w-ci Waiting on CI to pass label Sep 23, 2023
@nalinbhardwaj nalinbhardwaj force-pushed the nibnalin/eip-7212 branch 2 times, most recently from 7cb196f to 3254091 Compare September 23, 2023 21:12
@github-actions github-actions bot added w-ci Waiting on CI to pass and removed w-ci Waiting on CI to pass labels Sep 23, 2023
@github-actions github-actions bot removed the w-ci Waiting on CI to pass label Sep 23, 2023
@github-actions
Copy link

The commit 93d855d (as a parent of a3558d7) contains errors.
Please inspect the Run Summary for details.

@github-actions github-actions bot added the w-ci Waiting on CI to pass label Sep 23, 2023
@nalinbhardwaj nalinbhardwaj marked this pull request as ready for review October 5, 2023 23:25
@github-actions github-actions bot removed the w-ci Waiting on CI to pass label Oct 5, 2023
@eth-bot eth-bot enabled auto-merge (squash) October 6, 2023 01:10
Copy link
Collaborator

@eth-bot eth-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All Reviewers Have Approved; Performing Automatic Merge...

@eth-bot eth-bot merged commit d5373e9 into ethereum:master Oct 6, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-review Waiting on author to review c-update Modifies an existing proposal s-review This EIP is in Review t-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants