X25519KeyPair

Type Alias X25519KeyPair 

Source
pub type X25519KeyPair = AsymmetricKey<PublicKey, StaticSecret>;

Aliased Type§

pub struct X25519KeyPair {
    pub public_key: PublicKey,
    pub secret_key: Option<StaticSecret>,
}

Fields§

§public_key: PublicKey§secret_key: Option<StaticSecret>

Trait Implementations§

Source§

impl Debug for X25519KeyPair

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Returns a string representation of the public key.

This function is used to implement the fmt::Debug trait.

Source§

impl ECDH for X25519KeyPair

Source§

fn key_exchange(&self, key: &Self) -> Option<Vec<u8>>

Performs a key exchange using the Diffie-Hellman algorithm.

§Arguments
  • key - The public key of the other party.
§Returns

An optional vector of bytes representing the shared secret. If the secret key is not available, returns None.

Source§

impl Generate for X25519KeyPair

Source§

fn new() -> Result<X25519KeyPair, Error>

Generates a new X25519 key pair.

If the initial seed is empty or invalid, a random seed will be generated.

§Arguments
  • seed - The initial seed to use, or empty if none.
§Returns

A new X25519KeyPair instance.

Source§

fn new_with_seed(seed: &[u8]) -> Result<X25519KeyPair, Error>

Generates a new X25519 key pair with a seed.

If the seed is empty or invalid, generates a new seed.

§Arguments
  • seed - The initial seed to use.
§Returns

A new X25519KeyPair instance.

Source§

fn from_public_key(public_key: &[u8; 32]) -> Result<X25519KeyPair, Error>

Creates a new X25519KeyPair from a public key.

§Arguments
  • public_key - The bytes of the public key.
§Returns

A new X25519KeyPair instance.

Source§

fn from_secret_key(secret_key: &[u8; 32]) -> Result<X25519KeyPair, Error>

Creates a new X25519KeyPair from a secret key.

§Arguments
  • secret_key - The bytes of the secret key.
§Returns

A new X25519KeyPair instance.

Source§

impl KeyMaterial for X25519KeyPair

Source§

fn public_key_bytes(&self) -> Result<[u8; 32], Error>

Returns the bytes of the public key.

§Returns

A Result containing the bytes of the public key or an Error.

Source§

fn private_key_bytes(&self) -> Result<[u8; 32], Error>

Returns the bytes of the private key.

§Returns

A Result containing the bytes of the private key or an Error.

Source§

impl ToMultikey for X25519KeyPair

Source§

fn to_multikey(&self) -> String

Converts keypair into its multikey string
Source§

impl TryFrom<Jwk> for X25519KeyPair

Converts a Jwk to an X25519KeyPair.

Source§

fn try_from(jwk: Jwk) -> Result<Self, Self::Error>

Converts a Jwk to an X25519KeyPair.

§Arguments
  • jwk - The Jwk to convert.
§Returns

A Result containing the converted X25519KeyPair or an Error.

Source§

type Error = Error

The type returned in the event of a conversion error.