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

Function main

benchmark/crypto/webcrypto-verify.js:73–100  ·  view source on GitHub ↗
({ n, mode, keyReuse, keyType })

Source from the content-addressed store, hash-verified

71}
72
73async function main({ n, mode, keyReuse, keyType }) {
74 const algorithm = kAlgorithms[keyType];
75 const verifyParams = kSignParams[keyType];
76
77 if (!publicKeys || publicKeys.length !== n ||
78 publicKeys[0].algorithm.name !== verifyParams.name) {
79 publicKeys = new Array(n);
80 // Generate one key pair, then import its spki bytes n times to get
81 // distinct CryptoKey instances.
82 const kp = await subtle.generateKey(algorithm, true, ['sign', 'verify']);
83 const spki = await subtle.exportKey('spki', kp.publicKey);
84 for (let i = 0; i < n; ++i) {
85 publicKeys[i] = await subtle.importKey('spki', spki, algorithm, false, ['verify']);
86 }
87 signature = await subtle.sign(verifyParams, kp.privateKey, data);
88 }
89
90 const sharedKey = keyReuse === 'shared' ? publicKeys[0] : undefined;
91
92 switch (mode) {
93 case 'serial':
94 await measureSerial(n, verifyParams, sharedKey);
95 break;
96 case 'parallel':
97 await measureParallel(n, verifyParams, sharedKey);
98 break;
99 }
100}

Callers

nothing calls this directly

Calls 2

measureSerialFunction · 0.70
measureParallelFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…