Enforce valid modulus for Residue and associated macros#243
Merged
tarcieri merged 4 commits intoRustCrypto:masterfrom May 26, 2023
Merged
Enforce valid modulus for Residue and associated macros#243tarcieri merged 4 commits intoRustCrypto:masterfrom
Residue and associated macros#243tarcieri merged 4 commits intoRustCrypto:masterfrom
Conversation
8c7f233 to
8e7e982
Compare
8e7e982 to
de8e088
Compare
Contributor
Author
|
@fjarri: Would appreciate a review if you're available. |
fjarri
reviewed
May 25, 2023
fjarri
reviewed
May 25, 2023
fjarri
reviewed
May 25, 2023
Contributor
Author
tarcieri
reviewed
May 25, 2023
613e194 to
e6913c7
Compare
e6913c7 to
c0b42fa
Compare
fjarri
approved these changes
May 26, 2023
tarcieri
reviewed
May 26, 2023
Co-authored-by: Tony Arcieri <bascule@gmail.com>
tarcieri
reviewed
May 26, 2023
Member
|
Ok, I guess I'll go ahead and merge this, although I'd really, really like to find a way to get rid of |
Contributor
Author
Agreed. Being able to rely solely on compile-time checks would be much more elegant and in line with the intent of the design, for sure. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR follows in the footsteps of #240 and enforces a valid (odd) modulus for compile-time constructions.
It updates
impl_modulus!to panic on an invalid modulus.For
Residue, it adds a panic tonewand deprecates it, and adds anew_checkedconstructor that returns aCtOptionbased on the modulus validity. This is added since it's possible to define a modulus withoutimpl_modulus!and useResiduedirectly.It also updates
const_residue!to useResidue::new_checkedandunwrap, so it will also panic on an invalid modulus.Closes #232.