use rand_core::{CryptoRng, Rng};
pub trait Kem {
type EncapsulationKey;
type DecapsulationKey;
type Ciphertext;
type SharedSecret;
type Error;
fn keygen<R: CryptoRng + Rng>(
rng: &mut R,
) -> Result<(Self::EncapsulationKey, Self::DecapsulationKey), Self::Error>;
fn encapsulate<R: CryptoRng + Rng>(
ek: &Self::EncapsulationKey,
rng: &mut R,
) -> Result<(Self::Ciphertext, Self::SharedSecret), Self::Error>;
fn decapsulate(
dk: &Self::DecapsulationKey,
ct: &Self::Ciphertext,
) -> Result<Self::SharedSecret, Self::Error>;
}
pub trait Encapsulate {
type SharedSecret;
type Ciphertext;
type Error;
fn encapsulate(
&self,
rng: &mut (impl CryptoRng + Rng),
) -> Result<(Self::Ciphertext, Self::SharedSecret), Self::Error>;
}
pub trait Decapsulate {
type SharedSecret;
type Ciphertext;
type Error;
fn decapsulate(&self, ct: &Self::Ciphertext) -> Result<Self::SharedSecret, Self::Error>;
}