Re: Efficient (HUGE) prime modulus

2007-11-19 Thread Paul Rubin
blaine <[EMAIL PROTECTED]> writes: > As an alternative I > can use Java - but I'd rather have a pure python implementation. A number of people have suggested using 3-argument pow, but if this is supposed to be a learning exercise, I think it's worth figuring out for yourself how 3-argument pow is

Re: Efficient (HUGE) prime modulus

2007-11-19 Thread Tim Roberts
blaine <[EMAIL PROTECTED]> wrote: > > For my Network Security class we are designing a project that will, >among other things, implement a Diffie Hellman secret key exchange. >The rest of the class is doing Java, while myself and a classmate are >using Python (as proof of concept). I am having pr

Re: Efficient (HUGE) prime modulus

2007-11-19 Thread Justin Kwok
For the interested, the algorithm that is most likely being used is http://en.wikipedia.org/wiki/Exponentiation_by_squaring If you scroll down, there is a ruby implementation. Combine this with a little bit of http://en.wikipedia.org/wiki/Modular_arithmetic and I wrote a small python function that

Re: Efficient (HUGE) prime modulus

2007-11-19 Thread Hrvoje Niksic
blaine <[EMAIL PROTECTED]> writes: > Python Code: > G = > long(2333938645766150615511255943169694097469294538730577330470365230748185729160097289200390738424346682521059501689463393405180773510126708477896062227281603) > P = > long(7897383601534681724700886135766287333879367007236994792380

Re: Efficient (HUGE) prime modulus

2007-11-19 Thread Paul McGuire
On Nov 19, 10:32 am, blaine <[EMAIL PROTECTED]> wrote: > Hey guys, > For my Network Security class we are designing a project that will, > among other things, implement a Diffie Hellman secret key exchange. > The rest of the class is doing Java, while myself and a classmate are > using Python (as

Re: Efficient (HUGE) prime modulus

2007-11-19 Thread Steven Bethard
blaine wrote: > Hey guys, > For my Network Security class we are designing a project that will, > among other things, implement a Diffie Hellman secret key exchange. > The rest of the class is doing Java, while myself and a classmate are > using Python (as proof of concept). I am having problems

Re: Efficient (HUGE) prime modulus

2007-11-19 Thread Peter Otten
blaine wrote: > A = (G ** a) % P # G^a mod P > > ## END # > The above code takes a very long time. If I make little a only 16 bits > instead of 512, it takes about 12 seconds on my machine to compute. Is > this incorrect usage of **? I used math.pow and built-in pow. The > math.pow

Re: Efficient (HUGE) prime modulus

2007-11-19 Thread Chris Mellon
On Nov 19, 2007 10:32 AM, blaine <[EMAIL PROTECTED]> wrote: > Hey guys, > For my Network Security class we are designing a project that will, > among other things, implement a Diffie Hellman secret key exchange. > The rest of the class is doing Java, while myself and a classmate are > using Pytho

Re: Efficient (HUGE) prime modulus

2007-11-19 Thread Paul Rubin
blaine <[EMAIL PROTECTED]> writes: > A = (G ** a) % P # G^a mod P Think of how large the intermediate result G**a will be. That should explain why it's taking so long. So figure out what Java's modPow function must be doing, and write something similar. Or, see the docs for python's built-i

Efficient (HUGE) prime modulus

2007-11-19 Thread blaine
Hey guys, For my Network Security class we are designing a project that will, among other things, implement a Diffie Hellman secret key exchange. The rest of the class is doing Java, while myself and a classmate are using Python (as proof of concept). I am having problems though with crunching h