crypto: Rewrite modexp_even to use variadic-length numbers#1443
crypto: Rewrite modexp_even to use variadic-length numbers#1443
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the even-modulus modular exponentiation path to operate on variadic-length word spans (⌈k/64⌉ words) instead of fixed-width UIntT arithmetic, aligning it with the existing span-based approach used elsewhere in modexp.cpp.
Changes:
- Added small span-based
add()andsub()helpers for multi-word arithmetic. - Updated
mul()to auto-swap operands so it no longer requiresx.size() >= y.size(). - Rewrote
modexp_even()to compute intermediate values using only the words required bykand temporary span buffers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1443 +/- ##
=======================================
Coverage 96.52% 96.53%
=======================================
Files 152 152
Lines 13845 13862 +17
Branches 3227 3230 +3
=======================================
+ Hits 13364 13381 +17
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:
|
cc81764 to
3e8e826
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.
3e8e826 to
1c414d7
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.
Extends the variadic-length span approach to modexp_even, replacing fixed-width UIntT operations with span-based arithmetic over only the ⌈k/64⌉ words needed. New add and sub helpers are introduced. The mul function is relaxed to auto-swap operands instead of requiring x.size() >= y.size().
1c414d7 to
a3a9a8e
Compare
Extends the variadic-length span approach to modexp_even, replacing fixed-width UIntT operations with span-based arithmetic over only the ⌈k/64⌉ words needed.
New add and sub helpers are introduced. The mul function is relaxed to auto-swap operands instead of requiring
x.size() >= y.size().