Post-Quantum Cryptography: Lattice-Based, Code-Based, and Hash-Based Cryptography Explained

Post-Quantum Cryptography: Lattice-Based, Code-Based, and Hash-Based Cryptography Explained

If you work anywhere near security architecture, key management, or compliance, “post-quantum cryptography” has probably shown up on your roadmap in the last year or two, whether or not anyone on your team fully understands why it’s urgent now rather than, say, ten years from now when the actual threat might materialize. That timing question is worth answering first, because it’s the entire reason PQC migration has become a present-tense engineering project rather than a distant future concern.

Why This Is Urgent Now, Not “Whenever Quantum Computers Arrive”

The core threat isn’t that someone will break your encryption tomorrow using a quantum computer — no quantum computer that exists today comes close to being able to do that. The threat is called “harvest now, decrypt later.” An adversary — a nation-state intelligence agency is the standard example — can record encrypted traffic today, store it, and simply wait. If a cryptographically relevant quantum computer becomes available in ten or fifteen years, all that stored, currently-unbreakable traffic becomes retroactively readable. For data with a long confidentiality shelf life — medical records, state secrets, long-term financial and legal agreements, personal communications people would prefer stay private indefinitely — that’s a real and present risk, not a hypothetical future one. This is precisely why NIST, government agencies, and increasingly private industry have pushed PQC migration timelines up rather than waiting.

The specific mathematical threat is Shor’s algorithm, a quantum algorithm published by Peter Shor in 1994 that can factor large integers and solve the discrete logarithm problem in polynomial time on a sufficiently large, fault-tolerant quantum computer. This directly breaks RSA (which relies on factoring hardness) and Diffie-Hellman/ECDH/ECDSA (which rely on discrete logarithm hardness, including the elliptic curve variant), which together underpin the overwhelming majority of key exchange and digital signatures used across the modern internet, from TLS to SSH to code signing. Separately, Grover’s algorithm provides a quadratic speedup for unstructured search problems, which effectively halves the security level of symmetric ciphers and hash functions — meaning AES-256 retains roughly 128 bits of effective post-quantum security, which is why AES-256 (not AES-128) and SHA-384/SHA-512 (not their shorter variants) are the recommended symmetric-cryptography choices going forward, without needing any fundamental redesign of symmetric algorithms.

NIST’s Standardization Effort and Where It Stands

NIST ran an open, public, multi-round competition starting in 2016, evaluating dozens of candidate algorithms submitted by cryptographers worldwide, with several rounds of public cryptanalysis eliminating candidates that turned out to have exploitable weaknesses. This process finalized its first results on August 13, 2024, when NIST published three finalized Federal Information Processing Standards:

A fourth algorithm, FN-DSA (derived from FALCON, another lattice-based signature scheme), had been selected but its formal standard, expected to be published as FIPS 206, was still pending as of the most recent public updates. In 2025, NIST additionally selected HQC, a code-based key encapsulation mechanism, for standardization, specifically to provide a backup algorithm for key encapsulation built on a mathematically different hardness assumption than ML-KEM’s lattice foundation — a deliberate hedge in case future cryptanalysis finds a weakness specific to lattice-based schemes.

Separately, the NSA’s CNSA 2.0 guidance has set 2030 as a target migration deadline for National Security Systems, which has become an influential reference point pulling forward migration timelines across the broader industry, well beyond just government systems.

Lattice-Based Cryptography: The Current Workhorse

Lattice-based schemes dominate the finalized standards (both ML-KEM and ML-DSA are lattice-based), so it’s worth understanding the underlying math reasonably well.

A lattice, in this cryptographic sense, is a regularly repeating grid of points in high-dimensional space, generated by all integer linear combinations of a set of basis vectors:

$$L = \left{ \sum_{i=1}^{n} a_i \mathbf{b}_i : a_i \in \mathbb{Z} \right}$$

where $\mathbf{b}_1, \ldots, \mathbf{b}_n$ are the basis vectors defining the lattice. The hard problems these schemes rely on include the Shortest Vector Problem (SVP) — given a lattice basis, find the shortest non-zero vector in the lattice — and, more directly relevant to the standardized schemes, the Learning With Errors (LWE) problem, introduced by Oded Regev in 2005. LWE asks you to recover a secret vector $\mathbf{s}$ given many noisy linear equations of the form:

