← Codes you can try

ML-KEM

A newer way for two devices to agree on a secret key, built on noisy maths.

ML-KEM, short for Module-Lattice-Based Key-Encapsulation Mechanism, is a standard from NIST, the US National Institute of Standards and Technology, written up as FIPS 203. This page explains the idea behind it. Try noisy equations, then share a secret with a toy version, and see what the real thing adds. MELKEM is a company name. It sounds like ML-KEM, but MELKEM Authenticator doesn’t use ML-KEM or post-quantum cryptography.

The tools on this page are a teaching toy with tiny numbers. They must not be used to protect anything. Don’t type anything private. Everything runs in your browser. Nothing you type or choose is sent or kept.

I Why it exists

Today’s key exchange rests on problems a quantum computer could solve

In the key exchange lesson, two people agree on a shared secret while everyone watches. The lesson uses remainders and powers. Work like that is hard for an ordinary computer to undo.

NIST’s standard names two kinds of problem that today’s common key-agreement methods rest on: discrete logarithms, which are remainders and powers like those in the lesson, and integer factoring. It says those methods are open to attack by a quantum computer that is capable enough. It says: If large-scale quantum computers are realized, the security of many commonly used public-key cryptosystems will be at risk. NIST’s news item of 27 October 2026 says quantum computers are still in development, and that a sufficiently powerful one would threaten today’s encryption methods.

The same news item names a risk called “harvest now, decrypt later”: someone saves scrambled data today and unscrambles it later, once quantum computers are powerful enough. NIST’s news item calls it one of the main reasons the move to new standards is urgent.

ML-KEM is the answer NIST standardized. It is built on a different kind of problem. The standard says its security is related to the presumed difficulty of a problem called Module Learning with Errors. A polynomial is a sum of powers of x with a number in front of each, like 3 + 5x + 2x². “Module” means the problem works on small groups of polynomials, instead of on single numbers. At present, NIST says, it is believed that ML-KEM holds up even against an attacker with a quantum computer.

“Believed” is NIST’s word, and it is worth reading closely. Nobody has proved that this problem is hard for every attacker. The standard came out of a public process that began with 82 candidate algorithms and went through three rounds of evaluation, FIPS 203 says. NIST says it will keep following new analysis, and that it will formally look at the standard again every five years. NIST’s own page for FIPS 203 also carries a planning note, dated 17 November 2025, that an issue will be corrected in a future update.

What a key-encapsulation mechanism does

ML-KEM is a key-encapsulation mechanism, or KEM. A KEM does not carry your message. It lets two parties agree on a shared secret key over a public channel, where anyone may be watching. Ordinary encryption then uses that key for the message itself.

  1. Alice makes two keys. The encapsulation key is public. The decapsulation key stays with her.
  2. Bob uses her encapsulation key to make a copy of a shared secret, and a ciphertext that wraps it. He sends her the ciphertext.
  3. Alice uses the ciphertext and her decapsulation key to get her own copy of the shared secret.

ML-KEM does not prove who is on the other end. NIST’s other two standards from the same release are for digital signatures, which are used to check identity.

II The idea in one picture

Learning with errors

The problem underneath is called learning with errors, or LWE. Regev introduced it in 2005, according to FIPS 203. Here is the idea.

Secret numbers and public multipliers make answers with noise added A box of secret numbers and a box of public multipliers feed into a step that adds a little noise. The result is a box of published answers. Someone who knows the secret can check the answers. Someone who does not has the noise in the way. Secret numbers kept private Public multipliers shared with all Add a little noise Published answers Know the secret: check each answer. It is just a little off. Don’t know it: the noise is in the way of working it out.
The picture is drawn in code.
  • Secret numbers. One person picks a few numbers and keeps them to themselves.
  • Public numbers. Many equations are published. Each one multiplies the secret numbers by public multipliers and adds them up.
  • Noise. Before an answer is published, a small random number is added to it. The published answer is a little off.

If you know the secret, checking is easy. Work out each equation and see that the published answer is just a little off. If you do not know the secret, the noise gets in the way. Without noise, a few equations give the secret away by plain algebra. With noise, the algebra goes wrong.

FIPS 203 puts it this way: The noise in the equations is such that standard algorithms (e.g., Gaussian elimination) are intractable.

All the numbers here are remainders. “97” means the number wraps round at 97, the way a clock wraps round at 12. The key exchange lesson uses the same idea.

III Part 1: noisy maths

Hide a secret in noisy equations

Choose two secret numbers and a noise size. The page publishes six noisy equations. Then play the attacker: guess the secret, or use the textbook method, or try every guess.

Hide a secret in noisy equations

