Implementation of prime factors recovery #258
Closed
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.
Implements algorithm described in Appendix C of https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Br1.pdf
As a first draft, this is using the
rand_core::OsRng
to generate a random number in the range [2, n).Obviously this should be replaced somehow. One option is to pass an impl of a PRNG as a parameter, but maybe there is a better solution...
Given that:
and that:
The only requirement to succeed is to pick a
g
such that:These two requirements are why the probability to succeed with a random
g
is 1/2.That is, given a sequence of
g^z
(0 <= z <= ed -1) that for sure ends up with 1 at some point we will catch -1 or 1.If 2 doesn't hold ... we'll try with another
g
.As an attempt to remove the dependency on a random num generator given the super high probability to catch a correct
g
, maybe we can remove at all the generation ofg
via a proper random number generator and set it to something "good enough" (e.gg = e · i
, with i =1..100) or something like that...