Secrets and errors

Draft

As this page loaded, it ran a key agreement built to survive quantum computers: three function calls and two messages leave two parties holding the same 32-byte secret, without those 32 bytes ever crossing the wire between them. The algorithm is ML-KEM-768, a United States federal standard since August 2024, and what ran here is the real algorithm at its full production size, written in plain JavaScript.

lanes   you                          the wire                         a server
        keyGen()
        decapsulation key dk
        2,400 bytes, kept      ──▶   encapsulation key ek
                                     1,184 bytes
                                                                      encaps(ek)
                                                                      shared secret K, 32 bytes
                               ◀──   ciphertext c
                                     1,088 bytes
        decaps(dk, c)
        shared secret K, 32 bytes    the same 32 bytes at both ends; they never cross the wire
scale   2,272 bytes cross the wire, 35.5 times the 64 bytes of an X25519 exchange (a share of 32 bytes each way)
eve     an eavesdropper sees the encapsulation key and the ciphertext, and lacks the decapsulation key
flip    with 1 bit of the 8,704 of the ciphertext flipped on the wire, decaps(dk, c) still returns 32 bytes,
        but not K (implicit rejection): the two ends hold different secrets
time    the live figure times 24 calls of each of the 3 in the reader's page and prints the means
(the live figure needs JavaScript; it runs ML-KEM-768 in the page and loads no data)
A key agreement with ML-KEM-768, the real algorithm, run in this page as it loaded. Green: the shared secret, the same 32 bytes at both ends, which never cross the wire. The strips are the encapsulation key and the ciphertext, every byte drawn (256 a row, darker for a larger byte); under each, at the same scale, the 32-byte share of an X25519 exchange. Step makes the three calls one at a time with fresh randomness, run again all three; flipping one bit of the ciphertext leaves the two ends with different secrets. Times are means of 24 calls in your browser.

What ran is a key-encapsulation mechanism (KEM), the form in which the new standards package key agreement. One side publishes an encapsulation key (its public key) while keeping a matching decapsulation key (its private key). The other side generates a fresh 32-byte secret, locks it inside a ciphertext using the encapsulation key, and sends that ciphertext back; only the decapsulation key can open the ciphertext and recover the same 32 bytes. The mechanism is ML-KEM (called Kyber before standardization), and 768 counts the unknown coordinates of its secret.National Institute of Standards and Technology, "Module-lattice-based key-encapsulation mechanism standard", FIPS 203, 13 August 2024. FIPS are the Federal Information Processing Standards of the United States.

Two things about that exchange are the subject of this series. The first is that it works. Every byte on the wire crossed in the clear, and an eavesdropper who kept them all is left with a problem that nobody knows how to solve at this size, on a quantum computer or any other. The second is what it costs: 2,272 bytes on the wire, where X25519, the elliptic-curve key agreement in everyday use, sends 64.

Those same two messages already cross real networks. While the figure above runs ML-KEM-768 on its own, browsers since 2024 have shipped a hybrid key agreement: each message travels alongside a 32-byte X25519 share (1,216 bytes one way and 1,120 the other), and the connection's keys combine both shared secrets so that an attacker must break both schemes to read the traffic. By April 2026 Cloudflare counted over 65% of the human traffic it serves as protected this way (Section 11).K. Kwiatkowski, P. Kampanakis, B. E. Westerbaan and D. Stebila, "Post-quantum traditional (PQ/T) hybrid key agreement mechanisms for TLS 1.3", RFC 10024, August 2026, Sections 4.1 to 4.3; TLS is the protocol that secures web connections. The share is from B. Westerbaan, "Cloudflare targets 2029 for full post-quantum security", Cloudflare blog, 7 April 2026; the figure is a lower bound measured on one network.

One detail in the figure deserves a second look: flipping one of the ciphertext's 8,704 bits on the wire does not make decapsulation fail with an error. Instead, it quietly returns 32 different, plausible-looking bytes, leaving the two sides with mismatched secrets. Section 6 shows why returning an explicit failure can leak a private key bit by bit, and how this silent fallback closes that channel.

