Difference between BigInteger.probablePrime () and other primitive algorithms

I am implementing an RSA encryption program. Right now, I'm using BigInteger.probablePrime(1024, rnd) , where rnd is the random number generated by Random rnd = new Random() to get prime numbers. I need to check various encryption speeds. My question is which algorithm uses BigInteger.probablePrime(1024, rnd) ? and what is the difference between this and the use of some other algorithm, such as Rabin-Miller, Fermat, Lucas-Lemmer? Thanks.

+4
source share
2 answers

BigInteger probable simple methods use Miller-Rabin and Lucas-Lemmer algorithms to test primitiveness.

See the internal BigInteger.primeToCertainty method.

+2
source

Java source code is available for download, so you can look at it yourself. Here is the code for BigInteger.probablePrime(int, Random) :

 public static BigInteger probablePrime(int bitLength, Random rnd) { if (bitLength < 2) throw new ArithmeticException("bitLength < 2"); // The cutoff of 95 was chosen empirically for best performance return (bitLength < SMALL_PRIME_THRESHOLD ? smallPrime(bitLength, DEFAULT_PRIME_CERTAINTY, rnd) : largePrime(bitLength, DEFAULT_PRIME_CERTAINTY, rnd)); } 

Actual tests are contained in the smallPrime() and largePrime() methods, which follow directly in the source code.

+2
source

Source: https://habr.com/ru/post/1389477/


All Articles