← Back to section · Standards & Specifications

How the KEM Interface Is Standardized: The Semantic Contract Behind Three Functions

KeyGen, Encaps and Decaps look simple, but a standard must pin down where randomness comes from, what happens on failure, and the byte representation of keys — reading, item by item, the contract FIPS 203 sets for the KEM interface.

Published 22 November 2026 · 6 min read · PQ Frontier

How the KEM Interface Is Standardized: The Semantic Contract Behind Three Functions
AI-generated site artwork
Video explainer · Algorithm Standards: the lattice behind parameters

The key-encapsulation mechanism (KEM) replaces traditional public-key encryption as the key-establishment primitive of the post-quantum era, and its interface has only three functions. On the surface this is a simplification; in fact the standardization body has no less to specify: each function’s inputs and outputs, where the randomness comes from, what happens on error, and what keys look like in memory and on the wire. The contract FIPS 203 sets for this interface deserves an item-by-item reading.

Three functions: an interface deliberately kept small

The KEM interface is KeyGen, Encaps and Decaps. KeyGen produces a key pair; Encaps takes the other party’s encapsulation key (public key), randomly generates a shared key and outputs the corresponding ciphertext; Decaps uses the decapsulation key (private key) to recover the same shared key from the ciphertext.

Compared with the interface of RSA public-key encryption, one thing is missing here: there is no entry point for “encrypt an arbitrary message.” The shared key can only be generated randomly inside Encaps; the caller cannot choose it. This removal is a deliberate tightening of semantics: a KEM promises only that “both parties obtain the same random key,” and uses beyond key agreement are excluded at the interface level. Protocol standards (such as key exchange in TLS) want exactly this semantics, so the KEM interface slots in seamlessly.

The randomness clauses: hard rules outside the interface

The random source is invisible in the signatures of the three functions, yet the standard text is very concrete about randomness. Key generation requires two independent 32-byte seeds d and z, supplied by an approved random bit generator; the random message m used in encapsulation likewise comes from a random source. The standard simultaneously specifies a back door for deterministic testing: during testing, these random quantities may be injected from outside so that test vectors can be reproduced — but that belongs to the testing interface, not the deployment interface.

Key generation expands the whole key pair deterministically from the seeds (d, z), which makes “the same seeds always yield the same key pair” a verifiable clause of the contract. The z seed has a second use: it takes no part in normal decapsulation, but it is the raw material from which implicit rejection derives the substitute key, and so it is written into a fixed position of the decapsulation key.

Failure semantics: decapsulation that never errors

The most distinctive clause of the KEM interface contract is that Decaps has no error return value. Whether the ciphertext was tampered with, truncated and padded, or is completely random, Decaps returns a shared key that looks normal — a substitute value derived from the z seed and a hash of the ciphertext. The caller cannot distinguish the “real key” from the “substitute key” by the return value; the key confirmation or first MAC check that the protocol layer performs afterwards will fail naturally, and the connection terminates.

Why does the standard prescribe such a roundabout failure behaviour? Because “returning an error” is itself information: if decapsulation gave distinguishable reactions to different failure causes, an adversary could use the KEM as an oracle to extract the private key bit by bit. Implicit rejection compresses all failures into the same silent outcome, and this semantics must be nailed down at the interface level — implementers must not “helpfully” add error codes. FIPS 203 additionally requires decapsulation to perform two input checks first (the validity of the ciphertext length and the key format), and a failed check takes the same rejection path.

Byte representation: the key format is part of the standard too

The interface contract also includes the byte-level layout of keys. The encapsulation key is the K-PKE public key concatenated with a 12-byte seed; the decapsulation key contains, in order, the K-PKE private key, a copy of the encapsulation key, the hash H(ek) of the encapsulation key, and the seed z — making its total length a little over twice the public key. Embedding the public key and its hash lets the re-encryption comparison during decapsulation be completed self-contained, without external inputs. Any implementation that privately adopts a different key serialization format fails the comparison against the standard test vectors immediately, and cross-vendor interoperability is out of the question.

The form of the shared key: the fixed 32-byte convention

The interface contract also covers the form of the output: the shared key output by all three ML-KEM parameter sets is uniformly 32 bytes. The parameter set affects only the sizes of keys and ciphertexts, not the length of the shared key. This convention greatly simplifies protocol-layer design — when protocols such as TLS or SSH feed a KEM output into their key schedule, they need no separate handling paths for different parameter sets, and combiners that concatenate a classical shared secret with a post-quantum one in hybrid modes face tidy inputs.

The standard is equally clear about the shared key’s status: it is “keying material,” not a session key ready for direct use, and protocols must pass it through a key derivation function. The scope clauses of FIPS 203 draw this boundary sharply — the KEM is responsible only for giving both parties the same stretch of high-entropy bytes; everything after that belongs to protocol standards. This division of labour between standards (algorithm standards govern primitives, protocol standards govern composition) is the organizing pattern of the whole post-quantum standards family.

Input checks: the “gatekeeping” clauses of the interface contract

Beyond failure semantics, FIPS 203 also prescribes explicit input checks at the interface layer. Before decapsulation begins, the implementation must verify that the hash of the public key embedded in the decapsulation key matches the public key itself (guarding against corrupted or mismatched key material), and that the ciphertext length matches the parameter set; on the encapsulation side, the standard likewise specifies the format checks that may be applied to the encapsulation key. These checks share one trait: the disposition of a failed check is not an error code, but uniform entry into the rejection path.

Writing the gatekeeping clauses into the interface standard rather than leaving them to implementers’ discretion is a lesson learned from history: in the traditional public-key era, libraries handled invalid inputs in wildly different ways, and some of those dispositions later proved exploitable by adversaries. The interface contract settles “what input is legal, and what happens when it is not” once and for all, leaving no room for later improvisation.

Conclusion

The lesson of KEM interface standardization is: the smaller the interface, the more completely the contract must be written. Behind the three functions, the standard specifies the source and quality of randomness, a uniform behaviour on failure, and the byte-by-byte format of keys. Only with these three nailed down can any two independent implementations be used interchangeably inside a protocol — which is the entire purpose of an interface standard.

Tags: KEMinterface standardFIPS 203implicit rejection