Closed juliangruber closed 10 years ago
@indutny I figured I was missing something, thanks
I don't think the modp primes are psudo-mersenne primes modp1 is 2^768 - 2^704 - 1 + 2^64 * { [2^638 pi] + 149686 }
so k (which would have to be less then 2^(768/2) or 2^384 ) would be 36f0255dde973dcb3b399d747f23e32ed6fdb1f77598338bfdf44159c4ec64ddaeb5f78671cbfb22106ae64c32c5bce4cfd4f5920da0ebc8b01eca9292ae3dba1b7a4a899da181390bb3bd1659c5c9df0000000000000001
which comes out to be bigger then 2^384
@calvinmetcalf what prime are you using? :) Not every prime is pseudo-mersenne prime.
the modp primes you get from crypto.getDiffieHellman, pseudo-mersenne might only work as a speed up when a prime is generated
On Mon, Nov 3, 2014 at 11:12 PM, Fedor Indutny notifications@github.com wrote:
@calvinmetcalf https://github.com/calvinmetcalf what prime are you using? :) Not every prime is pseudo-mersenne prime.
— Reply to this email directly or view it on GitHub https://github.com/dominictarr/crypto-browserify/issues/12#issuecomment-61591250 .
-Calvin W. Metcalf
Ah, it is for random primes. I guess then the Montgomery is the only way to go right now in bn.js.
@indutny worse, random ones might sometimes work, these are specced to never work :) when generating primes we can (try) to make them pseudo-mersenne
@calvinmetcalf I think it is pretty dangerous business. I'd rather keep them random.
I'm adding in the ability to generate primes, but the modp stuff is mainly to copy the current node api..
Right read what you were responding to, generating them fully randomly
will see if i can come up with a pr