pub struct EphemeralSecret<C>where
    C: CurveArithmetic,{
    scalar: NonZeroScalar<C>,
}Expand description
Ephemeral Diffie-Hellman Secret.
These are ephemeral “secret key” values which are deliberately designed to avoid being persisted.
To perform an ephemeral Diffie-Hellman exchange, do the following:
- Have each participant generate an 
EphemeralSecretvalue - Compute the 
PublicKeyfor that value - Have each peer provide their 
PublicKeyto their counterpart - Use 
EphemeralSecretand the other participant’sPublicKeyto compute aSharedSecretvalue. 
§⚠️ SECURITY WARNING ⚠️
Ephemeral Diffie-Hellman exchanges are unauthenticated and without a further authentication step are trivially vulnerable to man-in-the-middle attacks!
These exchanges should be performed in the context of a protocol which takes further steps to authenticate the peers in a key exchange.
Fields§
§scalar: NonZeroScalar<C>Implementations§
Source§impl<C> EphemeralSecret<C>where
    C: CurveArithmetic,
 
impl<C> EphemeralSecret<C>where
    C: CurveArithmetic,
Sourcepub fn random(rng: &mut impl CryptoRngCore) -> Self
 
pub fn random(rng: &mut impl CryptoRngCore) -> Self
Generate a cryptographically random EphemeralSecret.
Sourcepub fn public_key(&self) -> PublicKey<C>
 
pub fn public_key(&self) -> PublicKey<C>
Get the public key associated with this ephemeral secret.
The compress flag enables point compression.
Sourcepub fn diffie_hellman(&self, public_key: &PublicKey<C>) -> SharedSecret<C>
 
pub fn diffie_hellman(&self, public_key: &PublicKey<C>) -> SharedSecret<C>
Compute a Diffie-Hellman shared secret from an ephemeral secret and the public key of the other participant in the exchange.