๐Ÿ”ท Interactive Simulation

CRYSTALS-Kyber

A lattice-based Key Encapsulation Mechanism (KEM) โ€” quantum-safe key exchange standardised by NIST in 2024.

๐Ÿ”ท
Step 1 โ€” What Is a Lattice?
Kyber's security comes from the hardness of problems on mathematical lattices โ€” regular grids of points in high-dimensional space.
A lattice is an infinite grid of points generated by combining basis vectors. The hard problem: given a point near the lattice, find the closest lattice point. In high dimensions, this is computationally infeasible โ€” even for quantum computers.
Blue = lattice points  |  Orange = "noisy" point (hard to place exactly)
โ–ธ Module-LWE: Learning With Errors over modules
โ–ธ Given: matrix A, vector b = As + e
โ–ธ Find: secret s (hard, because of error e)
โ–ธ Arithmetic done mod q = 3329 (Kyber's prime)
โ–ธ Polynomials in ring โ„ค_q[x]/(xยฒโตโถ+1)
๐Ÿ—๏ธ
Step 2 โ€” Key Generation (Bob / Recipient)
Bob generates a public/private key pair. The public key is a matrix A and a vector t = As + e. The private key is the secret vector s.
Simplified toy version (real Kyber uses 256-degree polynomials mod 3329). Here we use small integers mod q to show the same structural logic clearly.
๐Ÿ“ฆ
Step 3 โ€” Encapsulation (Alice / Sender)
Alice uses Bob's public key to encapsulate a shared secret. She produces a ciphertext (u, v) that only Bob can open.
Alice picks a random message bit m โˆˆ {0,1}, then:
u = Aแต€r + eโ‚  (mod q)  |  v = tแต€r + eโ‚‚ + โŒˆq/2โŒ‰ยทm  (mod q)
Ciphertext (u, v) is sent to Bob. The shared secret K = Hash(m).
๐Ÿ”“
Step 4 โ€” Decapsulation (Bob / Recipient)
Bob uses his private key s to recover mโ€ฒ from (u, v), then derives the same shared secret K.
Bob computes: w = v โˆ’ sแต€u (mod q)
If w is close to โŒˆq/2โŒ‰, mโ€ฒ=1; if close to 0, mโ€ฒ=0. Small errors cancel out because e,eโ‚,eโ‚‚ are tiny.
๐Ÿ›ก๏ธ
Step 5 โ€” Post-Quantum Security
Why lattice problems resist quantum attacks where RSA and DH fail.
Shor's algorithm (1994) breaks RSA and DH in polynomial quantum time. But it solves number-theoretic problems (factoring, discrete log) โ€” it has no known advantage against lattice problems like LWE.
AlgorithmClassical securityQuantum securityBased on
RSA-2048~112-bitBrokenInteger factorisation
DH-2048~112-bitBrokenDiscrete log
Kyber-512~118-bit~100-bitModule-LWE
Kyber-768~180-bit~161-bitModule-LWE
Kyber-1024~230-bit~254-bitModule-LWE

Key sizes (bytes)
Kyber-768 Public key: 1184 B
Kyber-768 Private key: 2400 B
Kyber-768 Ciphertext: 1088 B
RSA-2048 Public key: 256 B (smaller, but broken by quantum)
Deployment status
โœ“ NIST FIPS 203 (2024) โ€” official standard
โœ“ Chrome, Cloudflare: X25519+Kyber768 hybrid since 2023
โœ“ Signal Protocol: PQXDH (Kyber) since 2023
โœ“ Apple iMessage: PQ3 (Kyber) since 2024