Trait hpke::kem::Kem

source ·
pub trait Kem: Sized {
    type PublicKey: Clone + Debug + PartialEq + Eq + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>;
    type PrivateKey: Clone + PartialEq + Eq + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>;
    type EncappedKey: Clone + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>;

    const KEM_ID: u16;

    // Required methods
    fn sk_to_pk(sk: &Self::PrivateKey) -> Self::PublicKey;
    fn derive_keypair(ikm: &[u8]) -> (Self::PrivateKey, Self::PublicKey);

    // Provided method
    fn gen_keypair<R: CryptoRng + RngCore>(
        csprng: &mut R
    ) -> (Self::PrivateKey, Self::PublicKey) { ... }
}
Expand description

Represents authenticated encryption functionality

Required Associated Types§

source

type PublicKey: Clone + Debug + PartialEq + Eq + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>

The key exchange’s public key type. If you want to generate a keypair, see Kem::gen_keypair or Kem::derive_keypair

source

type PrivateKey: Clone + PartialEq + Eq + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>

The key exchange’s private key type. If you want to generate a keypair, see Kem::gen_keypair or Kem::derive_keypair

source

type EncappedKey: Clone + Serializable + Deserializable + SerdeSerialize + for<'a> SerdeDeserialize<'a>

The encapsulated key for this KEM. This is used by the recipient to derive the shared secret.

Required Associated Constants§

source

const KEM_ID: u16

The algorithm identifier for a KEM implementation

Required Methods§

source

fn sk_to_pk(sk: &Self::PrivateKey) -> Self::PublicKey

Computes the public key of a given private key

source

fn derive_keypair(ikm: &[u8]) -> (Self::PrivateKey, Self::PublicKey)

Deterministically derives a keypair from the given input keying material

Requirements

This keying material SHOULD have as many bits of entropy as the bit length of a secret key, i.e., 8 * Self::PrivateKey::size(). For X25519 and P-256, this is 256 bits of entropy.

Provided Methods§

source

fn gen_keypair<R: CryptoRng + RngCore>( csprng: &mut R ) -> (Self::PrivateKey, Self::PublicKey)

Generates a random keypair using the given RNG

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Kem for DhP256HkdfSha256

§

type PublicKey = <DhP256 as DhKeyExchange>::PublicKey

§

type PrivateKey = <DhP256 as DhKeyExchange>::PrivateKey

§

type EncappedKey = EncappedKey

source§

const KEM_ID: u16 = 16u16

source§

impl Kem for DhP384HkdfSha384

§

type PublicKey = <DhP384 as DhKeyExchange>::PublicKey

§

type PrivateKey = <DhP384 as DhKeyExchange>::PrivateKey

§

type EncappedKey = EncappedKey

source§

const KEM_ID: u16 = 17u16

source§

impl Kem for X25519HkdfSha256

§

type PublicKey = <X25519 as DhKeyExchange>::PublicKey

§

type PrivateKey = <X25519 as DhKeyExchange>::PrivateKey

§

type EncappedKey = EncappedKey

source§

const KEM_ID: u16 = 32u16