Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between BigInteger.probablePrime() and other primality algorithms in java

I am implementing an RSA encryption program using Java. Right now I am using BigInteger.probablePrime(1024, rnd) to get prime numbers. Here rnd is a random number generated by Random rnd = new Random() . I need to test various speeds of encryption.

My questions are:

  1. what algorithm does the BigInteger.probablePrime(1024, rnd) use?

  2. what is the difference between the algorithm above and other algorithms: like Rabin-Miller, Fermats, Lucas-Lehmer?

Thank you.

like image 646
user1132346 Avatar asked Jan 05 '12 14:01

user1132346


1 Answers

BigInteger's probable prime methods use both the Miller-Rabin and Lucas-Lehmer algorithms to test primality.

See the internal method BigInteger.primeToCertainty.

like image 132
Michael Brewer-Davis Avatar answered Sep 29 '22 22:09

Michael Brewer-Davis