<PackageReference Include="BouncyCastle.Cryptography" Version="2.7.0" />

Org.BouncyCastle.Math.Primes

public static class Primes
Utility methods for generating primes and testing for primality.
namespace Org.BouncyCastle.Math { public static class Primes { public sealed class MROutput { public BigInteger Factor { get; } public bool IsProvablyComposite { get; } public bool IsNotPrimePower { get; } } public sealed class STOutput { public BigInteger Prime { get; } public byte[] PrimeSeed { get; } public int PrimeGenCounter { get; } } public static readonly int SmallFactorLimit; public static STOutput GenerateSTRandomPrime(IDigest hash, int length, byte[] inputSeed); public static MROutput EnhancedMRProbablePrimeTest(BigInteger candidate, SecureRandom random, int iterations); public static bool HasAnySmallFactors(BigInteger candidate); public static bool IsMRProbablePrime(BigInteger candidate, SecureRandom random, int iterations); public static bool IsMRProbablePrimeToBase(BigInteger candidate, BigInteger baseValue); } }