Teaching toy, tiny numbers. It must not be used to protect anything.

1. Choose two secret numbers

Each published number is moved by up to this much. At 0 there is no noise.

3. See the published numbers

An onlooker sees the multipliers and the published numbers. The exact answers and the noise are shown here just so you can see what happened.

The six equations. Each one says: multiplier 1 (Mult. 1) times secret 1, plus multiplier 2 (Mult. 2) times secret 2, plus noise, written as a remainder after dividing by 97. Exact is the answer with no noise. Published is the number an onlooker sees.
No.Mult. 1Mult. 2ExactNoisePublished
1315880+181
2127726−125
364981+182
4452313−112
588402+13
669163−162

Each row is one equation, along the numbers 0 to 96. The ring is the exact answer. The filled dot is the published number. The shaded band is everywhere the exact answer could be, given the noise size.

4. Try to find the secret

Your guess against each published number. The gap is the published number take away what your guess gives, written from −48 to 48. Fits? says whether the gap is within the noise size.
No.PublishedGuess givesGapFits?
1810−16No
225025No
3820−15No
412012No
5303No
6620−35No

0 of 6 equations fit within the noise size of 1. This guess is not the secret.

What you just saw

With no noise, the textbook method finds the secret from two equations. With any noise in those two equations, the answer is wrong, and the page shows by how much. The noise carries straight through.

Trying every guess still works here. The toy has two secret numbers, so there are just 9,409 guesses, and a computer tries them all in a blink. That is why it is a toy. In ML-KEM-768 the secret is 768 numbers: three polynomials with 256 numbers each. Trying them one by one is out of the question. What NIST relies on is the presumed difficulty of the problem, not the size of one search.

IV Part 2: share a secret

Alice and Bob agree on a secret

Now use noisy equations to share a secret, in the same three steps as a real KEM. The toy shares four bits, and the page shows every number: the public multipliers, Alice’s secret and her noise, the fresh numbers Bob uses for each bit, and everything that is sent. Every sum is worked out as a remainder after dividing by 97, so you can check any row with a calculator. It opens on a finished example. Press the steps to run new ones with fresh random choices, and use the noise size to see what too much noise does.

Share a secret between Alice and Bob

Teaching toy, tiny numbers. It must not be used to protect anything.

The noise size is used the next time you press step 1 or step 2. Sizes 0, 1 and 2 always give matching copies, when step 1 and step 2 both use them. Try 4.

Step 1: Alice makes her keys

She picks small secret numbers s and small noise e. She publishes t, which is the public multipliers times s, plus e. Her secret numbers are the decapsulation key. The public multipliers and t are the encapsulation key.

Public multipliers (the same for everyone)
(31, 58) and (12, 77)
Alice’s secret numbers (kept)
(1, −2)
Alice’s noise (kept)
(1, −1)
Public numbers she sends (t)
(13, 51)

Step 2: Bob wraps a secret

Bob picks four random bits as his shared secret. For each bit he uses fresh small numbers, and makes a new noisy equation from t. He writes the bit as 0 or 48 and adds it in. The pair u and the number v for each bit are the ciphertext, which Bob sends to Alice.

Bob’s wrapped secret. Each bit gets its own fresh noise. The bit is written as 0 or 48, added in, and the whole thing is sent as a pair of public numbers u and a number v. The table also shows the fresh numbers Bob used for each bit: y, and two lots of noise.
BitBob’s value (kept)Bob’s fresh numbers (kept)u (sent)v (sent)
11 (written as 48)y (1, 0), noise (0, 1) and 1(31, 59)62
20 (written as 0)y (−1, 1), noise (1, 0) and −1(79, 19)37
31 (written as 48)y (0, 1), noise (−1, 1) and 0(11, 78)2
41 (written as 48)y (1, 1), noise (0, −1) and 1(43, 37)16

Step 3: Alice unwraps it

Alice’s unwrapping. Her number is v take away her secret numbers times u. It is 0 or 48 plus a little noise, and the noise left in it is shown beside it. She rounds her number to the nearer of 0 and 48.
BitAlice’s numberNoise in itNearer toAlice’s bitBob’s bit
152+44811
293−4000
350+24811
447−14811

Each row is one bit, along the numbers 0 to 96. The dot is Alice’s number. The two end bands round to 0, and the middle band rounds to 48. A dot in the wrong band is a bit that came out wrong.

Alice and Bob both have 1011. The noise moved every number a little, and rounding put each one back on 0 or 48.

Why there is rounding

When Alice unwraps a bit, she does not get exactly 0 or 48. She gets 0 or 48 plus a little noise, which the table shows beside her number. The noise left in it is a few small numbers multiplied together and added, so it stays small. She rounds to whichever of 0 and 48 is nearer, and that puts her back on Bob’s bit.

