Foundations: What ZKPs are, what they can do, and the math framework behind them
๐ The Password Paradox
Every time you log in to a website, you prove you know the password...
...by revealing the password.
What if you could prove you know it without ever sending it?
That's Zero Knowledge Proofs in one sentence.
Agenda
Time
Topic
0:00
What Are Zero Knowledge Proofs?
0:10
Computational Complexity: P, NP, PSPACE
0:25
Witnesses & Verification
0:35
Boolean Circuits
0:45
Arithmetic Circuits
0:55
Wrap-up & Practice Problems
Part 1: What Are Zero Knowledge Proofs?
~10 minutes
The Core Idea
A Zero Knowledge Proof lets a prover convince a verifier that a statement is true —
without revealing any information about why it's true.
Analogy: Prove to a bouncer you're over 21 — without showing your ID, name, address, or exact age.
Why ZKPs Matter in Web3
Use Case
What's Proven
What Stays Hidden
Privacy mixers
"I deposited funds earlier"
Which deposit is yours
zkRollups
"All transactions are valid"
Transaction details
Private voting
"I'm eligible and this is my vote"
Who you voted for
Identity
"I meet the criteria"
Personal data
Three Properties of ZKPs
Completeness — If the statement is true and both parties are honest, the verifier will be convinced
Soundness — If the statement is false, no cheating prover can trick the verifier (except with negligible probability)
Zero Knowledge — The verifier learns nothing beyond the truth of the statement
Discussion: Can you think of a situation in smart contracts where you'd want to prove something without revealing the underlying data?
Part 2: Computational Complexity
P, NP, PSPACE โ ~15 minutes
To understand what ZK proofs can and cannot do, we need to classify problems by difficulty.
Solving vs. Checking: The Key Difference
Before we classify problems, understand one idea:
๐ Solving
Finding the answer from scratch.
Like doing a jigsaw puzzle with no picture on the box.
โ Checking
Verifying someone else's answer is correct.
Like looking at a completed jigsaw and confirming all pieces fit.
Some problems are easy to both solve and check.
Some are hard to solve but easy to check.
Some are hard to even check! ZK proofs only work when checking is easy.
Problems in P — "Practical"
Easy to solve AND easy to check.
Problem
Solve
Check
Sorting a list
Compare & swap — fast for millions
Scan left to right: each item ≥ previous?
Finding a name
Scan through the whole list
"Alice is at pos 42" → look at pos 42
Drive City A → B?
Try different routes until one works
Follow the directions — do you arrive?
P = "Practical" — Both solving and checking finish in reasonable time, even for huge inputs.
Problems in NP
Hard to solve but easy to verify.
Sudoku
Solve: Exponential search through combinations
Verify: O(n²) — check rows, columns, subgrids
3-coloring a map
Solve: Brute-force through exponential color assignments
Verify: O(n) — check each pair of neighbors
Key insight: All P problems are also NP problems. P ⊆ NP
Problems in PSPACE — "Impossible to Check"
Hard to solve AND hard to check.
Problem
Why checking is hard
๐
Best move in chess
Must explore every opponent response & counter-move — no shortcut
๐ฎ
Unbeatable game strategy
Must simulate every possible game against every opponent
No "receipt" exists — nothing anyone can show you makes checking fast.
No ZK proofs possible here — if you can't check the answer quickly, you can't create a proof for it.
The Hierarchy
PSPACE
Hard to solve, hard to verify
NP
Hard to solve, easy to verify
P
Easy to solve, easy to verify
Summary Table
Class
Time to Solve
Time to Verify
P
Polynomial
Polynomial
NP
No requirement (often exponential)
Polynomial
PSPACE
No requirement
No requirement
ZK Proofs only work for P and NP problems — problems where the solution can be verified efficiently. If you can't verify it efficiently, you can't create a ZK proof for it.
โก Quick Check: Classify These!
Vote with your hands: 1 finger = P, 2 fingers = NP, 3 fingers = PSPACE
Problem
Your Vote
Answer
Binary search in a sorted list
๐ค
P โ O(log n) solve & verify
Solving a 9ร9 Sudoku
๐ค
NP โ hard to solve, easy to check
Finding the best chess move
๐ค
PSPACE โ can't even verify efficiently
"Is 997 prime?"
๐ค
P โ AKS primality test
Part 3: Witnesses & Verification
~10 minutes
What is a Witness?
A witness = the evidence that lets you quickly check a solution. Like a receipt ๐งพ.
Problem
Witness ("receipt")
How to check
Sorting a list
The sorted list
Scan: each item โฅ previous?
Finding "Alice"
"Position 42"
Look at pos 42
Drive city AโB?
Turn-by-turn directions
Follow them — arrive?
Sudoku
Filled grid
Rows, cols, boxes: all 1-9?
3-coloring
Color per region
Each border: neighbors differ?
PSPACE problems (chess, game strategies) have NO useful witness — no receipt exists.
The "Knowledge" in Zero Knowledge
The "knowledge" in ZKP = knowledge of the witness.
Concrete example — Sudoku:
Claim: "I solved this Sudoku puzzle"
Witness: The completed grid (SECRET โ only the prover knows this)
ZK Proof: Convinces the verifier the grid is valid
...WITHOUT ever showing the actual numbers
The ZK pipeline (how it works under the hood):
Express the problem as a circuit (math equations) — we'll learn this today
The prover plugs in their witness (the secret solution)
Cryptographic magic generates a proof
The verifier checks the proof — without ever seeing the witness
ZKPs Can't Do Everything
ZKPs cannot help you find a solution — only prove you have one
ZKPs cannot work for PSPACE problems — no efficient checking
ZKPs can work for any P or NP problem — anything where checking is fast
Think of ZKPs like a notary stamp: the notary confirms a document is valid, but doesn't create the document for you.
Real Example: Merkle Proof
You've likely seen this in Solidity — let's connect it to what we just learned.
ROOT HASH (stored on-chain)
/ \
Hash(A+B)Hash(C+D)
/ \ / \
Hash AHash B Hash C Hash D
| | | |
Leaf A Leaf B Leaf C Leaf D
โ
YOU WANT TO PROVE THIS LEAF IS IN THE TREE
Statement
"Leaf B is part of this Merkle tree"
Witness
Leaf B + Hash A + Hash(C+D) (the sibling hashes along the path)
Checking
Hash the leaf up the tree → does the result match the root?
This is NP: Hard to guess which leaves exist, but easy to verify a claimed leaf with just 2-3 hashes!
Part 4: Boolean Circuits
~10 minutes
We need a universal language to express any verifiable problem. Boolean circuits give us that.
Boolean Operators
Operator
Symbol
Description
AND
∧
True only when both inputs are true
OR
∨
True when at least one input is true
NOT
¬
Flips true ↔ false
Example formula with variables x1, x2, x3, x4:
out = (x1 ∨ ¬x2 ∨ ¬x3) ∧ (¬x2 ∨ x3 ∨ x4)
Verifying a Boolean Formula
Given: out = (x1 ∨ ¬x2 ∨ ¬x3) ∧ (¬x2 ∨ x3 ∨ x4)
Proposed witness: x1=T, x2=F, x3=T, x4=F
Plug in: (T ∨ T ∨ F) ∧ (T ∨ T ∨ F)
= T ∧ T
= TRUE ✓
Finding the assignment → may be exponential Verifying a proposed assignment → polynomial (just plug in!)
3-Coloring as a Boolean Circuit
Each territory gets Boolean variables per color: WA_G, WA_B, WA_R
Color constraint — exactly one color per territory:
Boolean circuits are overly long for number operations. Express 8 + 4 = 12:
Number
Binary
Boolean vars
8
1000
aโ=1, aโ=0, aโ=0, aโ=0
4
0100
bโ=0, bโ=1, bโ=0, bโ=0
12
1100
cโ=1, cโ=1, cโ=0, cโ=0
โ Boolean: 12 vars + carry logic
aโ XOR bโ = cโ (with carry)
aโ XOR bโ XOR carry = cโ
... MANY more lines
โ Arithmetic: 3 vars, 1 equation
a + b === c
// That's it. Done.
This is why ZK systems use arithmetic circuits.
Part 5: Arithmetic Circuits
~10 minutes
A simpler, more compact way to express problems for ZK proofs.
What is an Arithmetic Circuit?
A system of equations using only three operations:
Addition (+)
Multiplication (×)
Equality (===)
First example:
6 === xโ + xโ
9 === xโ * xโ
Satisfied by xโ = 3, xโ = 3
=== means assert equal, not assign.
Think: assertEq(left, right)
Constraining Values
How do we force a signal to be 0 or 1?
x(x - 1) === 0
Only x = 0 or x = 1 satisfies this!
How do we force a signal to be one of {1, 2, 3}?
0 === (1 - x) * (2 - x) * (3 - x)
A polynomial that has roots at exactly 1, 2, and 3.
3-Coloring with Arithmetic Circuits
Instead of 3 Boolean variables per territory → 1 signal with values {1, 2, 3}
// Color constraints โ each territory is colored 1, 2, or 3
0 === (1 - WA) * (2 - WA) * (3 - WA)
0 === (1 - SA) * (2 - SA) * (3 - SA)
0 === (1 - NT) * (2 - NT) * (3 - NT)
// ... one per territory
// Boundary constraints โ neighbors have different colors
// If x โ y and both โ {1,2,3}, then x*y โ {2, 3, 6}
0 === (2 - WA*SA) * (3 - WA*SA) * (6 - WA*SA)
0 === (2 - WA*NT) * (3 - WA*NT) * (6 - WA*NT)
// ... one per border
Same 15 constraints as Boolean, but ⅓ the variables.
Boolean ↔ Arithmetic Translation
Every Boolean gate has an arithmetic equivalent (when inputs are constrained to 0 or 1):
Boolean
Arithmetic
NOT u → t
t === 1 - u
u AND v → t
t === u * v
u OR v → t
t === u + v - u*v
Conversion Example
Boolean: out = (x ∧ ¬y) ∨ z
Step by step → Arithmetic:
// Constrain inputs to 0 or 1
x(x - 1) === 0
y(y - 1) === 0
z(z - 1) === 0
// ยฌy โ (1 - y)
// x โง ยฌy โ x * (1 - y)
// ... โจ z โ x*(1-y) + z - x*(1-y)*z
// Final:
out === x - x*y + z - x*z + x*y*z
The ZK Pipeline
Real-world problem
↓
Arithmetic Circuit (system of constraints)
↓
Prover: "I know a witness that satisfies all constraints"
↓
ZK Proof: Verifier confirms without seeing the witness
All problems in P and NP can be expressed as arithmetic circuits.
This is the foundation everything else is built on.
Live Demo: Boolean vs Arithmetic
Prove (x AND NOT y) OR z equals its arithmetic version for ALL inputs.
def boolean_circuit(x, y, z): # Python keywords
return (x and not y) or z
def arithmetic_circuit(x, y, z): # Only +, *, integers
assert x*(x-1) == 0 and y*(y-1) == 0 and z*(z-1) == 0
return x - x*y + z - x*z + x*y*z # NOT=(1-y), OR=a+b-ab
for x in [0,1]: # Test all 8 combos
for y in [0,1]:
for z in [0,1]:
b = 1 if boolean_circuit(x,y,z) else 0
a = arithmetic_circuit(x,y,z)
assert b == a
print(f"x={x}, y={y}, z={z} -> {a}")
print("All 8 match!")
Key Takeaways
ZKPs let you prove you know something without revealing it
Only P and NP problems can have ZK proofs (solutions must be efficiently verifiable)
Witnesses are the secret knowledge the prover has
Arithmetic circuits are systems of equations (add, multiply, equals) that model any NP problem
Arithmetic circuits are more compact than Boolean circuits for most ZK applications
Practice Problems
Classify as P, NP, or PSPACE: shortest path in a graph, prime factorization, best Go move, primality testing
Create an arithmetic circuit satisfied when all signals x1...xn are 1
Create an arithmetic circuit satisfied when at least one signal is 0
Convert this Boolean formula to arithmetic: out = (a ∨ b) ∧ ¬c
Design a 2-coloring circuit for a bipartite graph (hint: adjust the 3-coloring scheme)
Next Workshop
Finite Fields & Modular Arithmetic
How arithmetic circuits handle division and overflow
Modular arithmetic — the number system ZK proofs operate in
Additive and multiplicative inverses
Polynomials over finite fields
This is the number system that makes ZK proofs possible.