Implementation of prime factors recovery#258
Implementation of prime factors recovery#258davxy wants to merge 3 commits intoRustCrypto:masterfrom davxy:master
Conversation
EDIT: see below comment
|
|
@davxy Appendix C.2 has a "Deterministic Prime-Factor Recovery" algorithm. Perhaps it would make sense to implement that one instead? Edit: under the "Assumptions" section, I see the deterministic algorithm is more restrictive with respect to 𝒆, namely requiring it to be between 2^16 and 2^256. Perhaps it would be good to have both? |
|
Yeah, I think could be a good idea to have both. I'm going to have a look at the deterministic algorithm before attempt an implementation, but not before the we :-D |
|
FYI, the deterministic algorithm isn't in SP 800-56B Rev 1. It's only in Rev 2: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Br2.pdf |
|
Closing in favor of #380 |
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::OsRngto 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
gsuch that:These two requirements are why the probability to succeed with a random
gis 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 ofgvia a proper random number generator and set it to something "good enough" (e.gg = e · i, with i =1..100) or something like that...