Skip to content

Commit a24360d

Browse files
committed
Last update fixing table & equation rendering
1 parent ad1e5b9 commit a24360d

25 files changed

+356
-384
lines changed

docs/zkEVM/architecture/zkprover/arithmetic-sm.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
The **Arithmetic State Machine** is a secondary state machine that also **has an executor (the Arithmetic SM Executor)** and **an internal Arithmetic program (a set of verification rules written in the PIL language)**. The Arithmetic SM Executor is available in two languages: Javascript and C/C++.
1+
The Arithmetic State Machine is a secondary state machine that also has an executor (the Arithmetic SM Executor) and an internal Arithmetic program (a set of verification rules written in the PIL language). The Arithmetic SM Executor is available in two languages: Javascript and C/C++.
22

3-
It is **one of the six secondary state machines** receiving instructions from the Main SM Executor. The main purpose of the Arithmetic SM is to carry out elliptic curve arithmetic operations, such as Point Addition and Point Doubling as well as performing 256-bit operations like addition, product or division.
3+
It is one of the six secondary state machines receiving instructions from the Main SM Executor. The main purpose of the Arithmetic SM is to carry out elliptic curve arithmetic operations, such as Point Addition and Point Doubling as well as performing 256-bit operations like addition, product or division.
44

55
## Standard elliptic curve arithmetic
66

@@ -55,7 +55,7 @@ For instance, if $C = 0$, then $\bf{Eqn\ A}$ states that the result of multiplyi
5555

5656
Or, if $B = 1$, $\bf{Eqn\ A}$ states that the result of adding $A$ and $C$ is the same as before: $E$ with a carry of $D$. Similarly, division and modular reductions can also be expressed as derivatives of $\bf{Eqn\ A}$.
5757

58-
**These operations are performed in the Arithmetic State Machine, with registers satisfying the following PIL relation**,
58+
These operations are performed in the Arithmetic State Machine, with registers satisfying the following PIL relation,
5959

6060
$$
6161
\text{EQ}_0 \colon \quad x_1 \cdot y_1 + x_2 - y_2 \cdot 2^{256} - y_3 = 0
@@ -81,7 +81,7 @@ $$
8181

8282
where $q_0,q_1,q_2 \in \mathbb{Z}$, implying that these equations hold true over the integers.
8383

84-
This approach is taken because of the need to compute divisions by $p$. Note that **only three possible computation scenarios can arise**:
84+
This approach is taken because of the need to compute divisions by $p$. Note that only three possible computation scenarios can arise:
8585

8686
1. $\text{EQ}_0$ is activated while the rest are deactivated,
8787
2. $\text{EQ}_1$, $\text{EQ}_3$ and $\text{EQ}_4$ are activated but $\text{EQ}_0$ and $\text{EQ}_2$ are deactivated,
@@ -175,6 +175,6 @@ $$
175175

