Skip to content

Enforce valid modulus for DynResidueParams#240

Merged
tarcieri merged 8 commits intoRustCrypto:masterfrom
AaronFeickert:modulus-checks
May 26, 2023
Merged

Enforce valid modulus for DynResidueParams#240
tarcieri merged 8 commits intoRustCrypto:masterfrom
AaronFeickert:modulus-checks

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.

@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

Comments