$$b_i = \langle \mathbf{a}_i, \mathbf{s} \rangle + e_i \pmod{q}$$

where $\mathbf{a}_i$ are known random vectors, $e_i$ is small random “error” noise, and $q$ is a modulus. Without the noise term $e_i$, recovering $\mathbf{s}$ from enough equations would be trivial linear algebra. The noise is precisely what makes the problem hard — and, crucially, LWE has a worst-case to average-case reduction, meaning that solving randomly generated LWE instances is provably at least as hard as solving certain lattice problems in their worst case, which gives cryptographers unusually strong theoretical confidence in the foundation, compared to many other cryptographic hardness assumptions that rest only on empirical resistance to known attacks.

ML-KEM and ML-DSA specifically use Module-LWE, a structured variant of LWE that operates over polynomial rings rather than plain integer vectors, which dramatically improves performance (smaller keys, faster computation) at the cost of introducing additional algebraic structure. That structure is exactly what makes some cryptographers slightly more cautious about long-term confidence in these schemes relative to unstructured lattice problems — structure that improves efficiency can, in principle, also open doors for future cryptanalytic attacks that wouldn’t apply to the unstructured version, though no such weakness has been found in the standardized parameter sets to date.

In practical terms, ML-KEM public keys and ciphertexts run roughly 800 to 1,568 bytes depending on the chosen security level (ML-KEM-512, -768, or -1024), and ML-DSA signatures run from about 2,420 to 4,595 bytes — both substantially larger than their classical RSA or ECDSA counterparts, which is one of the real practical costs of migration: PQC generally means larger keys, larger signatures, and larger network payloads than what TLS handshakes and certificate chains have historically carried.

Code-Based Cryptography: The Oldest Approach

Code-based cryptography actually predates lattice-based approaches by decades — the foundational scheme, the McEliece cryptosystem, was proposed by Robert McEliece in 1978, making it one of the very few public-key cryptosystems that has survived over four decades of sustained cryptanalytic attention without ever being broken, a track record few other schemes can match, including several of the newer lattice-based candidates.

The underlying hard problem is syndrome decoding: given a linear error-correcting code (the kind normally used to fix transmission errors, not create cryptographic hardness) and a received vector, find the original message assuming some bounded number of errors were introduced. For a randomly chosen linear code, this decoding problem is believed to be computationally hard (formally, NP-hard for the general case), while for the special structured codes the legitimate key holder possesses (traditionally Goppa codes in the original McEliece scheme), efficient decoding algorithms exist. The private key is essentially the structure that makes efficient decoding possible; the public key deliberately disguises that structure to look like a generic, hard-to-decode random linear code.

McEliece’s biggest practical drawback has always been key size — original McEliece public keys run into the hundreds of kilobytes to over a megabyte, dramatically larger than lattice-based alternatives, which is exactly why it wasn’t standardized as NIST’s primary KEM despite its impressive cryptanalytic track record. NIST’s 2025 selection of HQC (Hamming Quasi-Cyclic), a more compact code-based scheme using structured quasi-cyclic codes to reduce key sizes relative to classic McEliece, represents an attempt to get some of code-based cryptography’s structural-diversity benefits — a hardness assumption genuinely independent from lattice problems — without quite as extreme a key-size penalty, specifically intended as a backup to ML-KEM.

Hash-Based Cryptography: The Conservative Choice

Hash-based signatures rest on the most conservative and minimal cryptographic assumption of any PQC family: the collision resistance and one-wayness of cryptographic hash functions, properties already relied upon throughout essentially all of modern cryptography and well-understood after decades of scrutiny. No structured algebraic assumption, no coding theory — just the basic security properties of hash functions like SHA-256 or SHA-3, whose resistance to quantum attack is well understood and limited only by the quadratic Grover speedup mentioned earlier (addressed simply by using longer hash outputs).

The foundational building block is the Merkle signature scheme, based on Merkle trees (also called hash trees), where a one-time signature scheme — something like the Winternitz one-time signature (WOTS) scheme, which can only safely sign a single message with a given key pair — gets extended to allow many signatures by organizing many one-time key pairs into the leaves of a binary hash tree, with the tree’s root serving as the actual long-term public key.

