Skip to content

Return Option from vartime inversion and pow methods#1260

Open
cong-or wants to merge 2 commits intoRustCrypto:masterfrom
cong-or:vartime-invert-return-option
Open

Return Option from vartime inversion and pow methods#1260
cong-or wants to merge 2 commits intoRustCrypto:masterfrom
cong-or:vartime-invert-return-option

Conversation

@cong-or
Copy link
Copy Markdown
Contributor

@cong-or cong-or commented May 3, 2026

#1096 converted the vartime bit shift methods from CtOption to Option. This does the same for vartime inversion and pow.

Since these methods are already variable-time, wrapping results in CtOption doesn't add any constant-time guarantees — it just forces eager evaluation in combinators where Option would
be lazy.

The Invert trait impls still return CtOption#1097 tried changing that and got reverted in #1124 because elliptic-curve needs Invert::Output to stay flexible. So the trait impls
convert back from Option via match.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

❌ Patch coverage is 73.33333% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.83%. Comparing base (40205f1) to head (6352578).

Files with missing lines Patch % Lines
src/modular/const_monty_form/invert.rs 0.00% 11 Missing ⚠️
src/uint/boxed/invert_mod.rs 0.00% 2 Missing ⚠️
src/uint/invert_mod.rs 80.00% 2 Missing ⚠️
src/modular/fixed_monty_form/invert.rs 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1260      +/-   ##
==========================================
- Coverage   90.84%   90.83%   -0.01%     
==========================================
  Files         186      186              
  Lines       21673    21686      +13     
==========================================
+ Hits        19688    19699      +11     
- Misses       1985     1987       +2     

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

@cong-or cong-or force-pushed the vartime-invert-return-option branch from 3018fca to 6352578 Compare May 3, 2026 14:34
@tarcieri
Copy link
Copy Markdown
Member

tarcieri commented May 3, 2026

I'm a little confused that cargo semver-checks isn't complaining, but these are breaking changes and we're in the stable part of a release cycle.

@cong-or
Copy link
Copy Markdown
Contributor Author

cong-or commented May 3, 2026

I'm a little confused that cargo semver-checks isn't complaining, but these are breaking changes and we're in the stable part of a release cycle.

@tarcieri No worries — happy to rebase this when you're ready to collect breaking changes for the next release.

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