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 is derivable by both parties, through this function. E.g.: Epk = esk * G // ephemeral keypair Pk = sk * G // recipient keypair Shared secret S = esk * Pk = sk * Epk // see how this function can be called with two different sets of inputs, depending on which secret the caller knows (either esk or sk)?