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

Function generateKeyPair

lib/internal/crypto/keygen.js:92–111  ·  view source on GitHub ↗
(type, options, callback)

Source from the content-addressed store, hash-verified

90}
91
92function generateKeyPair(type, options, callback) {
93 if (typeof options === 'function') {
94 callback = options;
95 options = undefined;
96 }
97 validateFunction(callback, 'callback');
98
99 const job = createJob(kCryptoJobAsync, type, options);
100
101 job.ondone = (error, result) => {
102 if (error) return FunctionPrototypeCall(callback, job, error);
103 // If no encoding was chosen, return key objects instead.
104 let { 0: pubkey, 1: privkey } = result;
105 pubkey = wrapKey(pubkey, PublicKeyObject);
106 privkey = wrapKey(privkey, PrivateKeyObject);
107 FunctionPrototypeCall(callback, job, null, pubkey, privkey);
108 };
109
110 job.run();
111}
112
113ObjectDefineProperty(generateKeyPair, customPromisifyArgs, {
114 __proto__: null,

Calls 3

createJobFunction · 0.85
wrapKeyFunction · 0.70
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…