ML-KEM-768
Purpose
When communicating with another party, you often need a way to establish a shared secret (symmetric) key without having an existing secure channel. An algorithm that allows this over a public (insecure) channel is called a key-establishment scheme.
Key encapsulation mechanisms (KEMs) are one type of key-establishment scheme, and they're the interface of choice for post-quantum algorithms, which protect against cryptographically relevant quantum computers (CRQCs). Even without a CRQC today, an adversary can capture encrypted data that relies on traditional key-establishment algorithms ready for decryption when such a CRQC becomes available (a store now, decrypt later attack).
Unlike a traditional key exchange, the sender's key pair isn't involved, a ciphertext needs to be sent to the recipient, and the shared secret is uniformly random. From the sending side, the algorithm is randomised rather than deterministic (the sender doesn't choose the shared secret).
Here is how it works when doing one trip of communication (real protocols often do multiple trips):
Key generation: the recipient generates a key pair and shares the public key with the sender.
Encapsulation: the sender uses the recipient's public key to generate a shared secret and an associated ciphertext. This ciphertext is sent to the recipient.
Decapsulation: the recipient uses the ciphertext and their private key to compute the same shared secret.
ML-KEM-768 is the middle (192-bit) security strength variant of ML-KEM, which is one of the algorithms standardised by NIST as part of the Post-Quantum Cryptography (PQC) Standardization (competition) process. This variant provides protection against cryptanalysis advancements compared to ML-KEM-512 whilst being lighter (smaller parameters/marginally faster) than ML-KEM-1024. All variants are faster than traditional key exchange algorithms (e.g., X25519) but have larger parameters.
Usage
GenerateKeyPair
Fills a span with a randomly generated private key and another span with the associated public key.
Exceptions
publicKey has a length not equal to PublicKeySize.
privateKey has a length not equal to PrivateKeySize.
Error generating key pair.
GenerateKeyPair
Fills a span with a private key generated using a random seed and another span with the associated public key.
Exceptions
publicKey has a length not equal to PublicKeySize.
privateKey has a length not equal to PrivateKeySize.
seed has a length not equal to SeedSize.
Error generating key pair from seed.
Encapsulate
Fills a span with the computed shared secret and another span with the ciphertext to send to the recipient based on the recipient's public key.
Exceptions
sharedSecret has a length not equal to SharedSecretSize.
ciphertext has a length not equal to CiphertextSize.
recipientPublicKey has a length not equal to PublicKeySize.
Invalid public key.
Decapsulate
Fills a span with the computed shared secret based on the recipient's private key and the ciphertext the recipient was sent.
Exceptions
sharedSecret has a length not equal to SharedSecretSize.
ciphertext has a length not equal to CiphertextSize.
recipientPrivateKey has a length not equal to PrivateKeySize.
Error performing decapsulation.
Constants
These are used for validation and/or save you defining your own constants.
Notes
Non-Interactive Pattern
This is a one-way pattern, so no back and forth between the sender and recipient is required. It's appropriate for offline applications (e.g., a file encryption program).
The recipient does not know who sent the message, and only the recipient can decrypt the message once the shared secret is erased from memory. This is the post-quantum equivalent of the N pattern. The security properties are discussed here.
The sender encapsulates to the recipient's static public key. They use the shared secret as input keying material to a KDF. The output keying material is used as the key to encrypt a message using an AEAD.
The KEM ciphertext is sent alongside the AEAD ciphertext to the recipient.
The recipient decapsulates using their static private key and the ciphertext from the sender. They use the shared secret to derive the same key and decrypt the AEAD ciphertext.
Interactive Patterns
These are two-way patterns, so back and forth between the sender and recipient is required. They are appropriate for online applications and can provide better security properties than the one-way patterns.
Bilateral Authenticated Key Establishment
Both parties are authenticated using static KEM key pairs (e.g., associated with certificates, with each other's certificates exchanged and verified before the below). This achieves weak forward secrecy due to ephemeral key pair involvement.
The sender generates an ephemeral key pair. They then encapsulate to the recipient's static public key. They send the ephemeral public key and static KEM ciphertext to the recipient.
The recipient encapsulates to the sender's static public key and encapsulates to the sender's ephemeral public key, sending both KEM ciphertexts to the sender. They also decapsulate the static KEM ciphertext from the sender.
The sender decapsulates the static and ephemeral KEM ciphertexts from the recipient.
Both parties now have three shared secrets - two static (each other) and one ephemeral (recipient to sender). These are combined using a KDF, with the output keying material used with an AEAD.
Last updated