browserify / crypto-browserify

partial implementation of node's `crypto` for the browser
MIT License
660 stars 201 forks source link

crypto.getDiffieHellman missing #12

Closed juliangruber closed 10 years ago

juliangruber commented 11 years ago

will see if i can come up with a pr

calvinmetcalf commented 10 years ago

@indutny I figured I was missing something, thanks

calvinmetcalf commented 10 years ago

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

indutny commented 10 years ago

@calvinmetcalf what prime are you using? :) Not every prime is pseudo-mersenne prime.

calvinmetcalf commented 10 years ago

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

indutny commented 10 years ago

Ah, it is for random primes. I guess then the Montgomery is the only way to go right now in bn.js.

calvinmetcalf commented 10 years ago

@indutny worse, random ones might sometimes work, these are specced to never work :) when generating primes we can (try) to make them pseudo-mersenne

indutny commented 10 years ago

@calvinmetcalf I think it is pretty dangerous business. I'd rather keep them random.

calvinmetcalf commented 10 years ago

I'm adding in the ability to generate primes, but the modp stuff is mainly to copy the current node api..

calvinmetcalf commented 10 years ago

Right read what you were responding to, generating them fully randomly

dominictarr commented 10 years ago

closed by: https://github.com/dominictarr/crypto-browserify/pull/62