Skip to content

Avoid branching on invertibility in BoxedMontyForm::invert - #1355

Open
elichai wants to merge 1 commit into
RustCrypto:masterfrom
elichai:elichai/fix-boxed-monty-invert-ct
Open

elichai wants to merge 1 commit into
RustCrypto:masterfrom
elichai:elichai/fix-boxed-monty-invert-ct

Conversation

@elichai

@elichai elichai commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

The function already returns CtOption::new(ret, is_some) and avoids branching on self.params.inverter().invert(&self.montgomery_form); result, so this does the same for the attached BoxedMontyForm

`Option::from(CtOption)` branches on `is_some`, which leaks whether the
value is invertible. Use `CtOption::unwrap_or`, which selects in
constant time.

Add a test for the non-invertible path.
@codecov

codecov Bot commented Oct 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.28%. Comparing base (d1a4e1c) to head (33d8dec).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1355   +/-   ##
=======================================
  Coverage   91.28%   91.28%           
=======================================
  Files         190      190           
  Lines       22941    22947    +6     
=======================================
+ Hits        20942    20948    +6     
  Misses       1999     1999           

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

This branch has not been deployed

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