SLH-DSA (standardized as FIPS 205, derived from SPHINCS+) is a stateless hash-based scheme, meaning the signer doesn’t need to carefully track which one-time keys have already been used — an important practical property, since stateful hash-based schemes (like the older LMS and XMSS schemes, standardized separately in NIST SP 800-208) require meticulous state management, and accidentally reusing a one-time key pair catastrophically breaks security. SLH-DSA achieves statelessness using a clever hypertree structure combined with pseudorandom key generation, at the cost of considerably larger signatures (roughly 8 to 50 kilobytes, depending on parameter set) and notably slower signing operations — commonly two to three orders of magnitude slower than lattice-based ML-DSA signing.

Given that cost, SLH-DSA is deliberately positioned as NIST’s conservative fallback signature scheme — the one to reach for either for extremely long-term, high-assurance signing needs, or as a hedge in case some future cryptanalytic breakthrough weakens confidence in the lattice-based assumptions underlying ML-DSA.

Why NIST Standardized Multiple Mathematical Families

This diversification is a deliberate risk-management strategy, not redundancy for its own sake. The standardization process itself provided a sobering lesson in why: two other finalist candidates from entirely different mathematical families were cryptanalytically broken during the evaluation process itself. SIKE, an isogeny-based key encapsulation scheme built on the mathematics of elliptic curve isogenies, was broken in 2022 by a classical (non-quantum) attack that recovered the private key in about an hour on a single core — a dramatic and very public example of a scheme that had survived years of scrutiny before a fundamentally new attack technique demolished it. Rainbow, a multivariate-equation-based signature scheme, was similarly broken during evaluation. Both cases are the clearest possible illustration of why “no known attack yet” is not the same guarantee as a mathematical proof of hardness, and why NIST’s decision to standardize algorithms from mathematically independent families (lattices, codes, hashes) — rather than putting all confidence in a single approach — is a sound and deliberately conservative engineering decision rather than mere thoroughness for its own sake.

Migration in Practice: Hybrid Approaches

Almost no serious organization is migrating directly from classical to pure post-quantum cryptography in one step. The dominant practical approach right now is hybrid key exchange — combining a classical algorithm (like X25519 or ECDH) with a post-quantum algorithm (like ML-KEM) in the same handshake, such that breaking the connection’s security requires breaking both the classical and the post-quantum component. This is a sensible hedge for the current transition period: if an unexpected weakness is later found in the newly standardized PQC algorithms — which, again, are far less battle-tested against decades of cryptanalysis than RSA or ECC — the classical component still provides the security guarantee everyone already trusted. Major browsers, TLS libraries, and cloud providers have already begun rolling out hybrid post-quantum key exchange (commonly labeled with names like X25519Kyber768 or similar in TLS implementation logs) well ahead of full-scale mandatory migration deadlines.

Practical and Engineering Implications

For anyone actually responsible for planning a migration, a few practical realities are worth internalizing. Larger keys and signatures mean larger network payloads — TLS handshakes carrying ML-KEM and ML-DSA material are measurably larger than their classical equivalents, which matters for latency-sensitive applications and for systems with tight packet-size or bandwidth constraints (embedded systems, IoT, satellite links). Performance characteristics differ significantly across algorithm families — lattice-based schemes are generally fast, hash-based signing is comparatively slow, and different applications will have different tolerance for that trade-off. Crypto-agility matters more than ever — building systems that can swap cryptographic primitives without a wholesale re-architecture is now a genuinely important design principle, given that the PQC landscape is still evolving (with FN-DSA still pending standardization and further algorithm rounds ongoing). And inventory work usually dominates the actual migration effort — most organizations’ biggest practical obstacle isn’t implementing the new algorithms (mature libraries already exist), it’s the unglamorous work of discovering every place in their infrastructure where classical cryptography is currently in use, including in embedded firmware, legacy protocols, and third-party dependencies that may not get updated on any predictable timeline.

ML-DSA in Practice: The Fiat-Shamir-with-Aborts Signing Loop

