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

Function test

test/parallel/test-webcrypto-derivebits.js:17–35  ·  view source on GitHub ↗
(namedCurve)

Source from the content-addressed store, hash-verified

15// Test ECDH bit derivation
16{
17 async function test(namedCurve) {
18 const [alice, bob] = await Promise.all([
19 subtle.generateKey({ name: 'ECDH', namedCurve }, true, ['deriveBits']),
20 subtle.generateKey({ name: 'ECDH', namedCurve }, true, ['deriveBits']),
21 ]);
22
23 const [secret1, secret2] = await Promise.all([
24 subtle.deriveBits({
25 name: 'ECDH', namedCurve, public: alice.publicKey
26 }, bob.privateKey, 128),
27 subtle.deriveBits({
28 name: 'ECDH', namedCurve, public: bob.publicKey
29 }, alice.privateKey, 128),
30 ]);
31
32 assert(secret1 instanceof ArrayBuffer);
33 assert(secret2 instanceof ArrayBuffer);
34 assert.deepStrictEqual(secret1, secret2);
35 }
36
37 test('P-521').then(common.mustCall());
38}

Callers 1

Calls 5

encodeMethod · 0.95
allMethod · 0.80
assertFunction · 0.50
toStringMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…