A ground-up, tutorial-style implementation of Private Information Retrieval (PIR) — motivated by the problem of reading Ethereum state without revealing what you're looking for.
When you check your ETH balance, your wallet asks a remote server: "What is the state at address 0x1234...?"
The server now knows your address. This leaks:
- That you own this address
- When you're checking it (before a transaction, after news, etc.)
- Patterns across queries over time
PIR is a cryptographic protocol that lets a client retrieve a database entry without the server learning which entry was fetched.
Work through these in order. Each chapter builds on the last.
| Chapter | Concept | Key Insight |
|---|---|---|
| 01 — Naive PIR | Download everything | The trivially correct solution. Sets the baseline. |
| 02 — Two-Server PIR | XOR secret sharing | No crypto needed. Two non-colluding servers. Elegant. |
| 03 — Single-Server PIR | LWE-based (SimplePIR) | One server. Needs lattice crypto. Real-world practical. |
| 04 — Sharded PIR | Slice + decoy queries | How to handle heterogeneous databases efficiently. |
| 05 — Ethereum Context | Applied to chain state | Connects to the sharded PIR proposal by Ali Atiia & Keewoo Lee. |
- Python 3.10+
numpy(pip install numpy)- No other dependencies until chapter 03
- A Gentle Introduction to PIR — start here
- Chor et al. 1995 — the original 2-server scheme
- SimplePIR paper — the most practical single-server scheme today
- Sharded PIR for Ethereum State — what this repo builds toward
This is a learning-by-building exercise. The goal is not production code — it's intuition. Each implementation is intentionally minimal and annotated.
If something breaks in an instructive way, that's the point.