The argument. The series explains how the new standards work and why they cost what they do in five steps. Every public-key scheme rests on a mathematical operation that is cheap to run one way and hard to invert, paired with a secret that makes the reverse direction cheap for its holder; everything else is engineering (Section 1). The problems in mainstream use since 1976, integer factoring and the discrete logarithm, both conceal a repeating cycle in modular arithmetic, and a quantum computer can find periods efficiently (Section 2), so their replacements must avoid any hidden periodic structure. The leading replacement hides a secret vector behind small random perturbations. The encapsulation key that crossed the wire as this page loaded is a system of 768 noisy linear equations in 768 unknowns,

\[t = A s + e \pmod q,\]

where the matrix \(A\) is public (expanded from a 32-byte seed carried inside the key), \(q = 3329\), and every entry of the secret \(s\) and of the error \(e\) is a small integer between \(-2\) and \(2\). A secret and an error: hence the title. Without \(e\), schoolbook Gaussian elimination solves for \(s\) at once. Adding \(e\) smudges every equation so that elimination amplifies the noise across the modulus until \(s\) is lost. Recovering \(s\) then amounts to finding the point of a lattice nearest to a target built from \(t\) in more than a thousand dimensions (Sections 3 and 4); in schemes whose errors are sparse rather than small, the analogous task is decoding a random error-correcting code (Section 9). At the sizes in use, nobody, with or without a quantum computer, knows anything much faster than exponential search for either problem. (Section 5.6 covers one qualification: for lattices with the module structure of the standards, a quantum algorithm posted on 30 November 2026 runs in time that is quasi-polynomial as the ring grows; its authors call it galactic, not practical for the standards' parameter sets.)

Hiding secrets behind noise exacts a price in bandwidth and care. Keys, ciphertexts, and signatures grow tens to hundreds of times larger than the ones they replace, and the errors bring operational hazards with them: accumulated noise can make decapsulation fail about once in \(2^{165}\) tries, signing takes about five attempts on average because revealing candidates must be rejected so they do not leak the key, and careless implementations can give a secret away through variations in running time.The two numbers are the standards' own: a decapsulation failure rate of \(2^{-164.8}\) for ML-KEM-768 (FIPS 203, Table 1) and 5.1 expected repetitions of the signing loop for ML-DSA-65, the lattice signature standard (FIPS 204, Table 1). Managing that price is the engineering core of the standards (Sections 5 to 9). Above all, confidence in their security is empirical: no proof rules out a fast attack, and these schemes are trusted because decades of cryptanalysis have failed to break them, even as several rivals broke late and suddenly (Section 10).

The public-key cryptography of the last fifty years rests on problems that hide a period, and a quantum computer finds periods. Its main replacement hides a secret behind small errors: it costs kilobytes where the old schemes cost bytes, and what stands behind it is not a proof but a long record of attacks that failed.

What is being replaced, and why now. Public-key cryptography does two jobs: it lets two parties who have never met agree on a secret key over a wire that anyone can read, and it lets one party sign a message so that anyone else can verify where it came from. For half a century both jobs have rested on two problems: factoring the product of two large primes (RSA, 1978) and computing discrete logarithms, first in the integers modulo a prime (Diffie and Hellman, 1976) and then on elliptic curves (1985). In 1994 one paper broke both in principle, on a machine that did not yet exist:

A digital computer is generally believed to be an efficient universal computing device; that is, it is believed able to simulate any physical computing device with an increase in computation time of at most a polynomial factor. This may not be true when quantum mechanics is taken into consideration. This paper considers factoring integers and finding discrete logarithms, two problems which are generally thought to be hard on a classical computer and have been used as the basis of several proposed cryptosystems. Efficient randomized algorithms are given for these two problems on a hypothetical quantum computer. These algorithms take a number of steps polynomial in the input size, e.g., the number of digits of the integer to be factored.

—P. W. Shor, "Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer" (1997).SIAM Journal on Computing 26 (1997); the abstract as it stands on arXiv (quant-ph/9508027). The algorithms were first presented at the Symposium on Foundations of Computer Science, 20 to 22 November 1994.

Unstructured brute-force search, by contrast, speeds up by only a square root on a quantum computer: checking \(N\) candidates takes on the order of \(\sqrt{N}\) steps instead of \(N\) (Grover's algorithm, 1996). Because symmetric ciphers and hash functions offer no periodic shortcut to exploit, they stay secure with at most longer keys and outputs, and one of the new signature standards is built on a hash function and nothing else.

time       1976 ───────────────────────────────────────── 30 November 2026 ┊ planned ──── 2035
construct  1976 Diffie-Hellman · 1978 RSA, McEliece · 1979 Lamport signatures, Merkle trees
           1985 Elliptic curves · 1996 Ajtai lattices, NTRU · 2005 Learning with errors · 2010 Ring-LWE
           2011 Isogenies (SIDH) · 2015 SPHINCS · 2017 Kyber and Dilithium
           (in grey, what Shor's algorithm breaks: Diffie-Hellman, RSA, Elliptic curves)
attacks    1994 Shor · 1996 Grover · 1999 GGH encryption broken · 2022 Rainbow broken, SIKE broken
           2019 to 2026: 4 estimates of machines that have not been built (hollow marks)
           2026 Module lattices: a galactic algorithm (a square: a published algorithm, like Shor's)
standards  2016 NIST call · 2022 NIST selects · 2024 FIPS 203, 204, 205 · 2025 HQC selected
           and deployments and policies; then 7 planned dates, the last 2035 Disallowed
in all     62 events: 13 constructions, 15 attacks, 34 standards and deadlines, each with its source
point      McEliece dates from 1978 like RSA; FIPS 203, 204 and 205 were approved on 13 August 2024,
           46 years later
(the live figure needs JavaScript and loads about 0.03 MB of data)
The 62 dated events of the series, 1976 to 2035, in three lanes; a year or a month stands at its first day. Green: the standards lane, its planned dates open, beyond the hairline of the day the data was written. Grey: the constructions that Shor's algorithm breaks. Among the attacks a solid mark was carried out, a hollow one is an estimate of a machine not built, a square a published algorithm, a cross a claim withdrawn. Names stand where there is room; point at a mark, or use the arrow keys or play, to read its sentence and source.

The underlying mathematics of the replacements is decades old: code-based encryption dates from 1978, the same year as RSA; hash-based signatures from 1979; and lattice cryptography from 1996 and 2005. What is new is their standardization, driven by three reasons to hurry. First, although as of November 2026 no machine capable of running Shor's algorithm against a real key has been built, published hardware estimates keep shrinking: for a 2,048-bit RSA modulus, from 20 million noisy qubits in 2019 to under a million in 2025, and lower still, in estimates of March 2026, for elliptic curves and for other hardware architectures (Section 2).C. Gidney and M. Ekerå, "How to factor 2048 bit RSA integers in 8 hours using 20 million noisy qubits", arXiv 1905.09749 (2019); C. Gidney, "How to factor 2048 bit RSA integers with less than a million noisy qubits", arXiv 2505.15917 (2025), in under a week. Each is an estimate under stated assumptions about the hardware, not a machine. Second, an eavesdropper does not have to wait for the machine. Encrypted traffic recorded today can be stored and decrypted once a capable machine arrives (harvest now, decrypt later), so any secret that must outlive that arrival is already exposed, forcing key agreement to migrate first.

Third, standardized replacements are ready. The National Institute of Standards and Technology of the United States (NIST) selected them in a public competition that opened in 2016, and on 13 August 2024 it published the first three as federal standards: ML-KEM for key agreement, ML-DSA (Dilithium) for lattice-based signatures, and SLH-DSA (SPHINCS+) for hash-based signatures.

NIST expects that the two digital signature standards (ML-DSA and SLH-DSA) and key-encapsulation mechanism standard (ML-KEM) will provide the foundation for most deployments of post-quantum cryptography. They can and should be put into use now.

—National Institute of Standards and Technology, Post-Quantum Cryptography project.The project's page at csrc.nist.gov, under "Ongoing PQC Standardization Process", as read on 30 November 2026.

Two more are on the way: HQC, a second key-encapsulation mechanism chosen in March 2025 as a backup that rests on error-correcting codes instead of lattices, and FN-DSA (Falcon), a compact lattice signature chosen in 2022 whose final standard had not been published by 30 November 2026. Meanwhile, the classical algorithms have a retirement schedule: under NIST's transition plan of October 2026 they are deprecated after 2030 and disallowed after 2035 (Section 11).D. Moody, R. Perlner, A. Regenscheid, A. Robinson and D. Cooper, "Transition to post-quantum cryptography standards", NIST IR 8547, October 2026, Section 4. The selections of 5 July 2022 and 11 March 2025 and the approval of the three standards are dated on the news page of NIST's project.

The five families. The problems proposed in place of factoring and the discrete logarithm are usually sorted into five families.

Five families of hard problemsa row to a family: the problem it rests on, the schemes built on it, and at the right how they stand on 30 November 2026

  1. 3lattices ML-KEM, ML-DSA, FN-DSA

    Find the point of a grid in a thousand dimensions or more that lies nearest a given point.

    two of the three standards of August 2024

    FN-DSA: a standard still to come

  2. 8hash functions SLH-DSA

    Run a hash function backward. Signatures only, with small keys and large signatures.

    a standard since August 2024

    chosen so that not everything rests on lattices

  3. 9codes Classic McEliece, HQC

    Correct the errors in a word of a code that shows no structure. Its first scheme dates from 1978, the year of RSA.

    HQC chosen in 2025

    as the backup to ML-KEM

  4. 10multivariate equations Rainbow, UOV, MAYO

    Solve a system of quadratic equations in many unknowns.

    Rainbow, a finalist: a key of its smallest second-round

    parameters in a weekend on a laptop, 2022

    relatives are still in evaluation

  5. 10isogenies SIKE, SQIsign

    Find a path of maps between two elliptic curves.

    SIKE: broken in 2022, in about an hour,

    later in ten minutes on one core

    SQIsign is still in evaluation

green: the family of ML-KEM and ML-DSA, which the series follows from Section 3 to Section 7

NIST drew its standards, published and upcoming, from three of the five families on purpose, choosing SLH-DSA and HQC so that not everything would rest on lattices. The other two families show why diversity matters. In 2022, late in the selection process, both lost their most advanced candidates to ordinary classical computers: Rainbow, a signature finalist built on systems of quadratic equations, saw the smallest parameter set from its second-round submission broken over a weekend on a laptop, while SIKE, a key-encapsulation candidate built on maps between elliptic curves, fell in about an hour and soon after in ten minutes on a single processor core.W. Beullens, "Breaking Rainbow takes a weekend on a laptop", ePrint 2022/214, February 2022: 53 hours on average, for the smallest parameters of the second-round submission. W. Castryck and T. Decru, "An efficient key recovery attack on SIDH", ePrint 2022/975, 30 July 2022: 62 minutes in the first version, about ten in the final one. As of November 2026, redesigned relatives of both families remain among the eight signature schemes that NIST is still evaluating (Section 10).

The series. The 11 Sections that follow are each led by interactive figures that run directly in the page. By the end you should be able to say, for each standard, which mathematical problem it rests on, why its keys and signatures have the sizes they do, and what kind of breakthrough would be needed to break it.

  1. What a key promises. One-way functions and their trapdoors: key agreement, RSA and elliptic curves, at toy size and at real size.
  2. What a quantum computer breaks. Factoring and discrete logarithms are period finding, and a quantum Fourier transform sees periods; search gains only a square root.
  3. Lattices. One grid, many descriptions: a good basis decodes by rounding, a bad one does not, and turning bad into good gets hard as the dimension grows.
  4. Learning with errors. Linear equations with a little noise are believed hard to solve, and that is enough to encrypt in four lines.
  5. Rings, modules and the number-theoretic transform. Polynomial structure shrinks the public matrix from megabytes to kilobytes and speeds up multiplication, while raising the question of whether extra structure helps an attacker.
  6. ML-KEM. The scheme that ran as this page loaded: noisy equations over polynomials, compressed, and wrapped so that a dishonest ciphertext teaches its sender nothing.
  7. Signatures from lattices. A signature proves knowledge of a secret without revealing it; lattice signatures leak the secret unless revealing attempts are discarded (ML-DSA) or sampled from a round Gaussian cloud (FN-DSA).
  8. Signatures from hashes. Revealing chosen pieces of hashed secrets signs one message; hash chains and Merkle trees turn one-time signatures into stateless many-time signatures (SLH-DSA).
  9. Codes. Noisy linear algebra in another metric, counting flipped bits instead of small integers: hide an error-correcting code that you can decode (McEliece, 1978), or hide a secret in a noisy codeword (HQC).
  10. What broke, and how we know what holds. Why hardness cannot yet be proved: how SIKE and Rainbow broke, where attack records stand against production sizes, and how leaky implementations give secrets away.
  11. Deploying it, and further reading. Hybrid handshakes on the wire, why certificate chains remain the open problem, regulatory deadlines, further reading, and how the examples were made.

Sizes at a glance. The fourth step of the argument, the price, fits on one chart.

rows    38 algorithms, a row each, in 4 groups; a dot for each number, on its column's logarithmic scale
        bytes                                              a second: OpenSSL 3.5.9, one core of this machine
                             public key  ciphertext     both    keygen   encaps   decaps
        X25519 as a KEM              32          32       64    39,475   17,548   33,138    the hairline
        ML-KEM-768                1,184       1,088    2,272    34,898   66,547   41,282    green
                             public key   signature     both               sign   verify
        Ed25519                      32          64       96             39,961   12,120    the hairline
        ML-DSA-65                 1,952       3,309    5,261              1,415    7,398    green
        SLH-DSA-SHA2-128s            32       7,856    7,888               3.29    3,312
        23 rows were run here; 15 more have published sizes only (hollow dots) and no speed
sizes   ML-KEM and ML-DSA keys, ciphertexts and signatures: 24 to 81 times X25519's and Ed25519's
        SLH-DSA signatures: 123 to 779 times Ed25519's
speeds  ML-KEM-768: 0.88 to 3.8 times the speed of X25519
        every post-quantum signature run here: at least 17 times slower to make than Ed25519's
(the live figure needs JavaScript and loads about 0.2 MB of data)
A row to an algorithm, 38 in all: key agreement above, signatures below, today's in grey. Columns: bytes (public key; ciphertext or signature; both, which orders the rows) and operations a second with OpenSSL 3.5.9 on one core of this machine, each on a logarithmic scale. Green: the defaults, ML-KEM-768 and ML-DSA-65. The hairline down a column is its table's baseline, X25519 as a KEM or Ed25519; the worse side is hatched. A hollow dot is a published size: that row was not run here and has no speed. Point at a row to read it; a heading reorders the rows.

For key agreement, the bandwidth price is 35.5 times the bytes of X25519, whereas in compute time ML-KEM-768 by itself costs roughly what X25519 costs, or less. Measured once with the cryptographic library OpenSSL 3.5.9 on one core of a 16-core server, ML-KEM-768 ran at 0.88 to 3.8 times the speed of X25519 across its three operations; the browser hybrid that runs both together ran at 0.46 to 0.82 times the speed of X25519 alone.

Signatures pay in both size and speed. For ML-DSA-65, the middle parameter set of the lattice signature standard, the public key and signature come to 5,261 bytes, 55 times the 96 bytes of the widely used elliptic-curve signature Ed25519, while signing ran 28 times more slowly. Hash-based SLH-DSA is slower again by up to three orders of magnitude, and even the fastest post-quantum signature measured here took about 18 times longer to produce than Ed25519's.

Different families carry their bulk in different places: Classic McEliece pairs a 261,120-byte public key with a 96-byte ciphertext, whereas SLH-DSA pairs a 32-byte public key with a signature of at least 7,856 bytes. Worse, a signature on the web seldom travels alone: establishing a secure connection sends a chain of several signatures along with the public keys that verify them, multiplying the overhead and making authentication the hardest open problem of the migration (Section 11).

How to read the figures. The algorithms in these pages are the real standards at their full production sizes, running in plain JavaScript in your browser: ML-KEM, ML-DSA, and SLH-DSA as specified by FIPS 203, 204, and 205, alongside the hash functions, elliptic curves, and RSA arithmetic they are compared against. That all of this fits comfortably inside a web page is part of the story. Filippo Valsorda makes the same observation in an implementer's guide to ML-KEM written for programmers who know RSA and elliptic curves:

Except now the post-quantum algorithms are coming, and they use lattices and matrices and polynomials. So, how much linear algebra and polynomial algebra do you need to know to implement these post-quantum cryptography primitives? Turns out, surprisingly little! The word “lattice” doesn’t even show up in the spec except in the name.

—F. Valsorda, "Enough polynomials and linear algebra to implement Kyber" (2023).At words.filippo.io/kyber-math, 7 November 2023, introduction. The spec is FIPS 203, a draft when this was written.

The ML-KEM implementation that ran as this page loaded is about 400 lines of code, not counting the hash functions it calls; it reproduces NIST's official test vectors and exchanges keys with OpenSSL in both directions. Toy instances (a lattice in the plane, a seven-bit code, a 23-hour clock) appear only to make a mechanism visible beside the full-size algorithm doing the exact same work, and no claim rests on them. Attacks are run rather than asserted: small ones live in the browser, larger ones on a 16-core server, with their measurements plotted directly. Every figure states which numbers were measured here, which were computed analytically, and which come from published literature, and the element drawn in green marks the central quantity of that figure. The code is written for clarity and is not hardened for protecting real secrets; Section 11 explains how each example was built and verified.

Notation. In learning with errors (LWE, Section 4), \(q\) is the modulus, \(n\) the secret dimension, \(m\) the number of equations, \(A\) a uniform public matrix, \(s\) the secret vector, \(e\) a small error vector, and \(b = A s + e\) the noisy product, following Regev's notation, with \(\mu\) denoting a message bit. In ML-KEM, FIPS 203 writes the public noisy product as \(t = A s + e\); the sender's ephemeral vectors are \(r\) (written \(y\) in FIPS 203), \(e_1\), and \(e_2\), producing ciphertext \((u, v)\) for message \(m\). Polynomial arithmetic takes place in the ring \(R_q = \mathbb Z_q[X]/(X^n + 1)\) with \(n = 256\) and \(q = 3329\), and modules have rank \(k\), so ML-KEM-768 has \(k = 3\) and \(kn = 768\) scalar unknowns. A lattice \(\mathcal L(B)\) is generated by the columns of a basis matrix \(B\), with shortest nonzero vector length \(\lambda_1\) and Gram-Schmidt orthogonalized vectors \(b_i^{*}\). Lattice signatures follow FIPS 204: secret vectors \(s_1\) and \(s_2\), masking vector \(y\), commitment \(w = A y\), challenge polynomial \(c\), and response \(z = y + c s_1\). For error-correcting codes, \(G\) is a generator matrix, \(H\) a parity-check matrix, \(e\) an error vector of Hamming weight \(t\), and \(s = H e^{\top}\) its syndrome. Hash functions are written \(H\), \(G\), and \(J\) as each standard names them. Because each section preserves the notation of its primary sources, letters such as \(G\), \(H\), \(s\), \(t\), and \(n\) shift meaning across Sections. Schemes go by their standardized names, with their competition submission names given once in parentheses: ML-KEM (Kyber), ML-DSA (Dilithium), SLH-DSA (SPHINCS+), and FN-DSA (Falcon). Following FIPS 203, these pages call the public and private keys of a KEM the encapsulation key and decapsulation key.

Security levels follow NIST's five categories: breaking a scheme in category 1, 3, or 5 must cost at least as much as an exhaustive key search against the block cipher AES-128, AES-192, or AES-256, and breaking category 2 or 4 must cost at least as much as finding a collision in a 256-bit or 384-bit hash function. ML-KEM-768 and ML-DSA-65 sit in category 3. Parts are cited as Sections; numbered statements are Definition, Proposition, Theorem, Example, and Remark \(N.S.K\), with \(N\) the part and \(S\) its section.

(General disclaimers apply.) Nothing here is security, legal or investment advice. The code in these pages explains how the algorithms work: it is not constant-time (how long it runs depends on the secrets it handles), it has not been audited, and it must not be used to protect anything. Standards, records, estimates and deployment figures are as published at the dates given, and the sidenotes say where each was read.

← Back to all posts