Skip to content

Commit 6f68378

Browse files
authored
Merge pull request 0xPolygon#563 from 0xPolygon/qa-quality-assurance2-zkevm
zkEVM - Quality assurance 2nd
2 parents aec540b + 174bada commit 6f68378

File tree

6 files changed

+50
-45
lines changed

6 files changed

+50
-45
lines changed
42.6 KB
Loading

docs/zkEVM/architecture/zkprover/index.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ The zkProver mainly interacts with two components, i.e. the Node and the databas
1515

1616
As depicted in the flow diagram above, the whole interaction works out in 4 steps.
1717

18-
1. The Node sends the content of Merkle trees to the database to be stored there
18+
1. The node sends the content of Merkle trees to the database to be stored there.
1919

20-
2. The Node then sends the input transactions to the zkProver
20+
2. The node then sends the input transactions to the zkProver.
2121

22-
3. The zkProver accesses the database and fetches the info needed to produce verifiable proofs of the transactions sent by the Node. This information consists of the Merkle roots, the keys and hashes of relevant siblings, and more
22+
3. The zkProver accesses the database and fetches the info needed to produce verifiable proofs of the transactions sent by the Node. This information consists of the Merkle roots, the keys and hashes of relevant siblings, and more.
2323

24-
4. The zkProver then generates the proofs of transactions, and sends these proofs back to the Node
24+
4. The zkProver then generates the proofs of transactions, and sends these proofs back to the Node.
2525

2626
However, this is really the tip of the iceberg in terms of what the zkProver does. There is a lot more detail involved in how the zkProver actually creates these verifiable proofs of transactions. It will be revealed while we dig deeper into state machines below.
2727

@@ -114,11 +114,11 @@ Each secondary state machine therefore consists of its own executor and a PIL pr
114114

115115
Here is a step-by-step outline of how the system achieves proof / verification of transactions:
116116

