RSA: Support RSA key pairs where q < p without converting to p > q. #1802
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.
Previously we swapped p and q and calcualted a new qInv if p < q so that we could avoid doing a redunction during the CRT computation. Instead, just do the reduction during CRT as it's cheap. This notably reduces the number of operations we need in
bigint
, and it eliminates the need for thePrime
modulus marker type.Now there are more things that can go wrong during CRT. First, we may wrongly forget to reduce m_2 mod p; before this wasn't necessary since every element of q was an element of p. Next, we may wrongly use the the value of m_2 mod p instead of m_2 later; before we could do this since previously m_2 mod p == m_2 since m_2 < q < p. Add tests for these cases.
Rewrite the tests for
elem_reduced_once
given its new constraints.