Skip to content

Add exponentiation methods for BoxedUint#1159

Merged
tarcieri merged 5 commits intoRustCrypto:masterfrom
andrewwhitehead:feat/boxed-pow
Feb 1, 2026
Merged

Add exponentiation methods for BoxedUint#1159
tarcieri merged 5 commits intoRustCrypto:masterfrom
andrewwhitehead:feat/boxed-pow

Conversation

@andrewwhitehead
Copy link
Contributor

@andrewwhitehead andrewwhitehead commented Jan 26, 2026

This implements wrapping_pow, wrapping_pow_bounded_exp, wrapped_pow_vartime for BoxedUint, as well as checked and saturating versions of these methods.

Multiplication support (references to the karatsuba module and overflow checks) are moved into UintRef.

A BoxedMultiplier helper is added for reducing allocations during the exponentiation.

Related to #259

@andrewwhitehead andrewwhitehead force-pushed the feat/boxed-pow branch 2 times, most recently from 2988923 to 0e13046 Compare January 26, 2026 16:23
@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 99.73615% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.13%. Comparing base (f25910b) to head (d8bb0c1).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/uint/boxed/mul.rs 98.18% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1159      +/-   ##
==========================================
+ Coverage   80.66%   81.13%   +0.47%     
==========================================
  Files         178      181       +3     
  Lines       18963    19277     +314     
==========================================
+ Hits        15296    15641     +345     
+ Misses       3667     3636      -31     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andrewwhitehead
Copy link
Contributor Author

@tarcieri I just noticed that (&BoxedUint) * (&BoxedUint) was doing a checked multiplication, unlike all the other Mul implementations so I changed it to be consistent and do a widening multiplication.

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
…xedUint

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Comment on lines +7 to +9
/// Boxed multiplier with a pre-allocated internal buffer to avoid additional allocations.
#[derive(Debug, Clone)]
pub struct BoxedMultiplier {
Copy link
Member

Choose a reason for hiding this comment

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

Wonder if there's a way we can consolidate this with e.g. BoxedMontyMultiplier

@tarcieri tarcieri merged commit 8a495fa into RustCrypto:master Feb 1, 2026
28 checks passed
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