pub trait MlKemOperations: Send + Sync {
// Required methods
fn generate_keypair(
&self,
) -> Result<(MlKemPublicKey, MlKemSecretKey), PqcError>;
fn encapsulate(
&self,
public_key: &MlKemPublicKey,
) -> Result<(MlKemCiphertext, SharedSecret), PqcError>;
fn decapsulate(
&self,
secret_key: &MlKemSecretKey,
ciphertext: &MlKemCiphertext,
) -> Result<SharedSecret, PqcError>;
}Expand description
ML-KEM operations trait
Required Methods§
Sourcefn generate_keypair(&self) -> Result<(MlKemPublicKey, MlKemSecretKey), PqcError>
fn generate_keypair(&self) -> Result<(MlKemPublicKey, MlKemSecretKey), PqcError>
Generate a new ML-KEM keypair
§Errors
Returns an error if:
- Random number generation fails
- Key generation algorithm fails
- Insufficient entropy is available
Sourcefn encapsulate(
&self,
public_key: &MlKemPublicKey,
) -> Result<(MlKemCiphertext, SharedSecret), PqcError>
fn encapsulate( &self, public_key: &MlKemPublicKey, ) -> Result<(MlKemCiphertext, SharedSecret), PqcError>
Encapsulate a shared secret
§Errors
Returns an error if:
- The public key is invalid or malformed
- Random number generation fails
- The encapsulation algorithm fails
Sourcefn decapsulate(
&self,
secret_key: &MlKemSecretKey,
ciphertext: &MlKemCiphertext,
) -> Result<SharedSecret, PqcError>
fn decapsulate( &self, secret_key: &MlKemSecretKey, ciphertext: &MlKemCiphertext, ) -> Result<SharedSecret, PqcError>
Decapsulate a shared secret
§Errors
Returns an error if:
- The secret key is invalid or malformed
- The ciphertext is invalid or malformed
- The decapsulation algorithm fails
- Key-ciphertext mismatch is detected