Skip to content

Add modular square root calculation for prime modulus ConstMontyForm#1139

Merged
tarcieri merged 7 commits intoRustCrypto:masterfrom
andrewwhitehead:feat/monty-sqrt
Feb 13, 2026
Merged

Add modular square root calculation for prime modulus ConstMontyForm#1139
tarcieri merged 7 commits intoRustCrypto:masterfrom
andrewwhitehead:feat/monty-sqrt

Conversation

@andrewwhitehead
Copy link
Contributor

This implements a new macro, const_prime_monty_params! as an alternative to const_monty_params! for a prime modulus. The resulting ConstMontyForm values support a sqrt method, calculating the modular square root (if it exists). Support for MontyForm is possible, but it would not be very ergonomic as the PrimeParams would need to be passed around separately.

@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 98.23009% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.99%. Comparing base (9689384) to head (263a7df).
⚠️ Report is 21 commits behind head on master.

Files with missing lines Patch % Lines
src/modular/prime_params.rs 95.27% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1139      +/-   ##
==========================================
+ Coverage   86.72%   86.99%   +0.27%     
==========================================
  Files         182      185       +3     
  Lines       20390    20729     +339     
==========================================
+ Hits        17683    18034     +351     
+ Misses       2707     2695      -12     

☔ 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>
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
Copy link
Contributor Author

This is really only in draft because I thought there might be debate about the macro naming or other aspects, I can mark it for review

@tarcieri
Copy link
Member

Would be nice to get it into a release, especially as it could be useful for primefield to replace the implementation there

@andrewwhitehead andrewwhitehead marked this pull request as ready for review February 13, 2026 20:14
@tarcieri tarcieri merged commit 236d679 into RustCrypto:master Feb 13, 2026
31 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