java.lang.Object
org.bouncycastle.pqc.crypto.mlkem.MLKEMGenerator

public class MLKEMGeneratorextends Object
Generator for ML-KEM encapsulated secrets. Creates encapsulated secrets for secure key exchange in post-quantum cryptography.
  • Field Details

  • Constructor Details

    • MLKEMGenerator

      public MLKEMGenerator(SecureRandom random)
      Creates a generator that draws its randomness from the given source.
      Parameters:
      random - the source of randomness the KEM engine is initialized from
  • Method Details

    • generateEncapsulated

      public SecretWithEncapsulation generateEncapsulated(AsymmetricKeyParameter recipientKey)
      Draws 32 fresh random bytes and encapsulates a shared secret for the recipient.
      Parameters:
      recipientKey - the recipient's ML-KEM public key, from which the parameter set and engine are taken
      Returns:
      the freshly drawn shared secret together with the ciphertext to send to the recipient
    • internalGenerateEncapsulated

      public SecretWithEncapsulation internalGenerateEncapsulated(AsymmetricKeyParameter recipientKey, byte[] randBytes)
      Encapsulates a secret using the supplied randomness instead of drawing fresh bytes.
      Parameters:
      recipientKey - the recipient's ML-KEM public key, from which the parameter set and engine are taken
      randBytes - the 32 bytes of randomness to encrypt with, instead of drawing fresh ones for reproducible tests
      Returns:
      the shared secret derived from randBytes together with the ciphertext to send to the recipient