Skip to content

Fixes for exact division edge cases#1310

Merged
tarcieri merged 4 commits into
RustCrypto:masterfrom
andrewwhitehead:fix/div-exact-low-zero
Jun 26, 2026
Merged

Fixes for exact division edge cases#1310
tarcieri merged 4 commits into
RustCrypto:masterfrom
andrewwhitehead:fix/div-exact-low-zero

Conversation

@andrewwhitehead

Copy link
Copy Markdown
Contributor

This adds fixes for a couple types of inputs that were not producing the correct result:

  • Zero dividends should always divide exactly, even when the divisor has more limbs
  • Inexact division could be undetected when the dividend had one or more zero-valued lower limbs

The suite of proptests for BoxedUint are updated to explicitly create inputs with a single bit set, only high bits set, and only low bits set (which also detects these issues). Some tests are expanded to test differently-sized inputs where this was not being exercised before.

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
…und zero-valued limbs

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Comment thread tests/boxed_uint.rs
}

#[test]
// TODO: expand to f in uint(), g in uint()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changing this highlights the issue fixed by #1291

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.03%. Comparing base (2021752) to head (65f40c8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1310      +/-   ##
==========================================
+ Coverage   90.99%   91.03%   +0.04%     
==========================================
  Files         189      189              
  Lines       22560    22585      +25     
==========================================
+ Hits        20528    20561      +33     
+ Misses       2032     2024       -8     

☔ View full report in Codecov by Harness.
📢 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
Copy Markdown
Contributor Author

This does make the test runs significantly slower at the moment, I'll look at reducing the frequency of tests for larger BoxedUints.

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
@tarcieri tarcieri merged commit e25b054 into RustCrypto:master Jun 26, 2026
44 of 63 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