You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/zkEVM/architecture/zkprover/arithmetic-sm.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff 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++.
2
2
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.
4
4
5
5
## Standard elliptic curve arithmetic
6
6
@@ -55,7 +55,7 @@ For instance, if $C = 0$, then $\bf{Eqn\ A}$ states that the result of multiplyi
55
55
56
56
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}$.
57
57
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,
Copy file name to clipboardExpand all lines: docs/zkEVM/architecture/zkprover/bits2field-sm.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff 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).
2
2
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.
4
4
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.
6
6
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.
8
8
9
9

10
10
11
11
## Mapping 44 Bits To A 64-bit Field Element
12
12
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$.
14
14
15
15
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.
Copy file name to clipboardExpand all lines: docs/zkEVM/architecture/zkprover/construct-key-path.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,7 +96,7 @@ The quadruple structure of the path bits and the level of leaves therefore have
96
96
97
97
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.
98
98
99
-
## Alternate Cyclic Group Of Order 4
99
+
## Alternate cyclic group of order 4
100
100
101
101
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.
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.
135
135
@@ -141,7 +141,7 @@ $$
141
141
142
142
Therefore, `LEVEL` is cyclic under `ROTATE_LEVEL`, and is in fact algebraically the same as the cyclic group $\mathbf{G_4}$ described above.
143
143
144
-
### Using `LEVEL`Register in Key Reconstruction
144
+
### Using `LEVEL`register in key reconstruction
145
145
146
146
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$:
Copy file name to clipboardExpand all lines: docs/zkEVM/architecture/zkprover/executor-pil.md
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,3 @@
1
-
## The Storage executor
2
-
3
1
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.
4
2
5
3
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
30
28
31
29
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.
32
30
33
-
## The Storage PIL
31
+
## Storage PIL
34
32
35
33
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.
36
34
@@ -63,7 +61,7 @@ Therefore, instead of performing some expensive computations in order to verify
63
61
64
62
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.
65
63
66
-
## The Poseidon hash
64
+
## Poseidon hash
67
65
68
66
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.
Copy file name to clipboardExpand all lines: docs/zkEVM/architecture/zkprover/intro-storage-sm.md
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,10 @@
1
-
## Introduction
2
-
3
1
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.
4
2
5
-

3
+

6
4
7
5
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.
8
6
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.
Copy file name to clipboardExpand all lines: docs/zkEVM/architecture/zkprover/keccakf-sm.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff 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.
2
2
3
3
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.
4
4
@@ -10,7 +10,7 @@ Thirdly, the Keccak-F circuit is constructed in such a way that executing it onc
10
10
11
11
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.
12
12
13
-
## Keccak-F Circuit
13
+
## Keccak-F circuit
14
14
15
15
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}$.
16
16
@@ -49,11 +49,11 @@ for each $i \in \{ 0, 1, 2, 3 \}$.
49
49
50
50
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.
51
51
52
-
## Keccak-256 Hash Function
52
+
## Keccak-256 hash function
53
53
54
54
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$.
55
55
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$.
57
57
58
58
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.
59
59
@@ -155,7 +155,7 @@ $$
155
155
156
156
## Keccak-F rounds
157
157
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
0 commit comments