Lattice Crypto Explorer
0%
Post-Quantum Cryptography • Beginner → Intermediate

Lattice Cryptography Explorer

A visual, interactive introduction to lattice-based cryptography with focused modules on FrodoKEM, NTRU, and the CRYSTALS family—especially CRYSTALS-Kyber and its standardized descendant, ML-KEM.

No libraries, plugins, servers, or network access are required for the interactive portions. External readings open separately when internet access is available.

A two-dimensional lattice with a noisy target point structured points = lattice small error / noise
Orientation

What you should be able to explain by the end

Foundations

Describe a lattice, a basis, short-vector intuition, modular arithmetic, polynomial rings, and why adding a small error can make a linear problem difficult.

Mechanisms

Explain KeyGen → Encaps → Decaps, and distinguish a key-encapsulation mechanism from bulk data encryption and from a digital signature.

Algorithms

Compare FrodoKEM, NTRU, and CRYSTALS-Kyber/ML-KEM by their algebraic structure, underlying hard problem, implementation tradeoffs, and standardization status.

Important vocabulary correction: the family name is CRYSTALS (“Cryptographic Suite for Algebraic Lattices”), not “Krystals.” CRYSTALS-Kyber led to the standardized KEM ML-KEM; CRYSTALS-Dilithium led to the standardized signature algorithm ML-DSA.

The big picture

Classical public-key cryptography often relies on integer factoring or discrete logarithms. A sufficiently capable quantum computer running Shor’s algorithm would threaten those assumptions. Lattice-based systems instead build security from problems involving high-dimensional geometric or algebraic structures for which no comparably devastating quantum algorithm is known.

A recurring teaching idea in this tutorial is simple: linear algebra is easy; linear algebra with carefully chosen uncertainty can be hard. LWE turns that intuition into a rigorous cryptographic problem.

Foundation 1

What is a lattice?

A lattice is an infinite, regularly repeating set of points obtained by taking integer combinations of basis vectors. In two dimensions, choose two linearly independent vectors b₁ and b₂. Every lattice point has the form:

L = { z₁b₁ + z₂b₂ : z₁,z₂ ∈ ℤ }

The same lattice can have many different bases. A “nice” basis may consist of short, nearly orthogonal vectors; an awkward basis can consist of long, skewed vectors. This difference between an easy description and a difficult-looking description helps build intuition for lattice cryptography.

Try this

Move the basis sliders, then click anywhere in the plot. The demo searches nearby integer combinations and marks a close lattice point.

Click the canvas to place a target.

Real cryptographic lattices have hundreds or thousands of dimensions. Two dimensions are used only to build geometric intuition.

Basis ≠ lattice

A basis is a description of a lattice, not the lattice itself. Different bases can generate the same set of points.

Foundation 2

Which lattice problems are supposed to be hard?

SVP

Shortest Vector Problem: find a shortest nonzero vector in a lattice. Exact and strong approximation variants become computationally difficult in high dimension.

CVP

Closest Vector Problem: given a target point not necessarily on the lattice, find the closest lattice point. Again, the high-dimensional problem is the important one.

SIS / LWE

Short Integer Solution and Learning With Errors are algebraic problems closely tied to lattice hardness and are especially useful for constructing cryptographic primitives.

Do not over-interpret the 2-D picture. In two dimensions, we can draw the lattice and brute-force nearby points. Cryptographic security comes from very high dimensions, carefully chosen parameters, distributions, and reductions—not from the fact that a picture looks complicated.

Why quantum resistance is plausible

Shor’s algorithm exploits special algebraic structure in factoring and discrete logarithms. No known quantum algorithm solves the lattice problems used by modern lattice cryptography with a similar exponential-to-polynomial collapse. “Post-quantum” therefore means designed around problems currently believed to resist both classical and quantum attacks; it does not mean mathematically proven invulnerable.

Foundation 3

Learning With Errors: linear equations plus tiny mistakes

Suppose a secret value is s. If an attacker sees many exact modular equations of the form b = a·s mod q, recovering s is usually straightforward. LWE changes the equation by adding a small random error:

b = a·s + e (mod q), where e is small and random

Each sample is almost consistent with the same secret, but not exactly. In the real problem, s, a, and e are vectors (or structured vectors of polynomials), and the dimension is large.

Generate toy LWE samples

Concept checkpoint: the “error” is not an implementation bug. The error is deliberately sampled. It is the feature that hides the secret while still permitting legitimate operations to recover the intended value.

