Two new search strategies to find special-form primes p #4
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 adds two new search strategies that look for special-form primes
p
with faster modular arithmetic. This is important for projects that will use the curve Ep much more often than curve Eq, such as Monero.The new stategies work by enumerating special-form primes
p
and then solving forT
andV
using the Cornacchia's algorithm. If a solution exists and any of the 6 possible orders are prime, a curve cycle is guaranteed to exist.Because special-form primes are rare, there is a new option
--anyeqn
that will find the smallestb
such that both curves have the equationy^2 = x^3 + b
.Additional small changes are:
Crandall primes
Crandall primes have the form of
2^x-c
withc
small. The most famous example is the prime2^255-19
used by Curve25519. These primes allow a fast Barrett modular reduction algorithm.Unfortunately, this strategy does not work very well with the 2-adicity requirement, but can still be used to find cycles without it. For example:
The first cycle found is:
Montgomery-friendly primes
Primes in the form of
c*2^x+1
withc
small have a much more efficient Montgomery reduction algorithm. A big advantage is that these primes are naturally 2-adic.Cycles found with this strategy always have 2-adicity of the prime
p
twice higher than the 2-adicity of primeq
.For example, the command:
wil perform an exhaustive search and find a total of 5 cycles. The first cycle found is:
All the changes are backwards compatible. The Pasta cycle can still be reproduced using the same command: