src/crypto/public_key/prime.js
async function isProbablePrime(n, e, k) {
  if (e && !n.subn(1).gcd(e).eqn(1)) {
    return false;
  }
  if (!divisionTest(n)) {
    return false;
  }
  if (!fermat(n)) {
    return false;
  }
  if (!await millerRabin(n, k)) {
    return false;
  }
  // TODO implement the Lucas test
  // See Section C.3.3 here: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
  return true;
}
async function isProbablePrime(n, e, k) {
  if (e && !n.subn(1).gcd(e).eqn(1)) {
    return false;
  }
  if (!divisionTest(n)) {
    return false;
  }
  if (!fermat(n)) {
    return false;
  }
  if (!await millerRabin(n, k)) {
    return false;
  }
  // TODO implement the Lucas test
  // See Section C.3.3 here: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
  return true;
}
async function isProbablePrime ( n , e , k ) { if ( e && ! n . subn ( 1 ) . gcd ( e ) . eqn ( 1 ) ) { return false ; } if ( ! divisionTest ( n ) ) { return false ; } if ( ! fermat ( n ) ) { return false ; } if ( ! await millerRabin ( n , k ) ) { return false ; } // TODO implement the Lucas test // See Section C.3.3 here: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf return true ; }
Probabilistic primality testing
@param {BN}      n Number to test
@param {BN}      e Optional RSA exponent to check against the prime
@param {Integer} k Optional number of iterations of Miller-Rabin test
@returns {boolean}
@async
Probabilistic primality testing