Three related flavors

FlavorObjectsIntuitionSeen in this tutorial
LWEordinary vectors / matrices mod qleast additional algebraic structureFrodoKEM
Ring-LWEpolynomials in a quotient ringmore structure; efficient polynomial arithmeticbackground for ring-based systems
Module-LWEvectors of ring elementsmiddle ground between plain LWE and a single ring elementCRYSTALS-Kyber / ML-KEM
Protocol idea

What is a KEM?

A key-encapsulation mechanism is not normally used to encrypt an entire file directly. Its job is to let two parties agree on a fresh shared secret over a public channel. That secret then feeds a symmetric cipher or authenticated-encryption scheme.

Alice

Generates a public/secret key pair.

pk, sk
PK
Bob

Uses Alice’s public key to encapsulate.

waiting…
1
KeyGen — Alice creates (pk, sk).
2
Send pk — the public key can cross an untrusted network.
3
Encaps(pk) — Bob creates ciphertext c and shared secret K.
4
Send c — Bob sends the encapsulation/ciphertext to Alice.
5
Decaps(sk,c) — Alice recovers the same K.
Real deployment includes more than the math. Authentication, certificate handling, side-channel resistance, secure randomness, key erasure, protocol binding, and failure handling are all critical.
Algorithm module

FrodoKEM: “plain” LWE with large matrices

FrodoKEM is designed around comparatively conservative algebraic structure: rather than using polynomial-ring structure for its main LWE computation, it works with large matrices over modular integers. That makes the connection to plain LWE especially direct, at the cost of larger keys/ciphertexts and heavier matrix arithmetic than highly structured schemes.

Core public-key shape

B = A·S + E (mod q)

A is a large public matrix (often generated from a compact seed). S is secret and small. E is small random error. The public information contains A and a noisy product B.

Encapsulation intuition

B′ ≈ S′A + E′
V ≈ S′B + E″ + Encode(μ)

The encapsulator uses fresh small secrets/errors. The recipient combines the ciphertext with the secret matrix S; matching products largely cancel, leaving an encoded value plus manageable noise.

Mini matrix laboratory

The following uses tiny 3×3 matrices and tiny numbers so you can see every operation. This is a teaching model only.

A (public)

S (small secret)

E (small error)

B = A·S + E mod q

What to remember

  • FrodoKEM is an excellent teaching example for seeing the connection between matrix algebra and LWE noise.
  • It deliberately avoids the same degree of algebraic structure exploited for efficiency in ring/module schemes.
  • That design choice changes engineering tradeoffs; it does not mean “structure is insecure.” Modern structured schemes are parameterized and analyzed specifically around their chosen assumptions.
Algorithm module

NTRU: small polynomials, modular rings, and convolution

NTRU predates the modern LWE family and has its own long line of analysis. Its arithmetic is built from polynomials with small coefficients in a quotient ring. Instead of multiplying ordinary integers or matrices, the algorithm repeatedly multiplies polynomials and reduces them by a polynomial relation and by an integer modulus.

R ≈ ℤ[x] / (xⁿ − 1)    with coefficient arithmetic also reduced mod p or mod q as required

Why polynomial rings?

A polynomial such as 2 − x + x³ can act like a compact vector. Multiplication becomes convolution. Reducing by xⁿ−1 “wraps” high-degree terms around.

Key intuition

Private polynomials are chosen to be small and to have required inverses modulo selected moduli. A public polynomial hides the private relationship. Encapsulation/encryption mixes a message or key-dependent value with fresh small randomness.

Teaching simplification: NTRU parameter sets and KEM conversions contain details beyond the historic classroom equation “c = r·h + m.” The interactive lab below demonstrates quotient-ring convolution, not an interoperable NTRU implementation.

Polynomial convolution lab

Enter coefficient lists for two degree-<7 polynomials. The demo multiplies them using cyclic convolution (the behavior created by reducing by x⁷−1), then reduces coefficients mod q.

Raw cyclic convolution appears here.
Reduced result appears here.

NTRU and the NIST process

NTRU reached the third-round finalist stage of NIST’s post-quantum standardization process. NIST ultimately standardized CRYSTALS-Kyber as the initial lattice-based KEM rather than NTRU. NTRU remains important historically, academically, and in continuing standardization and implementation work outside that specific NIST selection.

Algorithm module

CRYSTALS: Kyber → ML-KEM, Dilithium → ML-DSA

