Struct diem_sdk::crypto::x25519::x25519_dalek::StaticSecret
source · pub struct StaticSecret(_);
Expand description
A Diffie-Hellman secret key that can be used to compute multiple SharedSecret
s.
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_fiat::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.
Implementations§
source§impl StaticSecret
impl StaticSecret
sourcepub fn diffie_hellman(&self, their_public: &PublicKey) -> SharedSecret
pub fn diffie_hellman(&self, their_public: &PublicKey) -> SharedSecret
Perform a Diffie-Hellman key agreement between self
and
their_public
key to produce a SharedSecret
.
sourcepub fn new<T>(csprng: T) -> StaticSecretwhere
T: RngCore + CryptoRng,
pub fn new<T>(csprng: T) -> StaticSecretwhere T: RngCore + CryptoRng,
Generate an x25519 key.
Trait Implementations§
source§impl Clone for StaticSecret
impl Clone for StaticSecret
source§fn clone(&self) -> StaticSecret
fn clone(&self) -> StaticSecret
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Drop for StaticSecret
impl Drop for StaticSecret
source§impl<'a> From<&'a StaticSecret> for PublicKey
impl<'a> From<&'a StaticSecret> for PublicKey
source§fn from(secret: &'a StaticSecret) -> PublicKey
fn from(secret: &'a StaticSecret) -> PublicKey
Given an x25519 StaticSecret
key, compute its corresponding PublicKey
.