crypto.checkPrimeSync(candidate[, options])


  • candidate <ArrayBuffer> | <SharedArrayBuffer> | <TypedArray> | <Buffer> | <DataView> | <bigint> 编码为任意长度的大端字节序序列的可能素数。
  • options <Object>
    • checks <number> 要执行的 Miller-Rabin 概率素性迭代次数。 当值为 0(零)时,使用多次检查对随机输入产生最多 2-64 的误报率。 选择多个检查时必须小心。 有关更多详细信息,请参阅 BN_is_prime_ex 函数 nchecks 选项的 OpenSSL 文档。 默认值: 0
  • 返回: <boolean> 如果候选者是错误概率小于 0.25 ** options.checks 的素数,则为 true

检查 candidate 的素性。

  • candidate <ArrayBuffer> | <SharedArrayBuffer> | <TypedArray> | <Buffer> | <DataView> | <bigint> A possible prime encoded as a sequence of big endian octets of arbitrary length.
  • options <Object>
    • 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. Default: 0
  • Returns: <boolean> true if the candidate is a prime with an error probability less than 0.25 ** options.checks.

Checks the primality of the candidate.