176176
The Polygon zkEVM repository is available on [GitHub](https://github.com/0xPolygonHermez).
177177

178-
**Arithmetic SM Executor**: [sm_arith folder](https://github.com/0xPolygonHermez/zkevm-proverjs/tree/main/src/sm/sm_arith)
178+
Arithmetic SM Executor: [sm_arith folder](https://github.com/0xPolygonHermez/zkevm-proverjs/tree/main/src/sm/sm_arith)
179179

180-
**Arithmetic SM PIL**: [arith.pil](https://github.com/0xPolygonHermez/zkevm-proverjs/blob/main/pil/arith.pil)
180+
Arithmetic SM PIL: [arith.pil](https://github.com/0xPolygonHermez/zkevm-proverjs/blob/main/pil/arith.pil)

docs/zkEVM/architecture/zkprover/bits2field-sm.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
The **Bits2Field State Machine** is one of the auxiliary state machines used specifically for parallelizing the implementation of KECCAK-F SM. Its source code is available [here](https://github.com/0xPolygonHermez/zkevm-prover/blob/main/src/sm/bits2field/bits2field_executor.cpp).
1+
The Bits2Field state machine is one of the auxiliary state machines used specifically for parallelizing the implementation of KECCAK-F SM. Its source code is available [here](https://github.com/0xPolygonHermez/zkevm-prover/blob/main/src/sm/bits2field/bits2field_executor.cpp).
22

3-
The Bits2Field state machine ensures correct packing of $\mathtt{44}$ bits from $\mathtt{44}$ different $\mathtt{1600}$-row blocks of the Padding-KK-Bit SM into a single field element. Therefore, **it operates like a (44 bits to 1 field element) multiplexer between the Padding-KK-Bit SM and the Keccak-F SM**.
3+
The Bits2Field state machine ensures correct packing of $\mathtt{44}$ bits from $\mathtt{44}$ different $\mathtt{1600}$-row blocks of the Padding-KK-Bit SM into a single field element. Therefore, it operates like a (44 bits to 1 field element) multiplexer between the Padding-KK-Bit SM and the Keccak-F SM.
44

5-
In simpler terms, it takes bits from $\mathtt{44}$ different blocks, places them into the first 44 bit-positions of a single field element, whereupon the KECCAK-F circuit runs. **The name Bits2Field State Machine refers to the processing where $44$ **bits** from $44$ different blocks of the Padding-KK-Bit SM are inserted into a single field element**.
5+
In simpler terms, it takes bits from $\mathtt{44}$ different blocks, places them into the first 44 bit-positions of a single field element, whereupon the KECCAK-F circuit runs. The name Bits2Field state machine refers to the processing where $44$ bits from $44$ different blocks of the Padding-KK-Bit SM are inserted into a single field element.
66

7-
Although the KECCAK-F SM is a binary circuit, instead of executing on a bit-by-bit basis, **it is implemented to execute KECCAK-F operations on a 44bits-by-44bits basis**. This is tantamount to running $\mathtt{44}$ KECCAK-F hashing circuits in parallel.
7+
Although the KECCAK-F SM is a binary circuit, instead of executing on a bit-by-bit basis, it is implemented to execute KECCAK-F operations on a 44bits-by-44bits basis. This is tantamount to running $\mathtt{44}$ KECCAK-F hashing circuits in parallel.
88

99
![The 44 bits to 1 field-element Multiplexing](../../../img/zkEVM/01b2f-44-2-one-multiplex.png)
1010

1111
## Mapping 44 Bits To A 64-bit Field Element
1212

13-
Suppose operations are carried out in a field $\mathbb{F}_p$ of $\mathtt{64}$-bit numbers. **The smallest field used in the zkProver is the Goldilocks Field $\mathbb{F}_p$ where $p = 2^{64} - 2^{32}+1$**.
13+
Suppose operations are carried out in a field $\mathbb{F}_p$ of $\mathtt{64}$-bit numbers. The smallest field used in the zkProver is the Goldilocks Field $\mathbb{F}_p$ where $p = 2^{64} - 2^{32}+1$.
1414

1515
After multiplexing, the 44 bits are loaded into the first 44 least significant bit-positions of the field element as depicted in the figure below.
1616

docs/zkEVM/architecture/zkprover/construct-key-path.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ The quadruple structure of the path bits and the level of leaves therefore have
9696

9797
Since **addition modulo n** is an expensive computation in the state machine context, it is important to find a more efficient algorithm to achieve the same result.
9898

99-
## Alternate Cyclic Group Of Order 4
99+
## Alternate cyclic group of order 4
100100

101101
In order to explore cyclic groups of order 4, take the vector $\mathbf{x} = (1,0,0,0)$ , and rotate the components of $\mathbf{x}$ one position to the left.
102102

@@ -129,7 +129,7 @@ $$
129129
\text{00} \mapsto (1,0,0,0),\ \ \text{01} \mapsto (0,1,0,0),\ \ \text{10} \mapsto (0,0,1,0)\ \text{ and }\ \text{11} \mapsto (0,0,0,1).
130130
$$
131131

132-
## Special Cyclic Register For Leaf Levels
132+
## Special cyclic register for leaf levels
133133

134134
Define a register called `LEVEL` which is vector of four bits, three **0** bits and one **1** bit. And the operation `ROTATE_LEVEL` which is the **left rotation** of `LEVEL`'s bits by one position.
135135

@@ -141,7 +141,7 @@ $$
141141

142142
Therefore, `LEVEL` is cyclic under `ROTATE_LEVEL`, and is in fact algebraically the same as the cyclic group $\mathbf{G_4}$ described above.
143143

144-
### Using `LEVEL` Register in Key Reconstruction
144+
### Using `LEVEL` register in key reconstruction
145145

146146
First note that, when navigating the tree, the leaf level can be indicated by one of the four possible states of the `LEVEL` register. And this works for all possible leaf levels because, for any positive integer $j$:
147147

docs/zkEVM/architecture/zkprover/executor-pil.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
## The Storage executor
2-
31
The Storage Executor is like a slave-worker to the master, the Storage Assembly code. It carries out all Storage Actions in accordance with rules and logic that the Assembly code has set out.
42

53
As per instruction of the Main SM, the Storage Executor makes function calls to the Storage ROM for a specific secondary Assembly code stored as a JSON-file, by using the same aforementioned **selectors** of secondary Assembly codes.
@@ -30,7 +28,7 @@ are actually performed by the Storage Executor. The values being fetched are car
3028

3129
Also, since all Storage Actions require some hashing, the Storage SM delegates all hashing actions to the POSEIDON SM. However, from within the Storage SM, it is best to treat the POSEIDON SM as a blackbox. The Storage Executor simply specifies the sets of twelve values to be digested. And the POSEIDON SM then returns the required digests of the values.
3230

33-
## The Storage PIL
31+
## Storage PIL
3432

3533
All computations executed in the Storage SM must be verifiable. A special Polynomial Identity Language (PIL) code is therefore used to set up all the polynomial constraints the verifier needs so as to validate correctness of execution.
3634

@@ -63,7 +61,7 @@ Therefore, instead of performing some expensive computations in order to verify
6361

6462
The verifier takes the execution trace, and tests if it satisfies the polynomial constraints (or identities) in the PIL code. This technique helps the zkProver to achieve succintness as a zero-knowledge proof/verification system.
6563

66-
## The Poseidon hash
64+
## Poseidon hash
6765

6866
Poseidon SM is more straightforward once one understands the internal mechanism of the original Poseidon hash function. The hash function's permutation process translates readily to the Poseidon SM states.
6967

docs/zkEVM/architecture/zkprover/intro-storage-sm.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
## Introduction
2-
31
A standard state machine is characterized by sets of states (as inputs) stored in registers, instructions on how the states should transition, and the resultant states (as outputs) stored as new values in the same registers. The below figure demonstrates a standard state machine.
42

5-
![A Generic State Machine](../../../img/zkEVM/fig1-gen-state-mchn.png)
3+
![A Generic state machine](../../../img/zkEVM/fig1-gen-state-mchn.png)
64

75
State machine can be monolithic, where it is a prototype of one particular computation, while others may specialise with certain types of computations. Depending on the computational algorithm, a state machine may have to run through a number of state transitions before producing the desired output. Iterations of the same sequence of operations may be required, to the extend that most common state machines are cyclic by nature.
86

9-
The **Storage State Machine** is one of the **secondary zkProver state machine responsible for all operations on data stored in the zkProver's storage**. It receives instructions from the Main State Machine, called **Storage Actions**. The Main State Machine performs typical database operations such as: **Create, Read, Update and Delete (CRUD)**; and then instructs the Storage State Machine to verify whether these were correctly performed.
7+
The **Storage state machine** is one of the **secondary zkProver state machine responsible for all operations on data stored in the zkProver's storage**. It receives instructions from the Main state machine, called **Storage Actions**. The Main state machine performs typical database operations such as: **Create, Read, Update and Delete (CRUD)**; and then instructs the Storage state machine to verify whether these were correctly performed.
108

119
## A microprocessor-type state machine
1210

docs/zkEVM/architecture/zkprover/keccakf-sm.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The Keccak-F State Machine is one of the secondary zkProver state machines. It computes message string hashes and validates the accuracy of those computations upon the request of Main SM.
1+
The Keccak-F state machine is one of the secondary zkProver state machines. It computes message string hashes and validates the accuracy of those computations upon the request of Main SM.
22

33
Although the architecture of the original Keccak hash function is simple, the Keccak-F SM is not just a state machine or a simple automated version of the cryptographic hash function.
44

@@ -10,7 +10,7 @@ Thirdly, the Keccak-F circuit is constructed in such a way that executing it onc
1010

1111
The Keccak-F circuit is briefly described in this article, along with a thorough explanation of the widely used Keccak-256 hash function and its specific parameters as they apply to the Polygon zkEVM implementation.
1212

13-
## Keccak-F Circuit
13+
## Keccak-F circuit
1414

1515
The Keccak-F circuit has two types of gates, types $\mathtt{0}$ and $\mathtt{1}$, corresponding to the two binary operations it performs, the $\mathtt{XOR}$ and $\mathtt{ANDP}$.
1616

@@ -49,11 +49,11 @@ for each $i \in \{ 0, 1, 2, 3 \}$.
4949

5050
This covers the Keccak-F circuit in a nutshell together with its PIL code. See the codes of [sm_keccakf.js](https://github.com/0xPolygonHermez/zkevm-proverjs/blob/main/src/sm/sm_keccakf/sm_keccakf.js) and [keccakf.pil](https://github.com/0xPolygonHermez/zkevm-proverjs/blob/main/pil/keccakf.pil) on GitHub.
5151

52-
## Keccak-256 Hash Function
52+
## Keccak-256 hash function
5353

5454
There are seven Keccak-F permutation functions, each indicated by $\texttt{Keccak}$-$f[b]$, where $b = 5\times 5\times 2^l$ is the size of the internal state of the hash function, for $0 \leq l \leq w$.
5555

56-
The zkProver's Keccak State Machine is a verifiable automisation of a Keccak-F permutation function, which amounts to an irreversible scrambling of bits of a string $\mathbf{s} \in \mathbb{Z}_2^b$, where $b = 5\times 5\times 2^6 = 1600$.
56+
The zkProver's Keccak state machine is a verifiable automisation of a Keccak-F permutation function, which amounts to an irreversible scrambling of bits of a string $\mathbf{s} \in \mathbb{Z}_2^b$, where $b = 5\times 5\times 2^6 = 1600$.
5757

5858
The EVM utilises the Keccak-256 hash function, which is a sponge construction with capacity $c = 512$ bits, and denoted by Keccak$[512]$. That is, the Keccak-256 notation puts emphasis on the $256$-bit security level, while the Keccak$[512]$ notation seeks to depict the actual capacity of $512$ bits.
5959

@@ -155,7 +155,7 @@ $$
155155

156156
## Keccak-F rounds
157157

158-
The Keccak-F State Machine runs 24 rounds, each of which is a composition of five step mappings; $\mathtt{\theta}$, $\mathtt{\rho}$, $\mathtt{\pi}$, $\mathtt{\chi}$, and $\mathtt{\iota}$, denoted by
158+
The Keccak-F state machine runs 24 rounds, each of which is a composition of five step mappings; $\mathtt{\theta}$, $\mathtt{\rho}$, $\mathtt{\pi}$, $\mathtt{\chi}$, and $\mathtt{\iota}$, denoted by
159159

160160
$$
161161
\texttt{Rnd(A, ir)} = ι( χ( π( ρ( θ(A) ) ) ), \mathtt{ir})

0 commit comments

Comments
 (0)