PrimesIsMRProbablePrime Method

FIPS 186-4 C.3.1 Miller-Rabin Probabilistic Primality Test.

Definition

Namespace: Org.BouncyCastle.Math
Assembly: BouncyCastle.Cryptography (in BouncyCastle.Cryptography.dll) Version: 2.3.0-beta.187+d6da5648ae
public static bool IsMRProbablePrime(
	BigInteger candidate,
	SecureRandom random,
	int iterations
)

Parameters

candidate  BigInteger
The BigInteger instance to test for primality.
random  SecureRandom
The source of randomness to use to choose bases.
iterations  Int32
The number of randomly-chosen bases to perform the test for.

Return Value

Boolean
false if any witness to compositeness is found amongst the chosen bases (so candidate is definitely NOT prime), or else true (indicating primality with some probability dependent on the number of iterations that were performed).

Remarks

Run several iterations of the Miller-Rabin algorithm with randomly-chosen bases.

See Also