Class MillerRabinTest


  • public class MillerRabinTest
    extends Object
    Miller-Rabin probable prime test.
    Author:
    Tilman Neumann
    • Constructor Detail

      • MillerRabinTest

        public MillerRabinTest()
    • Method Detail

      • isProbablePrime

        public boolean isProbablePrime​(BigInteger N,
                                       int numberOfRounds)
        Perform up to numberOfRounds Miller-Rabin tests with random bases.
        Parameters:
        N -
        numberOfRounds -
        Returns:
        true if N passes all tests, false if N is composite
      • testBases

        public boolean testBases​(BigInteger N,
                                 BigInteger[] bases)
        Perform Miller-Rabin test of N to several bases.
        Parameters:
        N -
        bases -
        Returns:
        true if N is probable prime, false if N is composite
      • testSingleBase

        public boolean testSingleBase​(BigInteger N,
                                      BigInteger x)
        Perform a single Miller-Rabin test of N to base x.
        Parameters:
        N -
        x - the base
        Returns:
        true if N is probable prime, false if N is composite