๐ฎ The Magic Seed
How ML-KEM Shrinks 3,456 Bytes to 32โ
๐ฏ The Simple Storyโ
Imagine you need to send someone the entire city of New York:
Problem: It's too big!
Solution: Send them a magic seed instead!
You tell them: "Plant this seed and you'll get the whole city!"
When they "plant" it (run a program), New York grows out of that one tiny seed!
That's how ML-KEM sends huge matrices as just 32 bytes - like sending a seed instead of the entire city!
๐ง Mental Modelโ
Hold this picture in your head:
Normal way (impossible):
Full Matrix A:
โโโโโโโโโโโโโโโโโโโ
โ 256 coeffs โ ร 9 polynomials
โ (2,304 total) โ = 3,456 bytes raw!
โ โ Too big to send!
โโโโโโโโโโโโโโโโโโโ
โ โ โ โ โ โ โ
Sender toReceiver: [3,456 bytes]
Too slow!
Better way (magic):
1. Bob picks random 32-byte seed
2. Expands seed โ generates entire matrix
3. Stores seed, not matrix!
Sender toReceiver: [32 bytes] โ Just the seed!
Instant!
Receiver re-expands โ same matrix Bob created!
Think of it like:
๐ฑ Plant a tree (seed โ full tree)
๐ Read a book (index โ full story)
๐ Recipe card (list of steps โ full meal)
ML-KEM: Seed โ Expand โ 3,456 bytes (deterministic!)
๐ See It Happenโ
Let's watch the magic seed process:
๐ฎ Try It Yourselfโ
Question 1: Matrix A = 9 polynomials ร 256 coefficients = 2,304 coefficients ร 12 bits each = 27,648 bits. How many bytes raw?
Show Answer
Total bits: 2,304 ร 12 = 27,648 bits
Convert to bytes: 27,648 รท 8 = 3,456 bytes
Answer: 3,456 bytes raw
Question 2: If we use the seed compression trick, how many bytes do we send instead?
Show Answer
Traditional: Send 3,456 bytes directly
Seed trick: Send just 32-byte seed
Compression ratio: 3,456 รท 32 = 108ร smaller!
Answer: 32 bytes (99% smaller!)
Question 3: Why is this better than sending the raw matrix? Speed?
Show Answer
Assume 1 second to send 1 kilobyte:
Raw: 3,456 bytes ร 1 sec/KB = ~3.5 seconds Seed: 32 bytes ร 1 sec/KB = ~0.03 seconds (instant!)
Speedup: 100ร faster transmission (like 3 seconds vs 0.03 seconds)
Answer: 100ร faster to send seed vs raw matrix!
๐ข The Mathโ
Problem: Huge Matricesโ
In ML-KEM, matrix A has:
Where:
- for ML-KEM768
- polynomial entries
- Each polynomial has 256 coefficients
Total: coefficients
Each coefficient: 12 bits (0 to 3,328)
Raw size: bits = 3,456 bytes
Sending 3,456 bytes = Too slow!
Solution: Pseudo-Random Generator (PRG)โ
Idea: Store a small seed, expand when needed!
- Bob generates: 32-byte random seed
- Bob uses PRG: Expand โ Matrix
- Bob stores: Just (not !)
- When needed: Re-expand โ (deterministic)
PRG property: Same seed โ same output (always!)
Deterministic Expansionโ
Given seed , PRG computes:
Maps 256-bit seed to 3,456-byte matrix deterministically!
๐ก Why We Careโ
Transmission Speedโ
Without seed:
- Send 3,456 bytes = 3.4 KB
- At 1 KB/s: ~3.5 seconds
With seed:
- Send 32 bytes = 0.03 KB
- At 1 KB/s: ~0.03 seconds
100ร faster!
Storage Efficiencyโ
Public key contains:
- Matrix expansion (3,456 โ 864 bytes)
- Vector t (1,152 โ 320 bytes)
Total: 1,184 bytes (still much smaller than 4.6 KB!)
Security Propertyโ
The seed approach doesn't just shrink sizeโit's essential for ML-KEM:
- Attacker sees: 32-byte seed
- Can re-expand: To get matrix A
- But matrix A is: Deterministically generated
- Security: Based on seed hardness + MLWE hardness
Seed just tells you HOW to recompute A, doesn't give you A itself!
โ Quick Checkโ
Can you explain the seed trick to a 5-year-old?
Try saying this out loud:
"The seed trick is like storing a recipe card instead of the entire meal. When you want the meal, you just follow the recipe. ML-KEM sends a tiny seed, and the receiver expands it to get the whole matrix!"
Can you compute seed compression?
Try this examples:
Matrix has 2,304 coefficients ร 12 bits = 27,648 bits
Send raw: 27,648 รท 8 = 3,456 bytes Send seed: 32 bytes
Compression ratio: 3,456 รท 32 = 108ร
Speedup: Sending takes 100ร less time!
๐ Key Takeawaysโ
โ Seed trick = Store 32 bytes, expand to 3,456 bytes โ PRG = Pseudo-random generator (deterministic) โ Compression = 108ร smaller, 100ร faster โ Re-expand = Same seed โ same matrix (always!) โ Public key = Seed + vector t (1,184 bytes total) โ Security still fine = Seed hardness + MLWE hardness
๐ What You'll Learn Nextโ
Now you understand encoding and the seed trick! Next, we'll understand key generation:
๐ Making the Key โ Key Generation
How ML-KEM็ๆ (generates) public/private key pairs!