0Pricing
Cryptology Academy · Lesson

Learning With Errors (LWE) Foundation

Understand the LWE hard problem that underpins HE schemes.

Learning With Errors (LWE) Foundation is a free Cryptology Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cryptology Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Hard Problem Intuition

Learning With Errors (LWE) by Regev (2005): given many noisy linear equations over Z_q, find the secret vector s. The noise e is small but prevents Gaussian elimination. Without noise, the system is easy; with even tiny noise, it becomes computationally hard.

LWE Definition

Secret s ∈ Z_q^n. Adversary receives samples (a_i, b_i) where a_i ∈ Z_q^n random, b_i = + e_i mod q, e_i small noise from distribution χ (e.g., Gaussian with σ = √n). Task: find s given polynomially many samples.

Why Noise Is Essential

Without noise: b_i = mod q. Gaussian elimination recovers s in O(n^3). With noise: even one wrong equation corrupts elimination. The noise is small enough that decryption works (using the key), but large enough to prevent cryptanalysis.

LWE Hardness

Regev proved LWE reduces to worst-case lattice problems (SIVP, GapSVP) with quantum reduction. This means: if LWE is broken, many hard lattice problems are solved — but no quantum algorithm is known for lattice problems. LWE is post-quantum secure.

Ring-LWE (RLWE)

RLWE replaces Z_q^n with the ring Z_q[x]/(f(x)) for a cyclotomic polynomial f. One RLWE sample encodes n equations — much more efficient. RLWE is the basis for Kyber (KEM), Dilithium (signature), and BFV/BGV/CKKS HE schemes.

LWE Parameters

Security depends on: n (dimension, typically 512-2048), q (modulus, 1024-2^60), σ (noise standard deviation). Larger n and smaller σ/q ratio = harder. NIST Post-Quantum standards use n=256 (module dimension) with k modules (k=2,3,4).

LWE Encryption

Public key: (A, b=As+e). Encrypt bit m: choose random r, compute ciphertext (u=A^T r, v = b^T r + m*q/2). Decrypt: v - s^T u = e^T r + m*q/2 ≈ m*q/2. Round to nearest m. Noise e keeps the ciphertext hiding m during encryption.

Decision LWE

Decision-LWE: distinguish (a, As+e) from (a, u) where u is uniform random. Computationally indistinguishable assuming LWE hardness. This is the semantic security basis — ciphertexts look like random noise to adversaries without the secret key.

Lattice Reduction Attacks

Best known attacks: BKZ (Block Korkine-Zolotarev) lattice reduction. Complexity: sub-exponential but not polynomial. BKZ-β requires 2^{0.292β} operations. For LWE-512: security ≈ 128 bits against BKZ. No quantum speedup known for BKZ.

Module-LWE

Module-LWE (used in Kyber) is RLWE over modules of rank k. Provides flexibility: k=2 for 512-bit security, k=3 for 768-bit, k=4 for 1024-bit. Security and performance scale with k. NIST selected Kyber (renamed ML-KEM) as the PQC standard.

Comparison with RSA/ECC

RSA/ECC security: based on integer factoring/discrete log (quantum-vulnerable via Shor). LWE security: based on worst-case lattice problems (no known quantum speedup). Key sizes: LWE keys ~1 KB vs RSA-2048 256 bytes. LWE is larger but quantum-safe.

Quick Check

What makes LWE hard to solve even with many samples?

Recap

LWE: find secret s from noisy linear equations — quantum-hard. RLWE uses polynomial rings for efficiency. Basis for Kyber, Dilithium, and HE schemes. Next: BGV and BFV HE schemes for integer operations.

Frequently asked questions

Is the “Learning With Errors (LWE) Foundation” lesson free?

Yes — the full text of “Learning With Errors (LWE) Foundation” is free to read here on the web, and the Cryptology Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cryptology Academy course, upgrade to CoddyKit PRO.

What will I learn in “Learning With Errors (LWE) Foundation”?

Understand the LWE hard problem that underpins HE schemes. You practise Cryptology Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Cryptology Academy?

No prior experience is required. Cryptology Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Learning With Errors (LWE) Foundation” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Cryptology Academy lesson?

Yes. Every Cryptology Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. What Is Homomorphic Encryption?
  2. Learning With Errors (LWE) Foundation
  3. BGV & BFV Schemes for Integer Operations
  4. CKKS for Approximate Arithmetic & ML
← Back to Cryptology Academy