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

EC: Avoid Montgomery encoding in point arithmetic test data files. #1770

Merged
merged 2 commits into from
Oct 26, 2023

Conversation

briansmith
Copy link
Owner

Add a new scalar base point multiplication test case generator that where the points are not Montgomery-encoded. This way we don't need to generate different test data files when the Montgomery encoding for a curve isn't the same for 32-bit and 64-bit targets (P-521).

This version of the generator produces the test cases for all the scalars that the current P-256 and P-384 tests generate, in the same format; the only exception is that the point is not Montgomery-encoded.

davidben and others added 2 commits October 25, 2023 10:04
…test vectors.

`git cherry-pick 50418af`.

Bring in the test vector generator unmodified.
Add a new scalar base point multiplication test case generator that
where the points are *not* Montgomery-encoded. This way we don't need
to generate different test data files when the Montgomery encoding
for a curve isn't the same for 32-bit and 64-bit targets (P-521).

This version of the generator produces the test cases for all the
scalars that the current P-256 and P-384 tests generate, in the same
format; the only exception is that the point is not
Montgomery-encoded.
@briansmith briansmith self-assigned this Oct 25, 2023
@briansmith briansmith changed the title EC: Add scalar base point multiplication test case generator. EC: Avoid Montgomery encoding in point arithmetic test data files. Oct 25, 2023
@briansmith
Copy link
Owner Author

Remaining work:

  • Change the p{256,384}point{double,sum} tests so that they don't use Montgomery encoding for the input or output points. For the testing of edge cases of point doubling and point addition (handling of points at infinity in inputs and outputs), Unfortunately Go's API (even the deprecated one these tests use) doesn't expose Jacobian points so we probably can't write these generators in Go.
  • Change the test scaffolding for the (base) point multiplication tests so that it Montgomery-encodes the expected result from the input file before comparing to the actual computed result. Then regenerate the .txt files by running the generators so that the input points are no longer Montgomery-encoded.

@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

Merging #1770 (ac6738e) into main (3565fe8) will increase coverage by 0.12%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1770      +/-   ##
==========================================
+ Coverage   95.90%   96.02%   +0.12%     
==========================================
  Files         132      138       +6     
  Lines       15102    20788    +5686     
  Branches      169      226      +57     
==========================================
+ Hits        14483    19962    +5479     
- Misses        598      790     +192     
- Partials       21       36      +15     

see 29 files with indirect coverage changes

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

@briansmith briansmith marked this pull request as ready for review October 26, 2023 17:24
@briansmith
Copy link
Owner Author

I'm going to merge the test case generator as-is in the interest of helping others contribute towards solving the bigger problem.

@briansmith briansmith merged commit 61ad435 into main Oct 26, 2023
138 checks passed
@briansmith briansmith deleted the b/ec-mul-test-vectors branch October 26, 2023 17:25
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