pub trait Kem {
// Required methods
fn generate_keypair(&self) -> Result<KemKeypair>;
fn encapsulate(
&self,
public_key: &KemPublicKey,
) -> Result<(Vec<u8>, Vec<u8>)>;
fn decapsulate(
&self,
secret_key: &KemSecretKey,
ciphertext: &[u8],
) -> Result<Vec<u8>>;
fn derive_public_key(
&self,
secret_key: &KemSecretKey,
) -> Result<KemPublicKey>;
fn auth_encapsulate(
&self,
sender_sk: &KemSecretKey,
recipient_pk: &KemPublicKey,
) -> Result<(Vec<u8>, Vec<u8>)>;
fn auth_decapsulate(
&self,
recipient_sk: &KemSecretKey,
ciphertext: &[u8],
sender_pk: &KemPublicKey,
) -> Result<Vec<u8>>;
}Expand description
Trait for key encapsulation mechanisms
Required Methods§
Sourcefn generate_keypair(&self) -> Result<KemKeypair>
fn generate_keypair(&self) -> Result<KemKeypair>
Generate a keypair
Sourcefn encapsulate(&self, public_key: &KemPublicKey) -> Result<(Vec<u8>, Vec<u8>)>
fn encapsulate(&self, public_key: &KemPublicKey) -> Result<(Vec<u8>, Vec<u8>)>
Encapsulate a shared secret
Sourcefn decapsulate(
&self,
secret_key: &KemSecretKey,
ciphertext: &[u8],
) -> Result<Vec<u8>>
fn decapsulate( &self, secret_key: &KemSecretKey, ciphertext: &[u8], ) -> Result<Vec<u8>>
Decapsulate a shared secret
Sourcefn derive_public_key(&self, secret_key: &KemSecretKey) -> Result<KemPublicKey>
fn derive_public_key(&self, secret_key: &KemSecretKey) -> Result<KemPublicKey>
Derive public key from secret key
Sourcefn auth_encapsulate(
&self,
sender_sk: &KemSecretKey,
recipient_pk: &KemPublicKey,
) -> Result<(Vec<u8>, Vec<u8>)>
fn auth_encapsulate( &self, sender_sk: &KemSecretKey, recipient_pk: &KemPublicKey, ) -> Result<(Vec<u8>, Vec<u8>)>
Authenticated encapsulation (RFC 9180 AuthEncap)
Sourcefn auth_decapsulate(
&self,
recipient_sk: &KemSecretKey,
ciphertext: &[u8],
sender_pk: &KemPublicKey,
) -> Result<Vec<u8>>
fn auth_decapsulate( &self, recipient_sk: &KemSecretKey, ciphertext: &[u8], sender_pk: &KemPublicKey, ) -> Result<Vec<u8>>
Authenticated decapsulation (RFC 9180 AuthDecap)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".