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
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,19 @@
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
7
7
Consider an elliptic curve $E$ defined by $y^2 = x^3 + ax + b$ over the finite field $\mathbb{F} = \mathbb{Z}_p$, where $p$ is the prime,
Set the coefficients $a = 0$ and $b = 7$, so that $E$ reduces to
14
14
15
15
$$
16
-
y^2 = x^3 + 7.
16
+
y^2 = x^3 + 7
17
17
$$
18
18
19
19
### Point addition
@@ -55,15 +55,15 @@ 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,
Since the above Elliptic Curve operations are implemented in the PIL language, it is more convenient to express them in terms of the constraints they must satisfy. These constraints are:
66
+
Since the above elliptic curve operations are implemented in the PIL language, it is more convenient to express them in terms of the constraints they must satisfy. These constraints are:
Now, notice that the carry generated by the $\mathbf{eq}_i$'s is not important for them. That means, if $\mathbf{eq}_i = 10$, then what we really want the result to be is $0$ and save $1$ as a carry for the next operation. To express this fact as a constraint, we say that the following has to be satisfied:
158
+
Now, notice that the carry generated by the $\mathtt{eq}_i$'s is not important for them. That means, if $\mathtt{eq}_i = 10$, then what we really want the result to be is $0$ and save $1$ as a carry for the next operation. To express this fact as a constraint, we say that the following has to be satisfied:
where $\text{carry}$ represents the carry taken into account in the actual clock, and $\text{carry}'$ represents the carry generated by the actual operation.
@@ -175,6 +175,6 @@ $$
175
175
176
176
The Polygon zkEVM repository is available on [GitHub](https://github.com/0xPolygonHermez).
177
177
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)
179
179
180
180
Arithmetic SM PIL: [arith.pil](https://github.com/0xPolygonHermez/zkevm-proverjs/blob/main/pil/arith.pil)
0 commit comments