ECDH

Class: ECDH

The ECDH class is a utility for creating Elliptic Curve Diffie-Hellman (ECDH) key exchanges.

Instances of the ECDH class can be created using the crypto.createECDH() function.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const crypto = require('crypto');
const assert = require('assert');
 
// Generate Alice's keys...
const alice = crypto.createECDH('secp521r1');
const alice_key = alice.generateKeys();
 
// Generate Bob's keys...
const bob = crypto.createECDH('secp521r1');
const bob_key = bob.generateKeys();
 
// Exchange and generate the secret...
const alice_secret = alice.computeSecret(bob_key);
const bob_secret = bob.computeSecret(alice_key);
 
assert(alice_secret, bob_secret);
  // OK
doc_Nodejs
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.