Hybrid KEM Encapsulate
Encapsulates shared secret using hybrid X25519 + ML-KEM-768 recipient public key
Overview
Performs hybrid key encapsulation against a recipient's 1,216-byte X25519 + ML-KEM-768 public key: generates an ephemeral X25519 keypair to compute the X25519 ECDH shared secret, encapsulates an ML-KEM-768 shared secret, and combines both shared secrets via SHA-256 / HKDF into a single 32-byte Shared Secret.
Emits the 32-byte combined Shared Secret alongside the 1,120-byte Hybrid Ciphertext (32B ephemeral X25519 public key || 1,088B ML-KEM-768 ciphertext).
When to Use
- Encapsulating a quantum-resilient 32-byte session key for a recipient holding a hybrid secret key from Hybrid KEM KeyGen.
Parameter Configuration
Hybrid KEM Encapsulate has no configurable parameters.
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 1,216-byte Hybrid Public Key. |
Output Ports
Port Nature: Fixed Output Ports (2 total).
| Port Name | Port ID | Data Type | Visibility Condition | Description |
|---|---|---|---|---|
Shared Secret |
sharedSecret |
Bytes |
Always visible | Combined 32-byte shared secret derived from both X25519 and ML-KEM-768 components. |
Hybrid Ciphertext |
ciphertext |
Bytes |
Always visible | 1,120-byte composite ciphertext (32B X25519 ephemeral public key || 1,088B ML-KEM-768 ciphertext). |
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 is not 1,216 bytes or contains an invalid ML-KEM-768 / X25519 public key component. |
Examples
Hybrid Key Encapsulation for AES-256-GCM
Encapsulate a 32-byte hybrid key and use it to encrypt a message.
- Connect
Hybrid Public Keyfrom Hybrid KEM KeyGen toRecipient Public Key. - Wire
Shared Secretto AES Encrypt andHybrid Ciphertextto Hybrid KEM Decapsulate.