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

Function createRandomPrimeJob

lib/internal/crypto/random.js:462–514  ·  view source on GitHub ↗
(type, size, options)

Source from the content-addressed store, hash-verified

460}
461
462function createRandomPrimeJob(type, size, options) {
463 validateObject(options, 'options');
464
465 const {
466 safe = false,
467 bigint = false,
468 } = options;
469 let {
470 add,
471 rem,
472 } = options;
473
474 validateBoolean(safe, 'options.safe');
475 validateBoolean(bigint, 'options.bigint');
476
477 if (add !== undefined) {
478 if (typeof add === 'bigint') {
479 add = unsignedBigIntToBuffer(add, 'options.add');
480 } else if (!isAnyArrayBuffer(add) && !isArrayBufferView(add)) {
481 throw new ERR_INVALID_ARG_TYPE(
482 'options.add',
483 [
484 'ArrayBuffer',
485 'TypedArray',
486 'Buffer',
487 'DataView',
488 'bigint',
489 ],
490 add);
491 }
492 }
493
494 if (rem !== undefined) {
495 if (typeof rem === 'bigint') {
496 rem = unsignedBigIntToBuffer(rem, 'options.rem');
497 } else if (!isAnyArrayBuffer(rem) && !isArrayBufferView(rem)) {
498 throw new ERR_INVALID_ARG_TYPE(
499 'options.rem',
500 [
501 'ArrayBuffer',
502 'TypedArray',
503 'Buffer',
504 'DataView',
505 'bigint',
506 ],
507 rem);
508 }
509 }
510
511 const job = new RandomPrimeJob(type, size, safe, add, rem);
512 job.result = bigint ? arrayBufferToUnsignedBigInt : (p) => p;
513 return job;
514}
515
516function generatePrime(size, options, callback) {
517 validateInt32(size, 'size', 1);

Callers 2

generatePrimeFunction · 0.85
generatePrimeSyncFunction · 0.85

Calls 1

unsignedBigIntToBufferFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…