pub fn diffie_hellman<C>(
secret_key: impl Borrow<NonZeroScalar<C>>,
public_key: impl Borrow<AffinePoint<C>>,
) -> SharedSecret<C>where
C: Curve + ProjectiveArithmetic,
Expand description
Low-level Elliptic Curve Diffie-Hellman (ECDH) function.
Whenever possible, we recommend using the high-level ECDH ephemeral API
provided by EphemeralSecret
.
However, if you are implementing a protocol which requires a static scalar
value as part of an ECDH exchange, this API can be used to compute a
SharedSecret
from that value.
Note that this API operates on the low-level NonZeroScalar
and
AffinePoint
types. If you are attempting to use the higher-level
SecretKey
and PublicKey
types, you will
need to use the following conversions:
ⓘ
let shared_secret = elliptic_curve::ecdh::diffie_hellman(
secret_key.to_nonzero_scalar(),
public_key.as_affine()
);