### from Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.PublicKey.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Constructs a PublicKey from a 32-byte array. ```APIDOC ## pub fn from(bytes: [u8; 32]) -> PublicKey ### Description Given a byte array, construct a x25519 PublicKey. ``` -------------------------------- ### Add x25519-dalek dependency Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html?search= Include this dependency in your Cargo.toml file to use the crate. ```toml [dependencies] x25519-dalek = "3.0.0" ``` -------------------------------- ### ReusableSecret Methods Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.ReusableSecret.html?search= Methods for performing Diffie-Hellman key agreement and generating new secret keys. ```rust pub fn diffie_hellman(&self, their_public: &PublicKey) -> SharedSecret ``` ```rust pub fn random_from_rng(csprng: &mut R) -> Self ``` ```rust pub fn random() -> Self ``` -------------------------------- ### PublicKey Methods Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.PublicKey.html?search= Methods available on the PublicKey struct for byte conversion. ```APIDOC ## pub fn to_bytes(&self) -> [u8; 32] ### Description Convert this public key to a byte array. ## pub fn as_bytes(&self) -> &[u8; 32] ### Description View this public key as a byte array. ``` -------------------------------- ### as_bytes Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.PublicKey.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns a reference to the public key as a 32-byte array. ```APIDOC ## pub fn as_bytes(&self) -> &[u8; 32] ### Description View this public key as a byte array. ``` -------------------------------- ### StaticSecret Methods Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.StaticSecret.html?search= Methods for performing key agreement, generating keys from RNG, and accessing key bytes. ```rust pub fn diffie_hellman(&self, their_public: &PublicKey) -> SharedSecret ``` ```rust pub fn random_from_rng(csprng: &mut R) -> Self ``` ```rust pub fn random() -> Self ``` ```rust pub fn to_bytes(&self) -> [u8; 32] ``` ```rust pub fn as_bytes(&self) -> &[u8; 32] ``` -------------------------------- ### PublicKey Construction Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.PublicKey.html?search= Methods for constructing a PublicKey from bytes or secret keys. ```APIDOC ## impl From<[u8; 32]> for PublicKey ### Description Given a byte array, construct a x25519 PublicKey. ## impl<'a> From<&'a EphemeralSecret> for PublicKey ### Description Given an x25519 EphemeralSecret key, compute its corresponding PublicKey. ``` -------------------------------- ### Perform X25519 Key Exchange Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/fn.x25519.html Demonstrates generating key pairs and computing a shared secret using the raw x25519 function. ```rust use getrandom::{SysRng, rand_core::UnwrapErr}; use x25519_dalek::x25519; use x25519_dalek::StaticSecret; use x25519_dalek::PublicKey; let mut rng = UnwrapErr(SysRng); // Generate Alice's key pair. let alice_secret = StaticSecret::random_from_rng(&mut rng); let alice_public = PublicKey::from(&alice_secret); // Generate Bob's key pair. let bob_secret = StaticSecret::random_from_rng(&mut rng); let bob_public = PublicKey::from(&bob_secret); // Alice and Bob should now exchange their public keys. // Once they've done so, they may generate a shared secret. let alice_shared = x25519(alice_secret.to_bytes(), bob_public.to_bytes()); let bob_shared = x25519(bob_secret.to_bytes(), alice_public.to_bytes()); assert_eq!(alice_shared, bob_shared); ``` -------------------------------- ### StaticSecret Methods Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.StaticSecret.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Methods available for interacting with StaticSecret instances. ```APIDOC ## fn as_ref(&self) -> &[u8] View this key as a byte array. ## fn from(bytes: [u8; 32]) -> StaticSecret Load a secret key from a byte array. ## fn from(secret: &'a StaticSecret) -> PublicKey Given an x25519 StaticSecret key, compute its corresponding PublicKey. ``` -------------------------------- ### Generate Alice's ephemeral keys Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html?search=std%3A%3Avec Create a random ephemeral secret and derive the corresponding public key. ```rust use x25519_dalek::{EphemeralSecret, PublicKey}; let alice_secret = EphemeralSecret::random(); let alice_public = PublicKey::from(&alice_secret); ``` -------------------------------- ### PublicKey::from Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.PublicKey.html?search=u32+-%3E+bool Constructs a PublicKey from a byte array or a secret key. ```APIDOC ## impl From<[u8; 32]> for PublicKey ### Description Given a byte array, construct a x25519 PublicKey. ``` -------------------------------- ### pub fn x25519(k: [u8; 32], u: [u8; 32]) -> [u8; 32] Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/fn.x25519.html Performs the X25519 Diffie-Hellman key exchange using a secret key and a public key (or basepoint). ```APIDOC ## pub fn x25519(k: [u8; 32], u: [u8; 32]) -> [u8; 32] ### Description The bare, byte-oriented x25519 function, exactly as specified in RFC7748. This can be used with X25519_BASEPOINT_BYTES for scenarios where the higher-level ephemeral DH API is not suitable. ### Parameters - **k** ([u8; 32]) - The secret key bytes. - **u** ([u8; 32]) - The public key bytes or basepoint. ### Returns - **[u8; 32]** - The resulting shared secret bytes. ``` -------------------------------- ### From<&ReusableSecret> for PublicKey Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.ReusableSecret.html?search=std%3A%3Avec Converts a reference to a ReusableSecret into a PublicKey. ```APIDOC ## From<&ReusableSecret> for PublicKey ### Description Computes the corresponding PublicKey from a given x25519 ReusableSecret. ### Signature fn from(secret: &ReusableSecret) -> PublicKey ### Parameters - **secret** (&ReusableSecret) - Required - The reusable secret key to convert. ``` -------------------------------- ### as_bytes Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.StaticSecret.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides a reference to the raw bytes of the secret key. ```APIDOC ## pub fn as_bytes(&self) -> &[u8; 32] ### Description Returns a reference to the 32-byte array representation of the secret key. ``` -------------------------------- ### StaticSecret::as_bytes Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.StaticSecret.html?search=u32+-%3E+bool Provides a reference to the raw bytes of the secret key. ```APIDOC ## pub fn as_bytes(&self) -> &[u8; 32] ### Description View this key as a byte array. ``` -------------------------------- ### to_bytes Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.PublicKey.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Converts the public key into a 32-byte array. ```APIDOC ## pub fn to_bytes(&self) -> [u8; 32] ### Description Converts this public key to a byte array. ``` -------------------------------- ### Generate Bob's ephemeral keys Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html?search=std%3A%3Avec Create a random ephemeral secret and derive the corresponding public key for the second party. ```rust let bob_secret = EphemeralSecret::random(); let bob_public = PublicKey::from(&bob_secret); ``` -------------------------------- ### Generate Ephemeral Keys Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html?search= Generate random ephemeral secret keys and derive corresponding public keys for Alice and Bob. ```rust use x25519_dalek::{EphemeralSecret, PublicKey}; let alice_secret = EphemeralSecret::random(); let alice_public = PublicKey::from(&alice_secret); ``` ```rust let bob_secret = EphemeralSecret::random(); let bob_public = PublicKey::from(&bob_secret); ``` -------------------------------- ### x25519(k: [u8; 32], u: [u8; 32]) -> [u8; 32] Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/fn.x25519.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Performs the X25519 key exchange using a secret key and a public key (or basepoint). ```APIDOC ## Function: x25519 ### Description The `x25519` function performs the bare, byte-oriented X25519 key exchange as specified in RFC7748. It is intended for use cases where the higher-level ephemeral Diffie-Hellman API is not applicable. ### Signature `pub fn x25519(k: [u8; 32], u: [u8; 32]) -> [u8; 32]` ### Parameters - **k** ([u8; 32]) - The secret key bytes. - **u** ([u8; 32]) - The public key bytes or basepoint. ### Returns - **[u8; 32]** - The resulting shared secret bytes. ### Example ```rust use x25519_dalek::x25519; let alice_shared = x25519(alice_secret.to_bytes(), bob_public.to_bytes()); let bob_shared = x25519(bob_secret.to_bytes(), alice_public.to_bytes()); assert_eq!(alice_shared, bob_shared); ``` ``` -------------------------------- ### PublicKey::from(&EphemeralSecret) Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html Derives a public key from an ephemeral secret key. ```APIDOC ## PublicKey::from(&EphemeralSecret) ### Description Derives the corresponding public key from an ephemeral secret key. ### Signature `impl From<&EphemeralSecret> for PublicKey` ``` -------------------------------- ### PublicKey::from(&EphemeralSecret) Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html?search=std%3A%3Avec Derives a public key from an ephemeral secret key. ```APIDOC ## PublicKey::from(&EphemeralSecret) ### Description Derives the corresponding public key from a given ephemeral secret key. ### Signature `impl From<&EphemeralSecret> for PublicKey` ``` -------------------------------- ### PublicKey::from(&EphemeralSecret) Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html?search=u32+-%3E+bool Derives a public key from an ephemeral secret key. ```APIDOC ## PublicKey::from(&EphemeralSecret) ### Description Derives the corresponding public key from an ephemeral secret key. ### Usage ```rust use x25519_dalek::{EphemeralSecret, PublicKey}; let secret = EphemeralSecret::random(); let public = PublicKey::from(&secret); ``` ``` -------------------------------- ### x25519(k: [u8; 32], u: [u8; 32]) -> [u8; 32] Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/fn.x25519.html?search=u32+-%3E+bool Performs the X25519 Diffie-Hellman key exchange using a secret key and a public key (or basepoint). ```APIDOC ## Function: x25519 ### Description The bare, byte-oriented x25519 function, exactly as specified in RFC7748. This can be used with X25519_BASEPOINT_BYTES for scenarios where the higher-level ephemeral DH API is not suitable. ### Signature `pub fn x25519(k: [u8; 32], u: [u8; 32]) -> [u8; 32]` ### Parameters - **k** ([u8; 32]) - The secret key bytes. - **u** ([u8; 32]) - The public key or basepoint bytes. ### Returns - **[u8; 32]** - The resulting shared secret bytes. ### Example ```rust use x25519_dalek::x25519; let alice_shared = x25519(alice_secret.to_bytes(), bob_public.to_bytes()); let bob_shared = x25519(bob_secret.to_bytes(), alice_public.to_bytes()); assert_eq!(alice_shared, bob_shared); ``` ``` -------------------------------- ### x25519 Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html The bare, byte-oriented x25519 function, exactly as specified in RFC7748. ```APIDOC ## x25519 ### Description The bare, byte-oriented x25519 function, exactly as specified in RFC7748. ``` -------------------------------- ### fn x25519 Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/fn.x25519.html?search=std%3A%3Avec Performs the X25519 Diffie-Hellman key exchange using a secret key and a public key (or basepoint). ```APIDOC ## fn x25519(k: [u8; 32], u: [u8; 32]) -> [u8; 32] ### Description The bare, byte-oriented x25519 function, exactly as specified in RFC7748. This function computes the shared secret given a secret key and a public key. ### Parameters - **k** ([u8; 32]) - The secret key bytes. - **u** ([u8; 32]) - The public key or basepoint bytes. ### Returns - **[u8; 32]** - The resulting shared secret bytes. ``` -------------------------------- ### Verify Shared Secret Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html?search= Verify that both parties have computed the same shared secret. ```rust assert_eq!(alice_shared_secret.as_bytes(), bob_shared_secret.as_bytes()); ``` -------------------------------- ### X25519_BASEPOINT_BYTES Definition Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/constant.X25519_BASEPOINT_BYTES.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E The byte array representation of the X25519 basepoint. ```rust pub const X25519_BASEPOINT_BYTES: [u8; 32]; ``` -------------------------------- ### PublicKey struct definition Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.PublicKey.html?search=std%3A%3Avec The primary structure representing a Diffie-Hellman public key. ```rust pub struct PublicKey(/* private fields */); ``` -------------------------------- ### diffie_hellman Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.StaticSecret.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Performs a Diffie-Hellman key agreement between the static secret and a provided public key to produce a SharedSecret. ```APIDOC ## pub fn diffie_hellman(&self, their_public: &PublicKey) -> SharedSecret ### Description Perform a Diffie-Hellman key agreement between the current StaticSecret and the provided PublicKey to produce a SharedSecret. ### Parameters - **their_public** (&PublicKey) - Required - The public key to perform the key agreement with. ``` -------------------------------- ### fn x25519 Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/fn.x25519.html?search= The x25519 function performs the X25519 key exchange using a secret key and a public key (or basepoint). ```APIDOC ## fn x25519(k: [u8; 32], u: [u8; 32]) -> [u8; 32] ### Description The bare, byte-oriented x25519 function, exactly as specified in RFC7748. This can be used with X25519_BASEPOINT_BYTES for scenarios requiring manual key exchange. ### Parameters - **k** ([u8; 32]) - The secret key bytes. - **u** ([u8; 32]) - The public key or basepoint bytes. ### Returns - **[u8; 32]** - The resulting shared secret bytes. ``` -------------------------------- ### SharedSecret Methods Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.SharedSecret.html?search= Methods available on the SharedSecret struct for handling key exchange results. ```APIDOC ## pub fn to_bytes(&self) -> [u8; 32] ### Description Convert this shared secret to a byte array. ## pub fn as_bytes(&self) -> &[u8; 32] ### Description View this shared secret key as a byte array. ## pub fn was_contributory(&self) -> bool ### Description Ensure in constant-time that this shared secret did not result from a key exchange with non-contributory behaviour. ### Returns Returns `true` if the key exchange was contributory (good), and `false` otherwise. ``` -------------------------------- ### ReusableSecret::random Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.ReusableSecret.html?search= Generates a new ReusableSecret using the system's default random number generator. Requires the 'getrandom' feature. ```APIDOC ## pub fn random() -> Self ### Description Generate a new `ReusableSecret`. Available on crate feature `getrandom` only. ``` -------------------------------- ### StaticSecret::random Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.StaticSecret.html?search=u32+-%3E+bool Generates a new StaticSecret using the system's default random number generator (requires getrandom feature). ```APIDOC ## pub fn random() -> Self ### Description Generate a new `StaticSecret`. ``` -------------------------------- ### StaticSecret Definition Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.StaticSecret.html The definition of the StaticSecret struct. ```rust pub struct StaticSecret(/* private fields */); ``` -------------------------------- ### AsRef<[u8]> for SharedSecret Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.SharedSecret.html?search=std%3A%3Avec Allows the SharedSecret to be viewed as a byte array. ```APIDOC ## fn as_ref(&self) -> &[u8] ### Description View this shared secret key as a byte array. ``` -------------------------------- ### EphemeralSecret::random() Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html?search=std%3A%3Avec Generates a new random ephemeral secret key for Diffie-Hellman key exchange. ```APIDOC ## EphemeralSecret::random() ### Description Generates a new random ephemeral secret key used for Diffie-Hellman key exchange. ### Signature `pub fn random() -> EphemeralSecret` ``` -------------------------------- ### EphemeralSecret::random() Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html?search=u32+-%3E+bool Generates a new random ephemeral secret key for Diffie-Hellman key exchange. ```APIDOC ## EphemeralSecret::random() ### Description Generates a new random ephemeral secret key used for Diffie-Hellman key exchange. ### Usage ```rust use x25519_dalek::EphemeralSecret; let secret = EphemeralSecret::random(); ``` ``` -------------------------------- ### ReusableSecret::diffie_hellman Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.ReusableSecret.html?search= Performs a Diffie-Hellman key agreement between the secret key and a provided public key. ```APIDOC ## pub fn diffie_hellman(&self, their_public: &PublicKey) -> SharedSecret ### Description Perform a Diffie-Hellman key agreement between `self` and `their_public` key to produce a `SharedSecret`. ### Parameters - **their_public** (&PublicKey) - The public key to perform the agreement with. ``` -------------------------------- ### x25519 Function Signature Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/fn.x25519.html?search=std%3A%3Avec The function signature for the bare, byte-oriented x25519 implementation. ```rust pub fn x25519(k: [u8; 32], u: [u8; 32]) -> [u8; 32] ``` -------------------------------- ### to_bytes Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.StaticSecret.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Extracts the raw bytes of the secret key for serialization purposes. ```APIDOC ## pub fn to_bytes(&self) -> [u8; 32] ### Description Extracts the 32-byte array representation of the secret key. ``` -------------------------------- ### StaticSecret::to_bytes Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.StaticSecret.html?search=u32+-%3E+bool Extracts the raw bytes of the secret key for serialization. ```APIDOC ## pub fn to_bytes(&self) -> [u8; 32] ### Description Extract this key’s bytes for serialization. ``` -------------------------------- ### EphemeralSecret::random() Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html Generates a new random ephemeral secret key for use in Diffie-Hellman key exchange. ```APIDOC ## EphemeralSecret::random() ### Description Generates a new random ephemeral secret key. ### Signature `pub fn random() -> EphemeralSecret` ``` -------------------------------- ### StaticSecret::random_from_rng Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.StaticSecret.html?search=u32+-%3E+bool Generates a new StaticSecret using a provided cryptographically secure random number generator. ```APIDOC ## pub fn random_from_rng(csprng: &mut R) -> Self ### Description Generate a new `StaticSecret` with the supplied RNG. ``` -------------------------------- ### EphemeralSecret::random Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.EphemeralSecret.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Generates a new EphemeralSecret using the system's default random number generator. Requires the 'getrandom' feature. ```APIDOC ### fn random() #### Description Generates a new `EphemeralSecret` using the system's default random number generator. This method is only available when the `getrandom` crate feature is enabled. #### Returns - **Self** - A new instance of `EphemeralSecret`. ``` -------------------------------- ### SharedSecret::as_bytes Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.SharedSecret.html Provides a reference to the shared secret as a 32-byte array. ```APIDOC ## fn as_bytes(&self) -> &[u8; 32] ### Description View this shared secret key as a byte array. ### Returns - **&[u8; 32]** - A reference to the shared secret byte array. ``` -------------------------------- ### EphemeralSecret::diffie_hellman Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.EphemeralSecret.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Performs a Diffie-Hellman key agreement, consuming the secret and producing a shared secret. ```APIDOC ### fn diffie_hellman(self, their_public: &PublicKey) #### Description Performs a Diffie-Hellman key agreement between the current `EphemeralSecret` and the provided public key. This method consumes the `EphemeralSecret` and wipes the key material after the operation. #### Parameters - **their_public** (&PublicKey) - The public key of the other party. #### Returns - **SharedSecret** - The resulting shared secret from the key agreement. ``` -------------------------------- ### Compute Shared Secret Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html?search= Compute the shared secret using the local secret key and the remote party's public key. ```rust let alice_shared_secret = alice_secret.diffie_hellman(&bob_public); ``` ```rust let bob_shared_secret = bob_secret.diffie_hellman(&alice_public); ``` -------------------------------- ### ReusableSecret::random_from_rng Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.ReusableSecret.html?search= Generates a new ReusableSecret using a provided cryptographically secure random number generator. ```APIDOC ## pub fn random_from_rng(csprng: &mut R) -> Self ### Description Generate a new `ReusableSecret` with the supplied RNG. ### Parameters - **csprng** (&mut R) - A cryptographically secure random number generator. ``` -------------------------------- ### EphemeralSecret::diffie_hellman(&PublicKey) Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html?search=u32+-%3E+bool Computes the shared secret using the ephemeral secret and the peer's public key. ```APIDOC ## EphemeralSecret::diffie_hellman(&PublicKey) ### Description Computes the shared secret by performing a Diffie-Hellman key exchange with a peer's public key. ### Usage ```rust let shared_secret = secret.diffie_hellman(&peer_public_key); ``` ``` -------------------------------- ### EphemeralSecret::diffie_hellman(&PublicKey) Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html Computes the shared secret using the ephemeral secret and the peer's public key. ```APIDOC ## EphemeralSecret::diffie_hellman(&PublicKey) ### Description Computes the shared secret by performing a Diffie-Hellman key exchange with the provided public key. ### Signature `pub fn diffie_hellman(&self, public_key: &PublicKey) -> SharedSecret` ``` -------------------------------- ### EphemeralSecret::diffie_hellman(&PublicKey) Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/index.html?search=std%3A%3Avec Computes the shared secret using the ephemeral secret and the peer's public key. ```APIDOC ## EphemeralSecret::diffie_hellman(&PublicKey) ### Description Performs the Diffie-Hellman key exchange by computing the shared secret using the local ephemeral secret and the peer's public key. ### Signature `pub fn diffie_hellman(&self, peer_public: &PublicKey) -> SharedSecret` ``` -------------------------------- ### ReusableSecret Definition Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.ReusableSecret.html?search= The definition of the ReusableSecret struct, which requires the reusable_secrets feature flag. ```rust pub struct ReusableSecret(/* private fields */); ``` -------------------------------- ### EphemeralSecret::random_from_rng Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.EphemeralSecret.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Generates a new EphemeralSecret using a provided cryptographically secure random number generator. ```APIDOC ### fn random_from_rng(csprng: &mut R) #### Description Generates a new `EphemeralSecret` using the supplied cryptographically secure random number generator. #### Parameters - **csprng** (&mut R) - A mutable reference to a random number generator implementing `CryptoRng`. #### Returns - **Self** - A new instance of `EphemeralSecret`. ``` -------------------------------- ### SharedSecret::to_bytes Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.SharedSecret.html Converts the shared secret to a 32-byte array. ```APIDOC ## fn to_bytes(&self) -> [u8; 32] ### Description Convert this shared secret to a byte array. ### Returns - **[u8; 32]** - The shared secret as a byte array. ``` -------------------------------- ### Define SharedSecret struct Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.SharedSecret.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E The definition of the SharedSecret struct, which contains private fields. ```rust pub struct SharedSecret(/* private fields */); ``` -------------------------------- ### EphemeralSecret Definition Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.EphemeralSecret.html?search=std%3A%3Avec The definition of the EphemeralSecret struct. ```rust pub struct EphemeralSecret(/* private fields */); ``` -------------------------------- ### SharedSecret::was_contributory Source: https://docs.rs/x25519-dalek/3.0.0/x25519_dalek/struct.SharedSecret.html Checks in constant-time if the shared secret resulted from a key exchange with contributory behavior. ```APIDOC ## fn was_contributory(&self) -> bool ### Description Ensure in constant-time that this shared secret did not result from a key exchange with non-contributory behaviour. ### Returns - **bool** - Returns true if the key exchange was contributory, and false otherwise. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.