Class MLKEMCompositeSecretBCPGKey

All Implemented Interfaces:
BCPGKey, org.bouncycastle.util.Encodable

public class MLKEMCompositeSecretBCPGKey extends OctetArrayBCPGKey
Secret key of the ML-KEM + ECDH composite encryption algorithms PublicKeyAlgorithmTags.MLKEM768_X25519 and PublicKeyAlgorithmTags.MLKEM1024_X448 (RFC 9980 sec. 4.3.2.2): the fixed-length ECDH secret key in the RFC 7748 encoding of its curve, followed by the 64 octet ML-KEM secret key in seed format - the concatenation of the values d and z of FIPS 203 ML-KEM.KeyGen, from which the decapsulation key is expanded with ML-KEM.KeyGen_internal before use.
See Also:
  • Field Details

    • MLKEM_SEED_LENGTH

      public static final int MLKEM_SEED_LENGTH
      Length of the ML-KEM secret key in seed format: d || z, 32 octets each.
      See Also:
  • Constructor Details

  • Method Details

    • getAlgorithm

      public int getAlgorithm()
      Return the public key algorithm ID this key belongs to.
      Returns:
      PublicKeyAlgorithmTags.MLKEM768_X25519 or PublicKeyAlgorithmTags.MLKEM1024_X448
    • getECDHSecretKey

      public byte[] getECDHSecretKey()
      Return the ECDH (X25519 or X448) secret key component.
      Returns:
      ECDH secret key in RFC 7748 encoding
    • getMLKEMSeed

      public byte[] getMLKEMSeed()
      Return the ML-KEM seed d || z.
      Returns:
      64 octet ML-KEM seed
    • getLength

      public static int getLength(int algorithm)
      Return the length of the algorithm-specific secret key material for the given composite algorithm.
      Parameters:
      algorithm - public key algorithm ID
      Returns:
      total octet length of the ECDH secret key and the ML-KEM seed
    • getECDHSecretKeyLength

      public static int getECDHSecretKeyLength(int algorithm)
      Return the length of the ECDH secret key component (RFC 9980 Table 3).
      Parameters:
      algorithm - public key algorithm ID
      Returns:
      32 for X25519, 56 for X448