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 persistence.
To perform an ephemeral Diffie-Hellman exchange, do the following:
- Have each participant generate an
EphemeralSecretvalue using theGeneratetrait - Compute the
PublicKeyfor that value - Have each peer provide their
PublicKeyto their counterpart - Use
EphemeralSecretand the other participant’sPublicKeyto compute aSharedSecretvalue using theEphemeralSecret::diffie_hellmanfunction
§⚠️ 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 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.
Trait Implementations§
Source§impl<C: CurveArithmetic> Debug for EphemeralSecret<C>
impl<C: CurveArithmetic> Debug for EphemeralSecret<C>
Source§impl<C> Drop for EphemeralSecret<C>where
C: CurveArithmetic,
impl<C> Drop for EphemeralSecret<C>where
C: CurveArithmetic,
Source§impl<C> From<&EphemeralSecret<C>> for PublicKey<C>where
C: CurveArithmetic,
impl<C> From<&EphemeralSecret<C>> for PublicKey<C>where
C: CurveArithmetic,
Source§fn from(ephemeral_secret: &EphemeralSecret<C>) -> Self
fn from(ephemeral_secret: &EphemeralSecret<C>) -> Self
Converts to this type from the input type.
Source§impl<C> Generate for EphemeralSecret<C>where
C: CurveArithmetic,
impl<C> Generate for EphemeralSecret<C>where
C: CurveArithmetic,
Source§fn try_generate_from_rng<R: TryCryptoRng + ?Sized>(
rng: &mut R,
) -> Result<Self, R::Error>
fn try_generate_from_rng<R: TryCryptoRng + ?Sized>( rng: &mut R, ) -> Result<Self, R::Error>
Generate random key using the provided
TryCryptoRng. Read moreSource§fn generate_from_rng<R>(rng: &mut R) -> Self
fn generate_from_rng<R>(rng: &mut R) -> Self
Generate random key using the provided
CryptoRng.Source§impl<C> Zeroize for EphemeralSecret<C>where
C: CurveArithmetic,
impl<C> Zeroize for EphemeralSecret<C>where
C: CurveArithmetic,
impl<C> ZeroizeOnDrop for EphemeralSecret<C>where
C: CurveArithmetic,
Auto Trait Implementations§
impl<C> Freeze for EphemeralSecret<C>
impl<C> RefUnwindSafe for EphemeralSecret<C>
impl<C> Send for EphemeralSecret<C>
impl<C> Sync for EphemeralSecret<C>
impl<C> Unpin for EphemeralSecret<C>
impl<C> UnsafeUnpin for EphemeralSecret<C>
impl<C> UnwindSafe for EphemeralSecret<C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more