KeyExchange

Trait KeyExchange 

Source
pub trait KeyExchange {
    type SKey: Clone + ToBytes + FromBytes;
    type PubKey: Clone + ToBytes + FromBytes;
    type CompSecret: ToBytes;

    // Required methods
    fn generate_private_key(seed: [u8; 32]) -> Self::SKey;
    fn generate_public_key(sk: &Self::SKey) -> Self::PubKey;
    fn generate_shared_secret(
        sk: &Self::SKey,
        pk: &Self::PubKey,
    ) -> Result<Self::CompSecret>;
}
Expand description

A trait to describe the types, methods and functions of a key-exhange for a curve

Required Associated Types§

Source

type SKey: Clone + ToBytes + FromBytes

Secret key type

Source

type PubKey: Clone + ToBytes + FromBytes

Public key type

Source

type CompSecret: ToBytes

Shared Secret type

Required Methods§

Source

fn generate_private_key(seed: [u8; 32]) -> Self::SKey

A function to generate a random private key, given a 32 byte seed value.

Source

fn generate_public_key(sk: &Self::SKey) -> Self::PubKey

A method to generate the public key, given a private key.

Source

fn generate_shared_secret( sk: &Self::SKey, pk: &Self::PubKey, ) -> Result<Self::CompSecret>

A method to compute the shared secret, given a private key and public key.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§