aztec-nr - noir_aztec::keys::ecdh_shared_secret

Function derive_ecdh_shared_secret

pub fn derive_ecdh_shared_secret(
    secret: EmbeddedCurveScalar,
    public_key: EmbeddedCurvePoint,
) -> EmbeddedCurvePoint

Computes a standard ECDH shared secret: secret * public_key = shared_secret.

The input secret is known only to one party. The output shared secret can be derived given knowledge of public_key's key-pair and the public ephemeral secret, using this same function (with reversed inputs).

E.g.: Epk = esk * G // ephemeral key-pair Pk = sk * G // recipient key-pair Shared secret S = esk * Pk = sk * Epk

See also: https://en.wikipedia.org/wiki/Elliptic-curve_Diffie%E2%80%93Hellman