Skip to content

Faster floor_sqrt, checked_sqrt#1258

Open
andrewwhitehead wants to merge 8 commits intoRustCrypto:masterfrom
andrewwhitehead:feat/fast-sqrt
Open

Faster floor_sqrt, checked_sqrt#1258
andrewwhitehead wants to merge 8 commits intoRustCrypto:masterfrom
andrewwhitehead:feat/fast-sqrt

Conversation

@andrewwhitehead
Copy link
Copy Markdown
Contributor

  • An algorithm which scales better for large integers is used (approx O(2n)) - this is algorithm 1.12 in Modern Computer Arithmetic rather than 1.13
  • Addition and subtraction methods in UintRef are adjusted to accept an rhs smaller than self. This was inconsistently applied before
  • Performance is much better, about 70% improved for U256 and 95% for a 4096-bit BoxedUint
  • checked_sqrt no longer performs an additional squaring, so its performance matches floor_sqrt

…n_vartime

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>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

❌ Patch coverage is 98.95833% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.91%. Comparing base (ecf51af) to head (69f4ab6).

Files with missing lines Patch % Lines
src/uint/ref_type/sqrt.rs 98.32% 3 Missing ⚠️
src/uint/sqrt.rs 97.22% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1258      +/-   ##
==========================================
+ Coverage   90.84%   90.91%   +0.06%     
==========================================
  Files         186      187       +1     
  Lines       21673    21937     +264     
==========================================
+ Hits        19688    19943     +255     
- Misses       1985     1994       +9     

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

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