pub trait Encryptor {
// Required methods
fn generate_keypair(&self) -> Result<KeyPair, CryptoError>;
fn encapsulate(
&self,
public_key: &[u8],
) -> Result<(Bytes, Bytes), CryptoError>;
fn decapsulate(
&self,
secret_key: &[u8],
ciphertext: &[u8],
) -> Result<Bytes, CryptoError>;
}Expand description
Key encapsulation mechanism (KEM) port — ML-KEM-1024.
All operations are constant-time with respect to secret key material.
Required Methods§
Sourcefn generate_keypair(&self) -> Result<KeyPair, CryptoError>
fn generate_keypair(&self) -> Result<KeyPair, CryptoError>
Generate a fresh key pair.
§Errors
Returns CryptoError::KeyGenFailed if the RNG or parameter
validation fails.
Sourcefn encapsulate(&self, public_key: &[u8]) -> Result<(Bytes, Bytes), CryptoError>
fn encapsulate(&self, public_key: &[u8]) -> Result<(Bytes, Bytes), CryptoError>
Encapsulate a shared secret using the recipient’s public key.
Returns (ciphertext, shared_secret).
§Errors
Returns CryptoError::EncapsulationFailed on invalid key material.
Sourcefn decapsulate(
&self,
secret_key: &[u8],
ciphertext: &[u8],
) -> Result<Bytes, CryptoError>
fn decapsulate( &self, secret_key: &[u8], ciphertext: &[u8], ) -> Result<Bytes, CryptoError>
Decapsulate a shared secret using the holder’s secret key.
§Errors
Returns CryptoError::DecapsulationFailed on invalid key or
ciphertext.