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

Function checkPrime

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

Source from the content-addressed store, hash-verified

582}
583
584function checkPrime(candidate, options = kEmptyObject, callback) {
585 if (typeof candidate === 'bigint')
586 candidate = unsignedBigIntToBuffer(candidate, 'candidate');
587 if (!isAnyArrayBuffer(candidate) && !isArrayBufferView(candidate)) {
588 throw new ERR_INVALID_ARG_TYPE(
589 'candidate',
590 [
591 'ArrayBuffer',
592 'TypedArray',
593 'Buffer',
594 'DataView',
595 'bigint',
596 ],
597 candidate,
598 );
599 }
600 if (typeof options === 'function') {
601 callback = options;
602 options = kEmptyObject;
603 }
604 validateFunction(callback, 'callback');
605 validateObject(options, 'options');
606 let {
607 checks = 0,
608 } = options;
609
610 // The checks option is unsigned but must fit into a signed C int for OpenSSL.
611 validateInt32(checks, 'options.checks', 0);
612 // Coerce -0 to +0.
613 checks += 0;
614
615 const job = new CheckPrimeJob(kCryptoJobAsync, candidate, checks);
616 job.ondone = callback;
617 job.run();
618}
619
620function checkPrimeSync(candidate, options = kEmptyObject) {
621 if (typeof candidate === 'bigint')

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…