117-
- Represent a given computation as a state machine (SM),
118-
- Express the state changes of the SM as polynomials,
119-
- Capture traces of state changes, called execution traces, as rows of a lookup table,
120-
- Form polynomial identities / constraints that these state transitions satisfy,
121-
- Prover uses a specific polynomial commitment scheme to commit and prove knowledge of the committed polynomials,
117+
- Represent a given computation as a state machine (SM).
118+
- Express the state changes of the SM as polynomials.
119+
- Capture traces of state changes, called execution traces, as rows of a lookup table.
120+
- Form polynomial identities and/or constraints that these state transitions satisfy.
121+
- Prover uses a specific polynomial commitment scheme to commit and prove knowledge of the committed polynomials.
122122
- [Plookup](https://eprint.iacr.org/2020/315.pdf) is one of the ways to check if the Prover's committed polynomials produce correct traces.
123123

124124
While the polynomial constraints are written in the PIL language, the instructions are initially written in zkASM but subsequently expressed and stored in JSON format. Although not all verification involves a Plookup, the diagram below, briefly illustrates the wide role Plookup plays in the zkProver.
@@ -129,13 +129,13 @@ While the polynomial constraints are written in the PIL language, the instructio
129129

130130
For the sake of simplicity, one can think of the zkProver as being composed of the following four components;
131131

132-
- The Executor or the Main state machine executor
132+
- The Executor or the Main state machine executor.
133133

134-
- The STARK Recursion Component
134+
- The STARK Recursion Component.
135135

136-
- The CIRCOM library
136+
- The CIRCOM library.
137137

138-
- The zk-SNARK Prover
138+
- The zk-SNARK Prover.
139139

140140
In the nutshell, the zkProver uses these four components to generates verifiable proofs. As a result, the constraints that each proposed batch must meet are polynomial constraints or polynomial identities. All valid batches must satisfy specific polynomial constraints.
141141

@@ -147,32 +147,32 @@ The Executor or Main state machine Executor handles the execution of the zkEVM.
147147

148148
It takes as inputs; the transactions, the old and the new states, the ChainID of the Sequencer, to mention a few. The executor also needs;
149149

150-
1. The PIL, which is the list of polynomials, the list of the registers, and
151-
2. The ROM, which stores the list of instructions pertaining to execution
150+
1. The PIL, which is the list of polynomials, the list of the registers.
151+
2. The ROM, which stores the list of instructions pertaining to execution.
152152

153153
The Executor sets up the polynomial constraints that every valid batch of transactions must satisfy. Another language, specially developed by the team, called Polynomial Identity Language (or PIL), is used to encode all the polynomial constraints.
154154

155155
The Executor executes all instructions on top of the PIL hardware and generates the committed polynomials; which are the state machine cycles, or a list of all the states. It also generates some public data, which forms part of the input to the zk-SNARK verifier.
156156

157157
### STARK recursion component
158158

159-
Once the Main state machine Executor has converted transactions and related data to committed polynomials, the STARK Recursion Component takes the following inputs;
159+
Once the Main state machine Executor has converted transactions and related data to committed polynomials, the STARK Recursion component takes the following inputs;
160160

161-
1. The Committed Polynomials,
162-
2. The Constant Polynomials,
163-
3. Scripts, which are lists of instructions,
161+
1. The committed polynomials.
162+
2. The constant polynomials.
163+
3. Scripts, which are lists of instructions.
164164

165165
These are taken in order to generate a zk-STARK proof. In an effort to facilitate fast zk-STARK proving, the STARK Recursion Component utilises [Fast Reed-Solomon Interactive Oracle Proofs of Proximity (RS-IOPP)](https://drops.dagstuhl.de/opus/volltexte/2018/9018/pdf/LIPIcs-ICALP-2018-14.pdf), also referred to as FRI, for each zk-proof.
166166

167167
The component is referred to as the STARK Recursion, because;
168168

169-
; It actually produces several zk-STARK proofs,
169+
- It actually produces several zk-STARK proofs.
170170

171-
; Collates them into bundles of a few zk-STARK proofs,
171+
- Collates them into bundles of a few zk-STARK proofs.
172172

173-
; And produces a further zk-STARK proof of each bundle,
173+
- Produces a further zk-STARK proof for each bundle.
174174

175-
; The resulting zk-STARK proofs of the bundle are also collated and proved with only one zk-STARK proof.
175+
- The resulting zk-STARK proofs of the bundles are also collated and proved with only one zk-STARK proof.
176176

177177
This way, hundreds of zk-STARK proofs are represented and proved with only one zk-STARK proof.
178178

@@ -182,7 +182,7 @@ The single zk-STARK proof produced by the STARK Recursion Component is the input
182182

183183
The original CIRCOM [paper](https://www.techrxiv.org/articles/preprint/CIRCOM_A_Robust_and_Scalable_Language_for_Building_Complex_Zero-Knowledge_Circuits/19374986/1) describes it as both a circuits programming language to define Arithmetic circuits, and a compiler that generates two things;
184184

185-
1. A file containing a set of Rank-1 Constraints System (or R1CS) constraints associated with an Arithmetic circuit, and
185+
1. A file containing a set of Rank-1 Constraints System (or R1CS) constraints associated with an Arithmetic circuit.
186186
2. A program (written either in C++ or WebAssembly) for computing a valid assignment to all wires of the Arithmetic circuit, called a witness.
187187

188188
As implemented in the zkProver, CIRCOM takes as input a zk-STARK proof in order to perform two tasks;
@@ -196,7 +196,7 @@ The last component of the zkProver is the zk-SNARK Prover, in particular, Rapid
196196

197197
Rapid SNARK is a zk-SNARK proof generator, written in C++ and Intel Assembly, which is very fast in generating proofs of CIRCOM's outputs. With regards to the zkProver, the Rapid SNARK takes as inputs
198198

199-
1. The witness from CIRCOM, and
199+
1. The witness from CIRCOM.
200200
2. The STARK verifier data, which dictates how the Rapid SNARK must process the data, and then generate a zk-SNARK proof.
201201

202202
## Strategy to achieving succinctness

docs/zkEVM/concepts/circom-intro-brief.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ Consider as an example, the _Multiplier_ circuit with input signals $\texttt{a}$
8080

8181
![A simple Multiplier Arithmetic circuit](../../img/zkEVM/03circom-simple-arith-circuit.png)
8282

83-
The figure above depicts a simple _Multiplier_ Arithmetic circuit with input wires labeled $\texttt{a}$ and $\texttt{b}$ and an output wire labeled $\texttt{c}$ such that $\texttt{a} \times \texttt{b\ = } \texttt{c}$. The wires are referred to as signals. The constraint related to this Multiplier circuit is:
83+
The figure above depicts a simple _Multiplier_ Arithmetic circuit with input wires labeled $\texttt{a}$ and $\texttt{b}$ and an output wire labeled $\texttt{c}$ such that $\mathtt{a} \times \mathtt{b = }\ \texttt{c}$. The wires are referred to as signals. The constraint related to this Multiplier circuit is:
8484

8585
$$
86-
\texttt{a} \times \texttt{b} \texttt{ - c = 0}
86+
\mathtt{a} \times \mathtt{b} \mathtt{\ -\ c = 0}
8787
$$
8888

8989
### The `pragma` instruction
@@ -166,7 +166,7 @@ Small circuits can be defined which can be combined to create larger circuits by
166166

167167
As previously mentioned, the use of the operator "<==" in the _Multiplier template_ has dual functionality:
168168

169-
- It captures the arithmetic relation between signals, and
169+
- It captures the arithmetic relation between signals.
170170
- It also provides a way to compute $\texttt{c}$ from $\texttt{a}$ and $\texttt{b}$.
171171

172172
In general, the description of a CIRCOM circuit also keeps dual functionality. That is, it performs both symbolic tasks and computational tasks.
@@ -181,10 +181,10 @@ circom multiplier.circom --r1cs --c --wasm --sym
181181

182182
After compiling the _.circom_ circuit, the compiler returns four files,
183183

184-
- A file with the R1CS constraints (symbolic task)
185-
- A C++ program for computing values of the circuit wires (computational task)
186-
- A WebAssembly program for computing values of the circuit wires (computational task)
187-
- A file of symbols for debugging and printing the constraint system in an annotated way (symbolic task)
184+
- A file with the R1CS constraints (symbolic task).
185+
- A C++ program for computing values of the circuit wires (computational task).
186+
- A WebAssembly program for computing values of the circuit wires (computational task).
187+
- A file of symbols for debugging and printing the constraint system in an annotated way (symbolic task).
188188

189189
At this stage, either one of the C++ or WebAssembly programs generated by the compiler can be used to compute all signals that match the set of constraints of the circuit.
190190

@@ -220,13 +220,13 @@ The general syntax to specify the _main_ component is the following:
220220
component main {public [s1,..,sn]} = templateID(v1,..,vn);
221221
```
222222

223-
Specifying the list of public signals of the circuit, indicated as _{public [s1,..,sn]}_, is optional.
223+
Specifying the list of public signals of the circuit, indicated as $\mathtt{public [s1,..,sn]}$, is optional.
224224

225225
Note that global inputs are considered _private_ signals while global outputs are considered _public_.
226226

227227
However, the _main_ component has a special attribute to set a list of global inputs as public signals.
228228

229-
The rule of thumb is: Any other input signal not included in this list _{public [s1,..,sn]}_, is considered private.
229+
The rule of thumb is: Any other input signal not included in this list $\mathtt{public [s1,..,sn]}$, is considered private.
230230

231231
### Concluding CIRCOM's features
232232

docs/zkEVM/concepts/mfibonacci/commitment-scheme.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ It describes what a commitment scheme is, the necessary properties such a scheme
99

1010
## Commitment scheme protocol
1111

12-
In the case of our mFibonacci state machine, the prover needs to commit to the polynomials $P(X)$, $Q(X)$ $P( X \omega)$ and $Q( X \omega)$, and the verifier requests the prover to evaluate these polynomials at randomly selected points (i.e., field elements).
12+
In the case of our mFibonacci state machine, the prover needs to commit to the polynomials $P(X)$, $Q(X)$, $P( X \omega)$ and $Q( X \omega)$, and the verifier requests the prover to evaluate these polynomials at randomly selected points (i.e., field elements).
1313

1414
The general protocol, in an interactive setting, is as follows;
1515

@@ -72,12 +72,16 @@ In a typical commitment scheme, the following protocol is followed;
7272
$$
7373

7474
5. In order to enable the verifier to check the boundary constraint,
75+
76+
$$
77+
P(\omega^{\mathtt{1023}}) = \mathtt{14\ 823\ 897\ 298\ 192\ 278\ 947}
78+
$$
7579

76-
$$
77-
P(\omega^{\mathtt{1023}}) = \mathtt{14\ 823\ 897\ 298\ 192\ 278\ 947}\qquad\qquad
78-
$$
79-
80-
the prover must send a witness $\large{\mathtt{w}}$ as proof that he or she knows the correct value of the $1024$-th term, without disclosing the actual value $A_{1023} = \mathtt{14\ 823\ 897\ 298\ 192\ 278\ 947}$.
80+
the prover must send a witness $\large{\mathtt{w}}$ as proof that he or she knows the correct value of the $1024$-th term, without disclosing the actual value
81+
82+
$$
83+
A_{1023} = \mathtt{14\ 823\ 897\ 298\ 192\ 278\ 947}.
84+
$$
8185

8286
6. The verifier then uses a formula, which is specific to the commitment scheme in use and it takes the witness as an input, to check whether the prover has computed the correct $A_{1023}$.
8387

docs/zkEVM/spec/pil/compiling-using-pilcom.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ polIdentities: 1
102102
103103
The debug message reflects the numbers of;
104104
105-
- Input committed polynomials, denoted by $\texttt{Input Pol Commitments}$,
106-
- Quadratic polynomials, denoted by $\texttt{Q Pol Commitmets}$,
107-
- Constant polynomials, denoted by $\texttt{Constant Pols}$,
108-
- Intermediate polynomials, denoted by $\texttt{Im Pols}$,
105+
- Input committed polynomials, denoted by $\texttt{Input Pol Commitments}$.
106+
- Quadratic polynomials, denoted by $\texttt{Q Pol Commitmets}$.
107+
- Constant polynomials, denoted by $\texttt{Constant Pols}$.
108+
- Intermediate polynomials, denoted by $\texttt{Im Pols}$.
109109
- The various identities that can be checked; the $\texttt{Plookup}$, the $\texttt{Permutation}$, the $\texttt{connection}$ and the $\texttt{Polynomial}$ identities.
110110
111111
The resulting $\texttt{JSON}$ file into which the _multiplier.pil_ code is compiled looks like this:

docs/zkEVM/spec/pil/filling-polynomials.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ async function execute() {
2626

2727
The _pilcom_ package also provides two functions; _newConstPolsArray_ and _newCommitPolsArray_. Both these functions use the _pil_ object in order to create two crucial objects:
2828

29-
1. First is the constant polynomials object _constPols_, which is created by the _newConstPolsArray_ function, and
29+
1. First is the constant polynomials object _constPols_, which is created by the _newConstPolsArray_ function.
30+
3031
2. Second is the committed polynomials object _cmPols_, created by _newCommitPolsArray_.
3132

3233
Below is an outline of the _pilcom_ package.

0 commit comments

Comments
 (0)