It’s worth walking through ML-DSA’s signing procedure in a bit more mechanical detail, because it has a genuinely distinctive property that trips up engineers used to how RSA or ECDSA signing works: signing isn’t guaranteed to succeed on the first try. ML-DSA uses a design pattern called Fiat-Shamir with Aborts, in which the signer generates a candidate signature using randomness derived from the message and private key, checks whether that candidate signature’s coefficients fall within an acceptable range (a check designed specifically to ensure the signature doesn’t leak information about the secret key), and — if the check fails — simply discards the candidate and tries again with fresh randomness, repeating until an acceptable signature is produced. This rejection-sampling loop typically succeeds within a handful of attempts on average, and the expected number of attempts is a known, fixed property of each parameter set, but it does mean ML-DSA signing latency has a distribution with a right-skewed tail — occasionally needing several rounds — rather than the constant-time-per-operation behavior engineers are used to from classical signature schemes. Anyone building latency-sensitive or real-time systems around ML-DSA signing needs to account for this variability in their performance modeling, rather than assuming a fixed, deterministic signing cost per operation the way RSA or ECDSA signing effectively provides.

Side-Channel Considerations in PQC Implementations

A point that deserves explicit attention from any engineering or cybersecurity audience: being resistant to quantum attack via Shor’s or Grover’s algorithm says nothing about resistance to classical implementation-level side-channel attacks — timing attacks, power analysis, cache-timing attacks, and similar techniques that target how an algorithm is implemented in real hardware or software rather than the mathematical hardness of the underlying problem. This is a genuinely important and sometimes underappreciated point: a textbook-correct implementation of ML-KEM or ML-DSA can still be broken in practice by a classical side-channel attack targeting, for instance, the polynomial multiplication routines or the rejection-sampling comparison logic just described, if those operations aren’t implemented in constant time. Because these are comparatively new algorithms relative to RSA and ECC, side-channel-hardened reference implementations are less mature and less battle-tested than their classical counterparts, and organizations deploying PQC in security-sensitive contexts — hardware security modules, smart cards, embedded systems handling high-value keys — need to specifically evaluate side-channel resistance as part of their implementation choice, not simply assume that “NIST-standardized” implies “side-channel hardened” in any given library.

The Broader Migration Ecosystem: Certificates, HSMs, and Protocol Support

Beyond the algorithms themselves, a full PQC migration touches a surprisingly wide set of infrastructure layers that are each maturing at somewhat different rates. Certificate authorities and PKI need to support issuing certificates carrying ML-DSA (or hybrid classical/ML-DSA) public keys and signatures, which several major CAs have begun piloting, though widescale issuance of pure post-quantum certificates through the existing web PKI ecosystem remains an ongoing, multi-year rollout rather than a completed transition. Hardware security modules (HSMs), which many organizations rely on for protecting high-value private keys, need firmware and API support for the new algorithms — a nontrivial undertaking given the different computational profile (larger keys, the rejection-sampling signing loop, different memory access patterns) relative to the RSA and ECC operations HSM hardware has historically been optimized around. Protocol-level support — in TLS, SSH, IPsec, S/MIME, and other widely deployed protocols — has generally moved fastest for TLS, given the strong incentive created by the harvest-now-decrypt-later threat to web traffic, with hybrid key exchange now available in recent versions of major TLS libraries and browsers, while broader adoption across the full range of protocols that rely on public-key cryptography remains a longer, more uneven undertaking likely to stretch across the remainder of this decade.

Established Standards vs. Ongoing Work

FIPS 203, 204, and 205 are finalized, published, production-ready standards as of August 2024 — this is not speculative or forward-looking technology, and mature open-source implementations already exist in major cryptographic libraries. What remains ongoing is the completion of the broader standard set (FN-DSA/FIPS 206 still pending publication, HQC implementation guidance still maturing following its 2025 selection), continued cryptanalytic scrutiny of the newly standardized algorithms (which, being newer, have inherently had less adversarial attention than RSA or ECC have accumulated over decades), and the practical, organization-by-organization work of actually migrating deployed systems — which, given the harvest-now-decrypt-later threat model, is the part of this story where the clock is actually running today, regardless of how far off a cryptographically relevant quantum computer might turn out to be.

Exit mobile version