Exemplo n.º 1
0
 private bool IsProbablePrime(BigInteger x, int iterations)
 {
     /*
      * Primes class for FIPS 186-4 C.3 primality checking
      */
     return(!Primes.HasAnySmallFactors(x) && Primes.IsMRProbablePrime(x, random, iterations));
 }
Exemplo n.º 2
0
 protected bool isProbablePrime(BigInteger x)
 {
     /*
      * Primes class for FIPS 186-4 C.3 primality checking
      */
     return(!Primes.HasAnySmallFactors(x) && Primes.IsMRProbablePrime(x, param.Random, iterations));
 }
Exemplo n.º 3
0
        public void TestHasAnySmallFactors()
        {
            for (int iterations = 0; iterations < ITERATIONS; ++iterations)
            {
                BigInteger prime = RandomPrime();
                Assert.False(Primes.HasAnySmallFactors(prime));

                // NOTE: Loop through ALL small values to be sure no small primes are missing
                for (int smallFactor = 2; smallFactor <= Primes.SmallFactorLimit; ++smallFactor)
                {
                    BigInteger nonPrimeWithSmallFactor = BigInteger.ValueOf(smallFactor).Multiply(prime);
                    Assert.True(Primes.HasAnySmallFactors(nonPrimeWithSmallFactor));
                }
            }
        }