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

Add is_valid_secp256_signature support #1189

Merged
merged 10 commits into from
Oct 29, 2024

Conversation

ericnordelo
Copy link
Member

Fixes #987

PR Checklist

  • Tests
  • Documentation
  • Added entry to CHANGELOG.md
  • Tried the feature on a public network

Copy link

codecov bot commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.61%. Comparing base (9ad6d13) to head (b763c9f).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
packages/account/src/utils/secp256_point.cairo 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1189      +/-   ##
==========================================
+ Coverage   91.57%   91.61%   +0.03%     
==========================================
  Files          47       47              
  Lines        1223     1228       +5     
==========================================
+ Hits         1120     1125       +5     
  Misses        103      103              
Files with missing lines Coverage Δ
packages/account/src/eth_account.cairo 98.27% <ø> (ø)
packages/account/src/utils.cairo 87.50% <ø> (ø)
packages/account/src/utils/signature.cairo 87.50% <100.00%> (+4.16%) ⬆️
packages/testing/src/constants.cairo 100.00% <100.00%> (ø)
packages/testing/src/signing.cairo 100.00% <100.00%> (ø)
packages/account/src/utils/secp256_point.cairo 81.25% <85.71%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9ad6d13...b763c9f. Read the comment docs.

Copy link
Collaborator

@immrsd immrsd left a comment

Choose a reason for hiding this comment

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

Good job! Left a couple of minor comments


(x.low.into(), xhigh_and_parity)
(x.low.into(), xhigh_and_parity.try_into().unwrap())
Copy link
Collaborator

Choose a reason for hiding this comment

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

parity could be represented by felt252 and x.high can be also converted to felt with into call. This way we could avoid having try_into and unwrap calls. What do you think?

Copy link
Member Author

@ericnordelo ericnordelo Oct 25, 2024

Choose a reason for hiding this comment

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

I tried to avoid it, but since y is a u256, to make parity a felt252 we would also need to .try_into().unwrap() y % 2. But we can make parity a u128 using y.low % 2 and also remove the .try_into().unwrap().

Updated!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking about let parity: felt252 = y.low % 2 == 0 ? 0 : 1. But this solution also works since we've got rid of try_into!

packages/account/src/utils/secp256_point.cairo Outdated Show resolved Hide resolved
packages/account/src/tests/test_signature.cairo Outdated Show resolved Hide resolved
packages/account/src/tests/test_eth_account.cairo Outdated Show resolved Hide resolved
packages/account/src/tests/test_eth_account.cairo Outdated Show resolved Hide resolved
ericnordelo and others added 6 commits October 25, 2024 13:52
Co-authored-by: immrsd <103599616+immrsd@users.noreply.github.com>
Co-authored-by: immrsd <103599616+immrsd@users.noreply.github.com>
Co-authored-by: immrsd <103599616+immrsd@users.noreply.github.com>
Co-authored-by: immrsd <103599616+immrsd@users.noreply.github.com>
…cairo-contracts into feat/secp256r1-support-#987
@ericnordelo ericnordelo requested a review from immrsd October 25, 2024 11:53
Copy link
Collaborator

@immrsd immrsd left a comment

Choose a reason for hiding this comment

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

LGTM

@ericnordelo ericnordelo merged commit 52551a6 into OpenZeppelin:main Oct 29, 2024
8 checks passed
@ericnordelo ericnordelo deleted the feat/secp256r1-support-#987 branch October 29, 2024 16:01
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.

Add support for secp256r1
2 participants