Ed25519KeyPair

Type Alias Ed25519KeyPair 

Source
pub type Ed25519KeyPair = AsymmetricKey<VerifyingKey, SigningKey>;

Aliased Type§

pub struct Ed25519KeyPair {
    pub public_key: VerifyingKey,
    pub secret_key: Option<SigningKey>,
}

Fields§

§public_key: VerifyingKey§secret_key: Option<SigningKey>

Implementations§

Source§

impl Ed25519KeyPair

Source

pub fn get_x25519(&self) -> Result<X25519KeyPair, Error>

Returns the X25519 key pair corresponding to the Ed25519 key pair.

§Returns

A Result containing the X25519 key pair as X25519KeyPair or an Error.

Trait Implementations§

Source§

impl CoreSign for Ed25519KeyPair

Source§

fn sign(&self, payload: &[u8]) -> Result<Vec<u8>, Error>

Signs a payload using the secret key of the Ed25519KeyPair.

§Arguments
  • payload - The payload to sign.
§Returns

A Result containing the signature as bytes or an Error.

Source§

fn verify(&self, payload: &[u8], signature: &[u8]) -> Result<(), Error>

Verifies a payload using the public key of the Ed25519KeyPair.

§Arguments
  • payload - The payload to verify.
  • signature - The signature to verify against the payload.
§Returns

A Result containing (), or an Error if the verification fails.

Source§

impl Debug for Ed25519KeyPair

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 Generate for Ed25519KeyPair

Source§

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

Generates a new Ed25519 key pair.

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

§Returns

A new Ed25519KeyPair instance or an Error.

Source§

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

Generates a new Ed25519 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 Ed25519KeyPair instance.

Source§

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

Creates a new Ed25519KeyPair from a public key.

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

A new Ed25519KeyPair instance.

Source§

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

Creates a new Ed25519KeyPair from a secret key.

A public key will be derived from the secret key.

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

A new Ed25519KeyPair instance.

Source§

impl KeyMaterial for Ed25519KeyPair

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 Ed25519KeyPair

Source§

fn to_multikey(&self) -> String

Converts keypair into its multikey string
Source§

impl TryFrom<Jwk> for Ed25519KeyPair

Converts a Jwk to an Ed25519KeyPair.

Source§

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

Converts a Jwk to an Ed25519KeyPair.

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

A Result containing the converted Ed25519KeyPair or an Error.

Source§

type Error = Error

The type returned in the event of a conversion error.