Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce valid modulus for DynResidueParams #240

Merged
merged 8 commits into from
May 26, 2023

Conversation

AaronFeickert
Copy link
Contributor

@AaronFeickert AaronFeickert commented May 22, 2023

As noted in #232, it is possible to create DynResidueParams with an invalid modulus. If this happens, arithmetic operations will quietly produce invalid results.

At the suggestion of @tarcieri, this PR takes steps toward enforcing modulus validity. It has DynResidueParams::new panic on an invalid modulus, which keeps its signature intact while safely failing, and deprecates it. It also introduces DynResidueParams::new_checked, which returns a CtOption. It also adds a few simple tests and updates the documentation.

At the next breaking release, the checked behavior can move to DynResidueParams::new if desired.

benches/bench.rs Outdated Show resolved Hide resolved
@AaronFeickert AaronFeickert requested a review from fjarri May 25, 2023 21:27
@AaronFeickert AaronFeickert requested a review from tarcieri May 25, 2023 23:32
@tarcieri tarcieri merged commit c7b4694 into RustCrypto:master May 26, 2023
@AaronFeickert AaronFeickert deleted the modulus-checks branch May 26, 2023 15:12
@tarcieri tarcieri mentioned this pull request Sep 4, 2023
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.

3 participants