Everyone talks about zero-knowledge proofs (ZKP), but who understands them? How can a proof consist of bytes without leaking any knowledge? Why should I trust such a proof? 🤔
This is a workshop about ZKP written in Python. We use Jupyter as our interactive learning environment. Each notebook is a chapter. The chapters cover fundamentals, applications and much more. Explore and have fun 😜
We will not cover the latest and shiniest crypto. We will not build SNARKs, STARKs or validity rollups. The code you will see will not live up to the highest security standards (we use insecure parameters and take shortcuts for easier learning) 🕵️
Master the basics first, then move to the advanced stuff; that is my philosophy. Let's build an intuition for how ZKP works. We start small and work our way up. Things becomesimpler when we break them down into their constituent parts. Divide and conquer. Once there is understanding, we can take what we learned here and apply it to real problems 💪
Zero-knowledge proofs have clear benefits compared to ordinary plain-text proofs. These properties might seem impossible and have the potential to change our world.
Proofs grow logarithmically in size. If you double the size of the data, then the size of the proof grows by a single bit. This means, we can compress data beyond entropy!
Proofs take logarithmic time to verify. If you double the number of steps of a computation, then the verification of the proof only takes one step longer! This means, we can compress computations!
Proofs reveal no information. Everything that is sent over the wire is randomized. This means, we can work on private data without revealing it!
Run the workshop online (binder) or locally (nix or pip).
We have come a long way since this workshop Sage (1 GB). The new dependencies take up less than 50 MB 🍃
See below how to set up the workshop.
Then select a chapter to read 📖
Click the binder badge and wait for the workshop to be built on the server.
Use the provided nix flake to set up the runtime environment.
nix develop
Run Jupyter on the command line.
jupyter notebook
Create a virtual environment and use pip to install the dependencies.
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
Run Jupyter on the command line.
jupyter notebook
Some chapters depend on lessons from other chapters.
Start with chapters that depend on nothing else and work your way down the dependency tree, towards more advanced chapters.
Skip / skim lessons you already know. Look at what interests you and ignore everything else. Have fun 🤓
See how the curve points jump in 2D space as you iterate through the curve.
This is explained in more detail in the chapter on elliptic curves 🌀
python3 hardness_dlog.py
Play the side of Victor in an interactive proof of knowledge of a Sudoku solution. Accept or reject. Peggy might be lying! 🧩
python3 play_sudoku.py
Look at the documentation for how to further customize the workshop 🎨
If you see errors or room for improvement, then feel free to open a Github issue.
Pull requests are also welcome.
Let's turn this workshop into the best it can be 🚀
There is a lot more to learn about ZKP.
Check out these external resources. Happy learning 🧠