Moving Ephemeral Keygen to ML-KEM When the Entropy Path Can Fail
Every ML-KEM keypair is a deterministic function of two seeds, d and z, each 32 bytes. So the security of the key depends entirely on the moment those values leave the entropy source. That changes how the migration budget splits. The lattice arithmetic is cheap to adopt. The money goes into the entropy plumbing, the seed handling and the memory hygiene around it, and each line item should be defended by the failure it removes.
What the classical stack never told you
Most ECDH deployments drew ephemeral scalars from the operating system generator and never asked how well seeded it was at the moment of the call, so weak boot-time entropy degraded keys without any visible symptom. ML-KEM is less forgiving. The seed d is hashed with the SHA-3 family into the public matrix seed and the secret noise seed, so a repeated d across a cloned VM fleet produces identical keypairs. A weak z undermines implicit rejection, the mechanism that turns malformed ciphertexts into pseudorandom garbage instead of a decryption oracle. Paying for continuous entropy health testing is how you get detection for a failure class the old stack hid, and the measurable return is the number of hosts you can prove never minted a key from an uninitialized pool.
The decision rule
A raw TRNG never writes d or z directly: it seeds a validated deterministic generator, the generator's output becomes the seeds, and a tripped health test stalls new key generation rather than letting it continue on degraded output.
Keeping the service up while a component is down
The resilience design has three layers, and each one costs something you can measure. Hybrid key exchange combines X25519 and ML-KEM through a single KDF, so if the lattice implementation turns out to have a bug, the session still has classical protection. The price is larger handshakes, roughly an extra kilobyte per direction by our estimate, which you can track as fragmentation and retransmission rates on constrained links. On the entropy side, NIST's guidance on entropy sources and deterministic random bit generators expects repetition and proportion tests to run continuously. When those tests fail, the generator can keep serving from its last good seed until it reaches its reseed limit and then fail closed, which turns an entropy outage into a bounded availability window you can put an alarm on. Storing the private key as the seed pair rather than the expanded form allows a restarted process or a replaced HSM partition to rebuild the key deterministically, provided every load checks the expanded key against the seed. That check costs CPU on each load and catches silent corruption before it turns into failed decapsulations.
The part that hurts
Zero-trace scrubbing is where migrations stall, because managed runtimes copy buffers during garbage collection, the kernel can page them to swap, and crash handlers write them into core dumps, so the keygen boundary has to move into a native module or an HSM with locked pages and explicit zeroization. Some HSM firmware cannot import or export the seed format at all. On those devices the only route is to re-key the fleet, and that is a scheduling cost on top of the engineering one. By our estimate this boundary rewrite accounts for about a third of total migration effort, and it is the line item finance will challenge first. The defense is concrete: every copy you cannot scrub is an ephemeral key that outlives its session, and a key that outlives its session gives you no forward secrecy against an attacker who later images the host. Once the boundary is built, the next call is whether seeds at rest are worth the rebuild path, or whether the HSM should hold only expanded keys and accept that losing a partition means re-enrolment.
Technical FAQ: Is the kernel generator good enough to produce d and z?
Usually yes, provided its entropy source has been assessed and key generation blocks until the pool reports it is initialized. The real gap is evidence rather than algorithm quality: without health test telemetry you cannot show an auditor that a given seed came from a healthy source.