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

arithmetic: Pass inputs to limbs_mul_mont as slices. #2247

Merged
merged 2 commits into from
Jan 18, 2025

Conversation

briansmith
Copy link
Owner

See the individual commits for details.

Be more consistent with the non-squaring Montgomery multiplication
functions.
@briansmith briansmith self-assigned this Jan 18, 2025
Remove some gratuitous unsafety.

In theory there are many patterns of aliasing the arguments when
calling `bn_mul_mont`, but in practice we only have three:

1. r *= a (mod n)
2. r = a * b (mod n)
3. r = r * r (mod n)

Rename `mul_mont` to `limbs_mul_mont` and have it handle both #1 & #2.
Refactor it so that its arguments are slices.

Remove the `limbs_mont_mul` and `limbs_mont_product` wrappers around
`limbs_mul_mont` in favor of exposing `limbs_mul_mont` directly.

Change `limbs_square_mont` to call `bn_mul_mont` directly. Although we
could have `mul_mont` handle this by making the new `InOut` type more
complicated, but we'd just end up undoing this when `bn_mul_mont` is
split into separate squaring and non-squaring functions later.
@briansmith briansmith force-pushed the b/bn-mul-mont-split-square branch from 8a7e660 to 8f4d5f0 Compare January 18, 2025 05:37
Copy link

codecov bot commented Jan 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.88%. Comparing base (c229242) to head (8f4d5f0).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2247      +/-   ##
==========================================
- Coverage   96.89%   96.88%   -0.01%     
==========================================
  Files         167      167              
  Lines       20687    20661      -26     
  Branches      475      475              
==========================================
- Hits        20044    20018      -26     
  Misses        546      546              
  Partials       97       97              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@briansmith briansmith merged commit e8ffb44 into main Jan 18, 2025
169 checks passed
@briansmith briansmith deleted the b/bn-mul-mont-split-square branch January 18, 2025 07:01
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.

1 participant