MlKemOperations

Trait MlKemOperations 

Source
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§

Source

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
Source

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
Source

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

Implementors§