Skip to content

Support mixed-size comparisons for Integer types#1184

Open
andrewwhitehead wants to merge 3 commits intoRustCrypto:masterfrom
andrewwhitehead:upd/cmp
Open

Support mixed-size comparisons for Integer types#1184
andrewwhitehead wants to merge 3 commits intoRustCrypto:masterfrom
andrewwhitehead:upd/cmp

Conversation

@andrewwhitehead
Copy link
Contributor

This unifies the comparison methods between Int, Uint, and BoxedUint, and UintRef.

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
#[inline]
fn ct_assign(&mut self, other: &Self, choice: Choice) {
debug_assert_eq!(self.bits_precision(), other.bits_precision());
assert_eq!(self.bits_precision(), other.bits_precision());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to an assert because this cannot succeed.

@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 99.38272% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.86%. Comparing base (9cabea6) to head (0f61467).

Files with missing lines Patch % Lines
src/modular/boxed_monty_form/mul.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1184      +/-   ##
==========================================
+ Coverage   86.74%   86.86%   +0.11%     
==========================================
  Files         182      182              
  Lines       20384    20446      +62     
==========================================
+ Hits        17683    17760      +77     
+ Misses       2701     2686      -15     

☔ 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.

#[inline]
fn ct_select(&self, other: &Self, choice: Choice) -> Self {
debug_assert_eq!(self.bits_precision(), other.bits_precision());
assert_eq!(self.bits_precision(), other.bits_precision());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to an assert as the wrong value might be produced otherwise.

#[inline]
fn ct_swap(&mut self, other: &mut Self, choice: Choice) {
debug_assert_eq!(self.bits_precision(), other.bits_precision());
assert_eq!(self.bits_precision(), other.bits_precision());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to an assert because this could silently fail.

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.

1 participant