FdiffieHellman
Bun

function

crypto.diffieHellman

function diffieHellman(
options: { privateKey: KeyObject; publicKey: KeyObject }
): Buffer;

Computes the Diffie-Hellman secret based on a privateKey and a publicKey. Both keys must have the same asymmetricKeyType, which must be one of 'dh' (for Diffie-Hellman), 'ec', 'x448', or 'x25519' (for ECDH).

If the callback function is provided this function uses libuv's threadpool.

function diffieHellman(
options: { privateKey: KeyObject; publicKey: KeyObject },
callback: (err: null | Error, secret: Buffer) => void
): void;

Computes the Diffie-Hellman secret based on a privateKey and a publicKey. Both keys must have the same asymmetricKeyType, which must be one of 'dh' (for Diffie-Hellman), 'ec', 'x448', or 'x25519' (for ECDH).

If the callback function is provided this function uses libuv's threadpool.