Random Prime Generator/Modular Arithmetic

Alex Martelli aleaxit at yahoo.com
Sat Mar 4 12:15:41 EST 2006


Tuvas <tuvas21 at gmail.com> wrote:
   ...
> to make sure. For simpler than going to the website, I used the ranint

I assume you mean random.randint here.

> function to pick a random prime number, then ran it through the miller
> rabin primality test. It's a probabalistic test, which means it isn't
> full proof, but there's still less than 1 in a million of giving a

Miller-Rabin is not the problem -- rather, random.randint might be... it
makes no claims to be cryptographically strong, in either the current
Mersenne implementation or the previous Wichman-Hill one. Could you
maybe use /dev/random or the like?  Cfr
<http://world.std.com/~cme/P1363/ranno.html> for an introduction to the
subject.  (For speed, you may want to look into gmpy.sf.net, but that's
quite a separate issue from the strength of your random numbers).


Alex



More information about the Python-list mailing list