Remco Bloemen remco@0x.org
Disclaimer: contains math
- If you don't understand something
- Not your fault, this stuff is hard
- Nobody understands it fully
- If you don't understand anything
- My fault, anything can be explained at some level
- If you do understand everything
- Collect your Turing Award & Fields Medal
- Many open questions
Zero knowledge proofs
We know some algorithm .
I give you and and proof that “I know an such that ” without revealing .
- public input, old balances.
- secret input, trades.
- public output, new balances.
Scalable DEX
“I know an such that ”
- public input : (merkle root of) old balances.
- secret input : trades.
- public output : (merkle root of) new balances.
verifies maker and taker signatures on the trades and updates the balances.
Naive solution
- I give you , and .
- You compute and verify that it is .
Problems:
- 📀 I need to send data size , i.e. all the trades.
💾 We want , only merkle roots.
- ⏳ You need to do computations .
⌛ We want constant gas.
- 🤫 You now know , the secret input.
🤷 We don't care.
Math refresher: Polynomials
|
|
Constant |
|
Linear |
|
Parabola |
|
Cubic |
|
Quartic |
|
… |
|
Can be uniquely described in three ways:
- Coefficients
- Points
- Zeros* and a scaling factor
(* Zeros might be imaginary.)
Can do math with them:
- Add .
- Multiply .
- Divide
- Division works when zeros match.
Toy example: Fibonnacci
We want to prove the 1000-th Fibonacci number starting from a public and a secret value. Take to mean the following:
Computational trace
Computation with steps and registers. The trace is a table.
Here and . Restate algorithm as constraints on
Example: , :
n |
|
|
0 |
3 |
4 |
1 |
4 |
7 |
2 |
7 |
11 |
3 |
11 |
18 |
… |
… |
… |
999 |
|
|
Encode the algorithm as a set of transition constraints:
and boundary constraints:
‟I know such that .”
‟I know a trace such that the constraints hold.”
Trace polynomials
For each register , create a polynomial of degree such that
for .
(Actual implementation uses with a -root of unity to allow FFT and FRI. Also rounds up to the next power of two. Ignore for now.)
Consider the constraint for :
for
for
is zero when is an integer .
is a polynomial and is zero only when is an integer .
This means
is also a polynomial.
Create functions that are polynomial only when the constraints are satisfied:
Transition constraints:
Boundary constraints:
‟I know such that .”
‟I know a trace such that the constraints hold.”
‟I know polynomials and such that , , , are polynomial.”
Interactive proof
I give you , and a merkle roots of and .
You give me random values , , , .
Fast Reed-Solomon Interactive Oracle Proof II
Given a random number , we can fold the coefficients and get a polynomial of degree .
This can be computed using:
Given a random number , we can fold the coefficients and get a polynomial of degree .
I compute .
I give you the merkle root of and claim .
You give me a random value .
I give you the merkle root of and claim .
You give me a random value .
…
I give you the constant .
You verify using , , the s and the s.
All you do is give me random numbers. Why don't I replace you by a pseudo random number generator!
Seed PRNG with all prover messages, extract random 'verfier' messages.
Send all the proof at once.