Introduction to Quantum Resistance: Lattice-Based Cryptography
Introduction
In previous articles, we explored how quantum computers threaten modern cryptosystems, particularly Ethereum’s elliptic curve cryptography. But what do we do when the quantum canary starts to cough? How do we prepare for the quantum apocalypse?
One of the most promising paths forward is quantum-resistant cryptography.
So, what does it mean when we say a cryptography is quantum-resistant? Does it mean it’s provably secure against any quantum attack? Not quite. There’s currently no formal proof that any post-quantum cryptography is truly immune to quantum algorithms. So “quantum resistance” is more a belief—a well-informed hope based on hard problems for which no efficient quantum solution is known.
Among these hopeful contenders, lattice-based cryptography stands out due to its deep mathematical foundations, practical use in fully homomorphic encryption, digital signatures, and zero-knowledge proofs, and its balance of security and efficiency.
In this final post of the series, we’ll introduce the basic principles of lattice-based cryptography and walk through a public-key encryption scheme built on it, which was recently challenged (and quickly debunked) by a quantum algorithm that claimed to break lattice-based cryptography.
What Is a Lattice?
A lattice is a simple mathematical structure. You can think of it as a regular grid of points in space formed by taking all integer linear combinations of a set of basis vectors.
For example, in 2D, a lattice generated by unit vectors along the x- and y-axes looks like a standard grid:
Of course, the basis vectors can be anything, as long as they are linearly independent. Here’s an example with basis vectors $(1, 2)$ and $(2, 1)$:
Formally, given linearly independent vectors $\vec{b}_1,\vec{b}_2,\dots,\vec{b}_n\in\mathbb{R}^n$, the lattice they generate is:
\[L= \set{\sum_{i=1}^n c_i \vec{b}_i\;}{\;c_i \in \mathbb{Z}}.\]In higher dimensions, lattices become less intuitive to visualize—but more powerful. Problems like the Shortest Vector Problem (SVP) or the Closest Vector Problem (CVP)—finding the shortest nonzero lattice vector or the nearest lattice point to an arbitrary target—are extremely hard, even for quantum computers.
Learning with Errors (LWE)
SVP and CVP are hard in the worst case, but they can be relatively easy in certain instances. Cryptography needs average-case hardness, not just worst-case. That’s where the Learning With Errors (LWE) problem comes in.
LWE hides a secret vector inside a noisy linear system. Formally, given a matrix $A_i$ a vector $\vec{b}_i$ and a small error $\vec{e}_i$ find a secret vector $\vec{s}$ such that:
\[\vec{b}_i = A_i \cdot \vec{s} + \vec{e}_i,\]The noise $\vec{e}_i$ makes it hard to solve the system and recover $\vec{s}$ even when you know many $(A_i, b_i)$ pairs. This problem is believed to be hard even for quantum computers, making it a solid foundation for post-quantum cryptographic schemes.
From LWE to Lattices
At first glance, LWE looks like noisy linear algebra. But here’s the trick: each noiseless product $A\cdot\vec{s}$ corresponds to a lattice point (since the columns of $A$ form a basis). The addition of $\vec{e}$ perturbs this point slightly off the lattice.
Now, you might think this is just a variant of the CVP–but there’s a subtle difference. In CVP, you’re given a point and must find the closest lattice point. In LWE, the error doesn’t guarantee that the perturbed point is closest to the correct lattice point; the noise can push it in arbitrary directions. That means even if you could solve CVP, it wouldn’t necessarily help with LWE.
To overcome this, cryptographic LWE schemes use many independent samples. These multiple noisy instances average out the “bad cases” where the error might lead you astray. The hardness of LWE lies in solving the problem across all these samples, which smooths the difference between worst-case and average-case difficulty. This connection to lattice problems–and the wort-case-to-average-case reduction–is what makes LWE such a powerful foundation for quantum-resistant cryptography.
Public-Key Encryption Scheme
Let’s walk through a public-key encryption scheme introduced by Oded Regev, build on LWE.
Key Generation (by Alice)
- Choose a random matrix $A\in\mathbb{Z}_q^{m\times n}$ – this will be public.
- Sample a secret vector $\vec{s}\in\mathbb{Z}_q^n$ – this is the private key.
- Sample a small noise vector $\vec{e}\in\mathbb{Z}_q^m$ from a discrete Gaussian distribution.
- Compute $\vec{b} = A\cdot\vec{s}+\vec{e}$.
- The public key is $(A,\vec{b})$; the private key is $\vec{s}$.
Encryption (by Bob)
To send a single bit $\text{bit} \in \braces{0,1}$ to Alice:
- Choose a random binary vector $\vec{x} \in \mathbb{Z}_q^m$.
- Compute:
- $\vec{u}=A\cdot\vec{x}$.
- $v=\vec{b}\cdot\vec{x}+\text{bit}\cdot\frac{q}{2}$.
- The ciphertext is $(\vec{u}, v)$.
Decryption (by Alice)
Compute:
\[u^\prime=v-\vec{s}\cdot\vec{u}\]If $u^\prime$ is closer to $0$, decode as $0$; if it’s closer to $\frac{q}{2}$, decode as $1$.
This works because:
\[\begin{align*} u^\prime &=\vec{b}\cdot\vec{x}+\text{bit}\cdot\frac{q}{2}-\vec{s}\cdot A\cdot\vec{x}\\ &=\prths{A\cdot\vec{s}+\vec{e}}\cdot\vec{x}+\text{bit}\cdot\frac{q}{2}-\vec{s}\cdot A\cdot\vec{x}\\ &=\vec{e}\cdot\vec{x}+\text{bit}\cdot\frac{q}{2}\\ &\approx\text{bit}\cdot\frac{q}{2}, \end{align*}\]The error term $\vec{e}\cdot\vec{x}$ is small, so the decryption recovers the original bit with high probability.
A Scare in 2024
In April 2024, a paper titled Quantum Algorithms for Lattice Problems claimed a quantum algorithm that could solve LWE and SVP in polynomial time. If true, this would destroy the security foundations of lattice-based cryptography.
The approach relied on a quantum state with complex Gaussian amplitudes and quantum Fourier transform (QFT) to extract structure from the lattice. However, researchers quickly identified a fatal flaw in the extraction step: Step 9, which was meant to recover a modular linear equation, turned out to be infeasible under current quantum operations.
The field breathed a sigh of relief—but the incident served as a powerful reminder: quantum resistance is a moving target.
Conclusion
This article marks the end of our journey through quantum computing. We’ve explored quantum mechanics, circuit models, quantum algorithms that threaten classical cryptography, how quantum computers are built, what would be considered as a quantum canary, and finally, how we can defend against them with post-quantum cryptography.
I had a lot of fun writing this series, and I hope it helped demystify quantum computing and sparked your curiosity. If you’re diving into quantum research or engineering, I’d love to hear from you.
Feel free to reach out via email. Until next time—good luck navigating the quantum future.
All images in this article are real-time rendered TikZ diagrams.
Leave a comment