Skip to content

Add Invert to MontyForm supertraits#1226

Merged
tarcieri merged 1 commit intoRustCrypto:masterfrom
andrewwhitehead:feat/monty-inv
Mar 20, 2026
Merged

Add Invert to MontyForm supertraits#1226
tarcieri merged 1 commit intoRustCrypto:masterfrom
andrewwhitehead:feat/monty-inv

Conversation

@andrewwhitehead
Copy link
Contributor

No description provided.

Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
@tarcieri
Copy link
Member

tarcieri commented Mar 19, 2026

Note that this is technically a breaking change, which we really need to stop making, though this one is unlikely to have user-facing impact. It would involve yanking the existing stable releases again though like last time, which is somewhat disruptive.

Perhaps we should also seal Integer which would make future changes like this non-breaking.

@andrewwhitehead
Copy link
Contributor Author

andrewwhitehead commented Mar 19, 2026

Hm, I figured since it was additive it wouldn't be disruptive. Another potential one is adding from_montgomery since you can export the integer in Montgomery form but not import it.

@andrewwhitehead
Copy link
Contributor Author

Also doesn't have to be done now, implementers can use U: UnsignedWithMontyForm<MontyForm: Invert<Output=CtOption<U::MontyForm>>> or something like that.

@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.99%. Comparing base (2484f32) to head (508a278).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1226      +/-   ##
==========================================
+ Coverage   87.97%   87.99%   +0.01%     
==========================================
  Files         184      184              
  Lines       21238    21244       +6     
==========================================
+ Hits        18684    18693       +9     
+ Misses       2554     2551       -3     

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

@tarcieri
Copy link
Member

Hm, I figured since it was additive it wouldn't be disruptive

Right now it's possible for downstream crates to impl the Integer trait for their own types. If they do that, and we add a new trait requirement they don't impl, it will break their code.

I doubt anyone is doing that yet, so this is a largely hypothetical scenario, but it's one we should respect in our SemVer contract.

We can avoid this situation entirely by sealing the Integer trait so downstream crates can't impl it.

tarcieri added a commit that referenced this pull request Mar 20, 2026
Note: this is a breaking change in a stable release, and hopefully the
last such change we make. As a result, the v0.7.1 release will be
yanked. We suspect this will not have an impact on users as it's
unlikely any downstream crates have impl'd the `Integer` trait.

Sealing the `Integer` trait allows us to make additive changes to its
bounds, e.g. #1226
@tarcieri
Copy link
Member

I opened a PR to seal the Integer trait: #1227

tarcieri added a commit that referenced this pull request Mar 20, 2026
Note: this is a breaking change in a stable release, and hopefully the
last such change we make. As a result, the v0.7.1 release will be
yanked. We suspect this will not have an impact on users as it's
unlikely any downstream crates have impl'd the `Integer` trait.

Sealing the `Integer` trait allows us to make additive changes to its
bounds, e.g. #1226
@tarcieri tarcieri merged commit 4182ba0 into RustCrypto:master Mar 20, 2026
31 checks passed
@tarcieri tarcieri mentioned this pull request Mar 20, 2026
tarcieri added a commit that referenced this pull request Mar 20, 2026
## Added
- `Invert` to `MontyForm` supertraits (#1226)

## Changed
- BREAKING: seal the `Integer` trait (#1227)
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