CRYSTALS-Kyber is the submission from which NIST’s ML-KEM standard was derived. CRYSTALS-Dilithium is a related lattice-based signature design from which NIST’s ML-DSA was derived. One establishes keys; the other signs data. Do not mix their roles.

CRYSTALS lineNIST standardized namePurposePrimary standard
CRYSTALS-KyberML-KEMKey encapsulation / shared-secret establishmentFIPS 203
CRYSTALS-DilithiumML-DSADigital signaturesFIPS 204

Module-LWE in one picture

ML-KEM works with short vectors of polynomials rather than one giant ordinary matrix or a single polynomial. Its base polynomial ring is:

R_q = ℤ_q[x] / (x²⁵⁶ + 1), with q = 3329

At a conceptual level, a public value again resembles a noisy linear map:

t = A·s + e

But now entries of A, s, e, and t are polynomials in Rq. ML-KEM uses fast polynomial arithmetic, including number-theoretic-transform techniques, to make these operations efficient.

Interactive miniature module demo

Real ML-KEM polynomials have 256 coefficients. This toy version uses four coefficients so you can watch the algebra. It uses negacyclic reduction, corresponding to x⁴ = −1.

Secret vector s

Error vector e

Public t = A·s + e

The three standardized ML-KEM parameter sets

ML-KEM-512

Lowest of the three standardized security-strength options and generally the smallest/fastest of the set.

ML-KEM-768

Middle parameter set. A common teaching and deployment reference point because it balances security strength and overhead.

ML-KEM-1024

Highest security-strength option among the three, with correspondingly greater bandwidth/computation costs.

Version discipline matters: “Kyber” and standardized “ML-KEM” are closely related but should not be treated as byte-for-byte interchangeable names. For standards work, implement against the final FIPS 203 specification and its current errata guidance.
Synthesis

Side-by-side comparison

FeatureFrodoKEMNTRUCRYSTALS-Kyber / ML-KEM
Main teaching lensPlain LWE with matricesNTRU polynomial-ring arithmeticModule-LWE with vectors of polynomials
Algebraic structureLess structured large matricesStrong polynomial quotient-ring structureModule over a polynomial quotient ring
Typical engineering characterComparatively large data and heavier matrix workCompact polynomial operations; long research historyCompact and fast; designed for efficient software/hardware arithmetic
NIST PQC outcomeEvaluated candidate; not the selected NIST KEM standardRound-3 finalist; not selected as the initial NIST KEM standardKyber selected; standardized derivative ML-KEM in FIPS 203
Best first concept to remember“A·S + noise”“small polynomials + convolution + modular inverses”“matrix algebra where each entry is itself a polynomial”

Three common misconceptions

“Post-quantum means quantum encryption.”

No. These algorithms run on ordinary computers. They are designed to remain secure even if attackers later obtain powerful quantum computers.

“A KEM encrypts my whole file.”

Usually not. A KEM establishes a shared secret; symmetric authenticated encryption handles bulk data.

“More algebraic structure automatically means weak.”

No. Structure can enable efficiency, but its security implications must be analyzed for the specific construction and parameters.

Why migration matters before a large quantum computer exists

An adversary can collect encrypted traffic today and attempt to decrypt it later if cryptanalytic capabilities improve. This “harvest now, decrypt later” risk is most important for information that must remain confidential for many years. Migration also takes time because cryptography is embedded in protocols, certificates, hardware, firmware, key-management systems, and compliance processes.

Hands-on

Interactive laboratory checklist

Use the controls in the earlier modules, then record your answers. The browser stores completion locally on this device.

Optional implementation lab with Open Quantum Safe

If students have a separate development machine, the Open Quantum Safe liboqs project provides a common API for experimenting with post-quantum KEMs and signatures. Use it as a prototyping/learning environment and follow the project’s current algorithm-status notes rather than assuming every experimental algorithm is production-ready.

Conceptual API pattern — not browser code 1. choose a KEM implementation 2. kem.keypair() → public_key, secret_key 3. kem.encaps(pk) → ciphertext, shared_secret_B 4. kem.decaps(ct, sk) → shared_secret_A 5. verify shared_secret_A == shared_secret_B 6. use the shared secret with an approved symmetric construction
Assessment

Knowledge check

Reference

Glossary

Basis: a set of linearly independent vectors whose integer combinations generate a lattice.

Ciphertext / encapsulation: public data produced during encryption or KEM encapsulation and sent to the recipient.

