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

Fix: apply low-s s flips also to v on ecdsa signature shares combination #750

Merged
merged 2 commits into from
Dec 30, 2024

Conversation

FedericoAmura
Copy link
Contributor

@FedericoAmura FedericoAmura commented Dec 27, 2024

Description

This PR corrects the low-s rule by linking the s flips with the v value when combining ecdsa signatures

When the multiple shares are combined and the final signature created, if the s value is in the top half of the curve order, then it is flipped. However that flip also had to flip the v value. With the changes in this PR now we are doing that v flip
The signature was always valid as it is composed of the (r,s) tuple without caring of which s value (positive or negative) was used. But, when trying to recover the public key or address of the signer, we need the correct v value and having it unlinked from the s flips created a situation where a signature could recover a wrong public address unless the consumer knows the result already and fixes the v value itself

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Updated unit tests
  • Locally by running a script with 100 pkpSign operations and validating the recovered address agains the used pkp one

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Ansonhkg Ansonhkg merged commit 498ce42 into master Dec 30, 2024
5 checks passed
@Ansonhkg Ansonhkg deleted the feature/escal-11-pkp-address-derivation-issue branch December 30, 2024 15:38
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.

3 participants