The rounding works while the noise left in Alice’s number stays under about 24, which is half the gap between 0 and 48. In this toy, that holds when both Alice’s keys and Bob’s wrapping use noise size 0, 1 or 2, and the most noise that can be left is 0, 7 or 18. At size 3 it can reach 33. Then Alice’s number can cross the half-way line and round the wrong way. At size 3 that is rare: about one run in 350. At size 4 it happens in roughly one run in ten. Set the noise size to 4, and press steps 1, 2 and 3 a few times, to see it. If you use a different size for step 1 and step 2, the page tells you which each used.

Real ML-KEM is built so this almost never happens. FIPS 203 gives the chance that the two copies differ, which it calls a decapsulation failure, as 2−138.8 for ML-KEM-512, 2−164.8 for ML-KEM-768 and 2−174.8 for ML-KEM-1024.

V What’s real and what’s the toy

What the real thing adds

The toy keeps the shape of ML-KEM and drops the rest. Here is how they compare.

This page’s toy next to ML-KEM as FIPS 203 specifies it.
WhatThis page’s toyML-KEM (FIPS 203)
NumbersWhole numbers, wrapping round at 97.Whole numbers, wrapping round at 3329.
What one “number” isA single number.A polynomial: a row of 256 numbers that are added and multiplied together as one object.
The secretPart 1: two numbers, each from 0 to 96. Part 2: two numbers, each from −2 to 2.A list of 2, 3 or 4 polynomials, so 512, 768 or 1,024 numbers.
The public multipliersFixed numbers: six pairs in Part 1, and a 2-by-2 block in Part 2.A square block of polynomials, rebuilt from a 32-byte public seed that travels with the encapsulation key.
The noiseWhole numbers, up to the noise size: at most 6 in Part 1 and 4 in Part 2.Small numbers with a bell-shaped spread (a centred binomial distribution) that depends on a size set by the parameter set.
The shared secretFour bits, chosen by Bob.256 bits (32 bytes). Bob picks a random 32-byte value, and the shared key and the noise are worked out from it and a hash of the encapsulation key (a hash is a short fingerprint worked out from data of any size), using the SHA-3 family.
RoundingAlice picks the nearer of 0 and 48.Each number is compressed to a few bits before it is sent, and the receiver works back from that.
A check at the endNone.Alice works out the ciphertext again from what she decoded and compares it. If it differs, she returns a hash of the ciphertext with a stored random value, instead of the decoded key. FIPS 203 calls this implicit rejection.
Where the randomness comes fromThe browser’s random numbers.An approved random bit source, with a strength of at least 128, 192 or 256 bits, depending on the parameter set.
How often the two copies differVisibly, once the noise size passes 2.About once in 2 to the power 138.8 (ML-KEM-512) to 2 to the power 174.8 (ML-KEM-1024).
Fast multiplicationNone needed.The number-theoretic transform, which makes multiplying polynomials much faster.
What it may be used forLearning. Nothing else.Key establishment, as the standard sets out.

The three sizes

ML-KEM comes in three parameter sets: ML-KEM-512, ML-KEM-768 and ML-KEM-1024. Every one uses the same number of coefficients in a polynomial (256), the same remainder (3329) and a 32-byte shared secret. They differ in how many polynomials make up the secret, how noisy it is, and how big the keys are. FIPS 203 says the sets run in order of rising strength and falling speed. NIST recommends ML-KEM-768 as the default.

The three ML-KEM parameter sets, from FIPS 203. Every set has 256 numbers in a polynomial, a remainder of 3329 and a 32-byte shared secret. FIPS 203 says each set is claimed to be in its security category.
SetNumbers in the secretNoise (η1, η2)Encapsulation key (bytes)Decapsulation key (bytes)Ciphertext (bytes)Claimed NIST security category
ML-KEM-5122 × 256 = 5123, 28001,6327681
ML-KEM-7683 × 256 = 7682, 21,1842,4001,0883
ML-KEM-10244 × 256 = 1,0242, 21,5683,1681,5685

The sizes are from FIPS 203, Tables 2 and 3. The security categories 1, 3 and 5 are NIST’s own scale, set out in its key management guidance and named in FIPS 203, which says each set is claimed to be in its category. We do not rank them here beyond what NIST says.

A word on how it is used

FIPS 203 says a KEM’s guarantees depend on certain conditions, such as keeping the random numbers, the decapsulation key and the shared secret private. NIST’s SP 800-227, published in September 2025, sets out recommendations for using KEMs. The standard also says that following it does not by itself make an implementation sound. That depends on how the software or hardware is built.