CVP: Closest Vector Problem.

Error / noise: deliberately sampled small values that obscure exact linear relationships in LWE-style systems.

KEM: Key-Encapsulation Mechanism; establishes a shared secret using a public/secret key pair.

Lattice: a discrete set of points generated by integer combinations of basis vectors.

LWE: Learning With Errors, a noisy linear-equation problem connected to lattice hardness.

ML-KEM: NIST’s Module-Lattice-Based Key-Encapsulation Mechanism standardized in FIPS 203 and derived from CRYSTALS-Kyber.

ML-DSA: NIST’s Module-Lattice-Based Digital Signature Algorithm standardized in FIPS 204 and derived from CRYSTALS-Dilithium.

Module-LWE: an LWE variant using vectors whose entries are elements of a polynomial ring.

Modulus q: the integer used for modular reduction; values “wrap around” modulo q.

NTT: Number Theoretic Transform; a finite-field analogue of FFT-style techniques used to accelerate certain polynomial operations.

Negacyclic convolution: polynomial convolution under a relation such as xⁿ = −1.

PQC: Post-Quantum Cryptography.

Quotient ring: a polynomial ring in which a selected polynomial relation is treated as zero, causing high-degree terms to reduce or wrap.

Ring-LWE: LWE formulated in a polynomial ring.

SIS: Short Integer Solution problem.

SVP: Shortest Vector Problem.

External reading

Authoritative and useful external sources

The links below are intentionally weighted toward standards bodies, algorithm-team specifications, peer-reviewed/ePrint papers, and maintained implementation projects.

Standards and NIST project material

NIST Standard

FIPS 203 — ML-KEM

Final U.S. standard for the Module-Lattice-Based Key-Encapsulation Mechanism.

Open NIST FIPS 203
NIST Standard

FIPS 204 — ML-DSA

Final U.S. standard for the Module-Lattice-Based Digital Signature Algorithm.

Open NIST FIPS 204
NIST Project

Post-Quantum Cryptography Project

Standardization history, selected algorithms, submissions, reports, and updates.

Open NIST PQC project
NIST History

Selected algorithms

Official page identifying CRYSTALS-Kyber, CRYSTALS-Dilithium, and other selected algorithms.

Open selected-algorithms page
NIST Report

NIST IR 8309

Second-round status report; useful for seeing how FrodoKEM, NTRU, Kyber, and peers were evaluated in the competition.

Open IR 8309
NIST History

Round 3 submissions

Official finalist/alternate information, including NTRU and CRYSTALS-Kyber.

Open Round 3 page

FrodoKEM

Algorithm Team

FrodoKEM project

Algorithm information, specification, software, and project material.

Open FrodoKEM site
Specification

FrodoKEM written specification

Detailed mathematical and algorithmic description of FrodoPKE/FrodoKEM.

Open specification PDF

NTRU

Algorithm Team

NTRU project site

NIST submission history, news, and current project links.

Open NTRU site
Specification & resources

NTRU resources

Submission packages, specifications, implementations, test vectors, and presentations.

Open NTRU resources

CRYSTALS / Kyber / Dilithium

Algorithm Team

CRYSTALS-Kyber

Original Kyber project material and submission documentation.

Open Kyber site
Papers & specs

Kyber resources

Specifications, papers, implementation work, and presentations.

Open Kyber resources
Algorithm Team

CRYSTALS-Dilithium

Original Dilithium project material for the signature side of CRYSTALS.

Open Dilithium site
Papers & specs

Dilithium resources

Algorithm specifications and supporting research.

Open Dilithium resources

Lattice foundations and deeper reading

Foundational paper

Regev — Learning With Errors

Foundational work linking LWE to worst-case lattice problems.

Open ACM record
Survey

Peikert — A Decade of Lattice Cryptography

Widely used survey covering lattice problems, LWE/SIS, reductions, and constructions.

Open IACR ePrint PDF
Course material

Peikert — Lattices in Cryptography

Graduate-level course page with lecture notes and mathematical background.

Open course page
Implementation lab

Open Quantum Safe / liboqs

Open-source experimentation framework with a common API for PQC KEMs and signatures.

Open liboqs
Implementation notes

OQS ML-KEM page

Algorithm metadata, source links, and implementation status for ML-KEM.

Open OQS ML-KEM page
Examples

liboqs example code

Small examples illustrating KEM encapsulation/decapsulation and digital signatures.

Open examples