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 simplified elliptic curve code generator. #1756

Merged
merged 2 commits into from
Oct 25, 2023
Merged

Conversation

briansmith
Copy link
Owner

Add a tool to generate and/or verify NIST curve boilerplate.

Manually sync the formatting of the existing code with the generator.

@briansmith briansmith self-assigned this Oct 17, 2023
@briansmith
Copy link
Owner Author

@vkrasnov This is the tool I used to review #1702. The tool existed in a different form, and I modified it to produce (almost) identical output to that PR. My plan is to use this tool to help with the P-521 work and to bulk rewrite all of src/ec/suite_b.

@codecov
Copy link

codecov bot commented Oct 17, 2023

Codecov Report

Merging #1756 (3094b9d) into main (3565fe8) will increase coverage by 0.11%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1756      +/-   ##
==========================================
+ Coverage   95.90%   96.01%   +0.11%     
==========================================
  Files         132      138       +6     
  Lines       15102    20788    +5686     
  Branches      169      226      +57     
==========================================
+ Hits        14483    19959    +5476     
- Misses        598      792     +194     
- Partials       21       37      +16     
Files Coverage Δ
src/ec/suite_b/ops/p256.rs 100.00% <100.00%> (ø)
src/ec/suite_b/ops/p384.rs 100.00% <100.00%> (ø)

... and 28 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@briansmith briansmith force-pushed the b/curve-gen-2 branch 2 times, most recently from 05b3b13 to 54d659e Compare October 17, 2023 08:17
@vkrasnov
Copy link
Contributor

Yes, I generated the params with python as well, they are the same, not sure why my code doesn't pass the 32bit tests, since code is reused from p384. I was unable to get a 32bit dev enviroment unfortunately.

};

pub static COMMON_OPS: CommonOps = CommonOps {
num_limbs: (%(bits)s + 7) / LIMB_BITS,
Copy link
Contributor

Choose a reason for hiding this comment

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

  • 7 should be (LIMB_BITS - 1), or 31

Add a tool to generate and/or verify NIST curve boilerplate.

Sync the existing P-256 and P-384 code with the generator.
Add preliminary support for P-521 but don't sync the existing
(semi-)generated code with it.
@briansmith briansmith marked this pull request as ready for review October 25, 2023 20:21
@briansmith briansmith merged commit 6613481 into main Oct 25, 2023
138 checks passed
@briansmith briansmith deleted the b/curve-gen-2 branch October 25, 2023 20:46
@briansmith
Copy link
Owner Author

I updated this PR substantially so that it can generate everything in in p384.rs except the addition chains.

I also extended the P-521 support so that it does the right thing for the 32-bit vs. 64-bit Montgomery stuff; it does the #[cfg(...)] stuff slightly differently than your P-521 PR does it. See the second commit in this PR. I verified the numbers match your numbers for both 64-bit and 32-bit.

Yes, I generated the params with python as well,

I didn't extend the code generator to generate gfp_p{384,521}.c. If you have Python code that can generate the constants in the C code, then could you please submit it as a change to this Python script?

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.

2 participants