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

change: Refactor & optimize the NAF #63

Merged
merged 7 commits into from
Apr 25, 2023
Merged

change: Refactor & optimize the NAF #63

merged 7 commits into from
Apr 25, 2023

Conversation

upbqdn
Copy link
Member

@upbqdn upbqdn commented Apr 24, 2023

Motivation

Close ZcashFoundation/zebra#6341.

Solution

This PR:

  • Makes the NAF function generic and removes the two curve-specific implementations.
  • Uses the appropriate NAF length for the individual curves, which reduces loop iterations in multiplication.
  • Tests NAF invariants that result from the NAF definition.
  • Tests that it's possible to reconstruct the original scalar from its NAF.

@upbqdn upbqdn self-assigned this Apr 24, 2023
@upbqdn upbqdn added rust Pull requests that update Rust code C-audit Category: Issues arising from audit findings labels Apr 24, 2023
conradoplg
conradoplg previously approved these changes Apr 24, 2023
Copy link
Contributor

@conradoplg conradoplg left a comment

Choose a reason for hiding this comment

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

Looks great, thanks! Added a suggestion to simplify one part

src/scalar_mul/tests.rs Show resolved Hide resolved
src/scalar_mul.rs Show resolved Hide resolved
Co-authored-by: Conrado Gouvea <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2023

Codecov Report

Merging #63 (f52607e) into main (c31c5c4) will increase coverage by 0.24%.
The diff coverage is 87.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #63      +/-   ##
==========================================
+ Coverage   84.30%   84.55%   +0.24%     
==========================================
  Files          12       12              
  Lines         720      764      +44     
==========================================
+ Hits          607      646      +39     
- Misses        113      118       +5     

Copy link
Contributor

@conradoplg conradoplg 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, apologies for the rework!

@conradoplg conradoplg merged commit 4f8ce48 into main Apr 25, 2023
@conradoplg conradoplg deleted the make-NAF-generic branch April 25, 2023 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-audit Category: Issues arising from audit findings rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code duplication between reddsa and redjubjub
4 participants