MCPcopy Index your code
hub / github.com/nodejs/node / checkPrimeSync

Function checkPrimeSync

lib/internal/crypto/random.js:620–652  ·  view source on GitHub ↗
(candidate, options = kEmptyObject)

Source from the content-addressed store, hash-verified

618}
619
620function checkPrimeSync(candidate, options = kEmptyObject) {
621 if (typeof candidate === 'bigint')
622 candidate = unsignedBigIntToBuffer(candidate, 'candidate');
623 if (!isAnyArrayBuffer(candidate) && !isArrayBufferView(candidate)) {
624 throw new ERR_INVALID_ARG_TYPE(
625 'candidate',
626 [
627 'ArrayBuffer',
628 'TypedArray',
629 'Buffer',
630 'DataView',
631 'bigint',
632 ],
633 candidate,
634 );
635 }
636 validateObject(options, 'options');
637 let {
638 checks = 0,
639 } = options;
640
641 // The checks option is unsigned but must fit into a signed C int for OpenSSL.
642 validateInt32(checks, 'options.checks', 0);
643 // Coerce -0 to +0.
644 checks += 0;
645
646 const job = new CheckPrimeJob(kCryptoJobSync, candidate, checks);
647 const { 0: err, 1: result } = job.run();
648 if (err)
649 throw err;
650
651 return result;
652}
653
654module.exports = {
655 checkPrime,

Callers 1

Calls 2

unsignedBigIntToBufferFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…