crypto: Use variadic-length modinv in modexp#1434
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1434 +/- ##
=======================================
Coverage 96.51% 96.52%
=======================================
Files 152 152
Lines 13805 13828 +23
Branches 3223 3225 +2
=======================================
+ Hits 13324 13347 +23
Misses 342 342
Partials 139 139
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
f2285ac to
72de6b7
Compare
There was a problem hiding this comment.
Pull request overview
This pull request refactors the modular inversion function in the modular exponentiation implementation to use variable-length operands via spans instead of fixed-size template types.
Changes:
- Adds two new helper functions:
mul()for truncated multiplication andneg_add2()for computing2 - x - Converts
modinv_pow2()from a template function to a span-based function for variable-length operations - Updates the call site in
modexp_even()to use the new span-based interface
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
72de6b7 to
3eca7de
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f4b9c6c to
dacd4d0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dacd4d0 to
5dc11af
Compare
Replace the modular inversion with mod 2ᵏ which uses fixed size
intx::uintto one which uses variadic-length numbers represented bystd::span<uint64_t>.This improves performance in pathological cases when the 2ᵏ part of the modexp modulus is significant shorter than the modulus itself.