-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When computing modular inverses distingush which case we are in
There are several different scenarios where we need to compute a modular inverse * A secret value modulo a secret prime (eg RSA-CRT setup) * A (potentially) secret value modulo a public prime (eg inversion modulo an DL group order) * A secret value modulo a public value that is not prime (RSA blinding setup) * RSA secret exponent calculation, where e and phi(n) are relatively prime, phi(n) is secret and not prime, and e is public * The general case where we have no idea as to the structure of the modulus, and we don't know if it is public so must treat it as secret Previously all of these went through `inverse_mod` which prevented any possible optimizations based on cases. Add a new (internal) header which directly exposes the various cases and apply them within the codebase. The only new algorithm implemented (so far) is Arazi's algorithm for inversion of a prime modulo a non-prime. Specifically this is a special case for computing the RSA secret exponent when `e=65537`. (Would also work for `e=3`/`e=17`/etc but this is not implemented)
- Loading branch information
Showing
20 changed files
with
413 additions
and
79 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ reducer.h | |
</header:public> | ||
|
||
<header:internal> | ||
mod_inv.h | ||
monty.h | ||
monty_exp.h | ||
primality.h | ||
|
This file contains 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
Oops, something went wrong.