Skip to content

Conversation

andrewwhitehead
Copy link
Contributor

invert_mod2k and invert_mod2k_vartime are optimized for Uint and BoxedUint (often by 95% or more), which brings the performance of invert_mod much closer to invert_odd_mod.

This depends on some of the updates in #930, and adds more functionality to UintRef for operating on limb slices in const methods. Support for operating on Odd<UintRef> or NonZero<UintRef> is also added.

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
fix repeated doubling in expand_invert_mod2k

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
@andrewwhitehead andrewwhitehead marked this pull request as ready for review September 9, 2025 17:59
@@ -92,12 +93,37 @@ impl UintRef {
self.0.iter_mut()
}

/// Access the number of limbs.
#[inline]
pub const fn len(&self) -> usize {
Copy link
Member

Choose a reason for hiding this comment

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

This is fairly consistently fn nlimbs elsewhere, e.g. BoxedUint::nlimbs, or the nlimbs macro for Uint

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
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.

3 participants