Struct x25519_dalek::StaticSecret[][src]

pub struct StaticSecret(_);

A Diffie-Hellman secret key that can be used to compute multiple SharedSecrets.

This type is identical to the EphemeralSecret type, except that the StaticSecret::diffie_hellman method does not consume the secret key, and the type provides serialization methods to save and load key material. This means that the secret may be used multiple times (but does not have to be).

Some protocols, such as Noise, already handle the static/ephemeral distinction, so the additional guarantees provided by EphemeralSecret are not helpful or would cause duplicate code paths. In this case, it may be useful to

use x25519_dalek::StaticSecret as SecretKey;

since the only difference between the two is that StaticSecret does not enforce at compile-time that the key is only used once.


impl StaticSecret[src]

pub fn diffie_hellman(&self, their_public: &PublicKey) -> SharedSecret[src]

Perform a Diffie-Hellman key agreement between self and their_public key to produce a SharedSecret.

pub fn new<T: RngCore + CryptoRng>(csprng: T) -> Self[src]

Generate an x25519 key.

pub fn to_bytes(&self) -> [u8; 32][src]

Extract this key’s bytes for serialization.

Trait Implementations

impl Clone for StaticSecret[src]

impl Drop for StaticSecret[src]

impl<'a> From<&'a StaticSecret> for PublicKey[src]

fn from(secret: &'a StaticSecret) -> PublicKey[src]

Given an x25519 StaticSecret key, compute its corresponding PublicKey.

impl From<[u8; 32]> for StaticSecret[src]

fn from(bytes: [u8; 32]) -> StaticSecret[src]

Load a secret key from a byte array.

impl Zeroize for StaticSecret[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.