ML-KEM Encapsulate
Encapsulates a shared key against recipient public key
Overview
Generates a fresh 32-byte (256-bit) post-quantum shared secret and encapsulates it against the recipient's ML-KEM public key (NIST FIPS 203), outputting both the 32-byte Shared Key (for the sender) and the encapsulated Ciphertext (to transmit to the recipient for decapsulation).
Ciphertext sizes are 768 bytes for ML-KEM-512, 1,088 bytes for ML-KEM-768, and 1,568 bytes for ML-KEM-1024.
When to Use
- Establishing a 32-byte quantum-resistant symmetric session key with a recipient holding the corresponding ML-KEM secret key.
Parameter Configuration
| Parameter (ID) | Type & Default | Visibility Condition | Description & Options |
|---|---|---|---|
Variantvariant |
selectDefault: 768 |
Always visible | Must match the ML-KEM security level of the connected Recipient Public Key (512, 768, or 1024).
|
Port I/O Specification
See Ports & Connections for general wiring rules, data type colors, and dynamic port creation.
Input Ports
Port Nature: Fixed Input Ports (1 total).
| Port Name | Port ID | Data Type | Required | Visibility Condition | Description |
|---|---|---|---|---|---|
Recipient Public Key |
publicKey |
Bytes |
Required | Always visible | Recipient's ML-KEM encapsulation public key (800B, 1184B, or 1568B depending on variant). |
Output Ports
Port Nature: Fixed Output Ports (2 total).
| Port Name | Port ID | Data Type | Visibility Condition | Description |
|---|---|---|---|---|
Shared Key |
sharedSecret |
Bytes |
Always visible | Generated 32-byte shared secret key (ready for use with AES-256, ChaCha20-Poly1305, or HKDF). |
Ciphertext |
ciphertext |
Bytes |
Always visible | Encapsulated KEM ciphertext (768B, 1088B, or 1568B) to send to ML-KEM Decapsulate. |
Error Cases
When any of the following conditions occurs at runtime, this node transitions to an ERROR state and downstream nodes connected to its outputs do not execute.
| Error Code | Default Engine Message | Trigger Condition |
|---|---|---|
INVALID_KEY_MATERIAL |
Invalid key length or format | Raised when Recipient Public Key length does not match the selected ML-KEM variant or fails FIPS 203 modulus check. |
Examples
Encapsulating a 32-Byte Key with ML-KEM-768
Encapsulate a shared key and encrypt a message with AES-256-GCM.
- Connect
Public Keyfrom ML-KEM KeyGen toRecipient Public Key. - Connect
Shared Keyto theKeyport of AES Encrypt, and sendCiphertextto ML-KEM Decapsulate.