VI Where it is used

What the official pages say

This list has what we read on the organizations’ own pages, with the date each page shows, and nothing else. It is not a full list. We did not use news stories, copies or mirrors.

  • NIST, 13 August 2024. NIST published FIPS 203, along with two standards for digital signatures. NIST’s news release says FIPS 203 is intended as the primary standard for general encryption, and says the new standards are designed to withstand attack by a quantum computer. The same release encourages system administrators to start moving to them, because full integration takes time.
  • NIST, October 2026. NIST’s report on the transition (NIST IR 8547) says that, at this time, ML-KEM is the one approved post-quantum key-establishment scheme based on public-key cryptography. Another scheme, HQC, has been selected for standardization as an alternative. The report says NIST will deprecate quantum-vulnerable key-establishment methods after 2030 and disallow them after 2035, and that it recommends ML-KEM-768 as the default set. “Deprecated” means a method may still be used, but the data owner has to weigh the risk. “Disallowed” means it is no longer allowed under NIST standards. It also describes hybrid key exchange, which combines ML-KEM with a classical method.
  • NIST, 27 October 2026. NIST’s news item on that report says Executive Order 14412 requires federal high-value assets and high-impact systems to move to post-quantum key establishment by 2030, and to post-quantum digital signatures by 2031. It adds that the 2035 target set by a national security memorandum applies to federal systems, and that many organizations that work with the federal government will be affected as well. The order itself, signed on 22 June 2026, is on the White House’s site: Securing the Nation Against Advanced Cryptographic Attacks (opens in a new tab). It sets 31 December 2030 for that move to post-quantum key establishment, and leaves out national security systems.
  • Canadian Centre for Cyber Security, June 2025. Its roadmap for the Government of Canada sets April 2026 for departments to make an initial migration plan, the end of 2031 for high-priority systems and the end of 2035 for the rest. It is about post-quantum cryptography in general, and does not name ML-KEM.
  • OpenSSH, 9 April 2025. The release notes for OpenSSH 10.0 say the hybrid method mlkem768x25519-sha256 is now the default for key agreement in the ssh tool.
  • Cloudflare, 28 October 2025. Cloudflare’s blog reports that the majority of human-initiated traffic with Cloudflare is using post-quantum encryption. It says the hybrid key agreement X25519MLKEM768, which combines X25519 and ML-KEM-768, is “ready to use and is indeed quite widely deployed”.

VII For teachers

Teacher notes

  • Level. Senior secondary and up: Grades 11 and 12, and adults. It uses remainders and multiplication, and the idea of a vector as a short list of numbers.
  • Time. About 30 to 40 minutes. Allow more for a class that has not done the key exchange lesson, which comes before this one.
  • What students should take away.
    • Today’s common key agreement rests on problems that a large quantum computer could solve, and ML-KEM rests on a different problem.
    • Learning with errors hides a secret by adding small noise to equations that would otherwise give it away.
    • A KEM has three steps: make keys, wrap a secret, unwrap it. Rounding lets both sides land on the same answer despite the noise.
    • “Believed” is a different word from “proved”. NIST says it will keep watching new analysis.
    • The toy is not ML-KEM. It is a way to see the shape of the idea.

Questions to ask

  • In Part 1, why does the textbook method fail with noise, yet trying every guess works?
  • In Part 2, at what noise size did the two copies begin to differ? What would you change to fix it?
  • Why do you think NIST is moving to a new standard now, when the machine it worries about is not here yet?

VIII The lesson

The lesson

ML-KEM is one of the standards NIST has chosen to replace today’s key agreement, with one built on noisy equations. The toy shows the shape: a public key from a noisy equation, a wrapped secret from a fresh noisy equation, and rounding that cancels the noise. The real thing uses much larger structures and hashing, and it is worth reading from the source.

You can also try the key exchange that ML-KEM is meant to replace, the one-time pad, a code whose key is random and used once, or the fingerprint of a piece of data. To read about the standard in words, see our Note What is ML-KEM? And where the name MELKEM comes from.

This page explains how an idea works. It does not describe how any MELKEM app or website is built.

IX Sources

Sources

These pages were opened and read on 24 November 2026. The date each page shows is given. The short quotations are in quotation marks. The rest of the wording is ours.

Where the pages differ: FIPS 203 says NIST started its post-quantum standardization process in 2016. NIST’s news release says NIST began selecting and standardizing quantum-resistant algorithms in 2015, and refers to the call for submissions as 2016. Both give 82 algorithms assessed.

We did not use any page we could not open. No photographs are used: every picture is drawn in code.