Skip to content

perf(ecdsa): JoinScalarMulBase avoids 0 edge-cases #661

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

Merged
merged 1 commit into from
Apr 28, 2023
Merged

Conversation

yelhousni
Copy link
Contributor

@yelhousni yelhousni commented Apr 26, 2023

In ECDSA verification (or ECRecover), we compute [r/s]pubKey + [h/s]g where (r,s) is the signature, h the hash of the message and g the canonical generator of the subgroup. Previously, we took into consideration the edge cases where either or both r and h can be 0 and also pubKey=(0,0), but the EYP rules out these:

  • s ≠ 0 and r ≠ 0

image

  • pubKey ≠ (0,0) (because private key ≠ 0)

image

The PR introduces the JointScalarMulBase method which performs [s1]p1 + [s2]g assuming that s1 and s2 are nonzero and p1 not the infinity (0,0). This saves ~17k constraints in ECDSA verifier gadget.

@yelhousni yelhousni added this to the v0.9.0 milestone Apr 26, 2023
@yelhousni yelhousni requested a review from ivokub April 26, 2023 11:04
Copy link
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

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

Looks good!

@yelhousni yelhousni merged commit e9ff34a into develop Apr 28, 2023
@yelhousni yelhousni deleted the perf/ecdsa branch April 28, 2023 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants