FcheckPrimeSync
Bun

function

crypto.checkPrimeSync

function checkPrimeSync(
candidate: LargeNumberLike,
): boolean;

Checks the primality of the candidate.

@param candidate

A possible prime encoded as a sequence of big endian octets of arbitrary length.

@returns

true if the candidate is a prime with an error probability less than 0.25 ** options.checks.

Referenced types

type LargeNumberLike = NodeJS.ArrayBufferView | SharedArrayBuffer | ArrayBuffer | bigint

interface CheckPrimeOptions

  • checks?: number

    The number of Miller-Rabin probabilistic primality iterations to perform. When the value is 0 (zero), a number of checks is used that yields a false positive rate of at most 2**-64 for random input. Care must be used when selecting a number of checks. Refer to the OpenSSL documentation for the BN_is_prime_ex function nchecks options for more details.