Fermat's primality test vs. Miller-Rabin

Sidney Markowitz sidney at sidney.com
Sun Dec 4 21:01:42 EST 2005


Joseph Ashwood wrote:
> Granted this is only a test of the 
> generation of 128 numbers, but I got 128 primes (based on 128 MR rounds). 

That doesn't make sense, unless I'm misinterpreting what you are saying. Primes
aren't that common, are they?

I don't have time right now to look for a bug in your code, but you could add a
sanity check that would catch a bug immediately by adding in the appropriate
spot a test like

 if (!curnum.isProbablePrime(128))
   System.out.println("Something wrong, number is not really a prime!");


to check that your primality test gets the same result as the M-R primality
test that comes with BigInteger.

 -- sidney

---------------------------------------------------------------------
The Cryptography Mailing List
Unsubscribe by sending "unsubscribe cryptography" to majordomo at metzdowd.com



More information about the cryptography mailing list