Skip to content

Commit aec540b

Browse files
authored
Merge pull request 0xPolygon#562 from 0xPolygon/quality-assurance-zkEVM
zkEVM - Quality Assurance 1 - fix small errors
2 parents cf7393c + 601344e commit aec540b

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

docs/zkEVM/architecture/zkprover/storage-state-machine/construct-key-path.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ $$
191191

192192
## Special cyclic register for leaf levels
193193

194-
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.
194+
Define a register called _LEVEL_ which is a 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.
195195

196196
If _LEVEL_ is initialised as $(1,0,0,0)$, observe that applying _ROTATE_LEVEL_ four times brings _LEVEL_ back to $(1,0,0,0)$. That is,
197197

docs/zkEVM/architecture/zkprover/storage-state-machine/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ A standard state machine is characterized by sets of states (as inputs) stored i
22

33
![A Generic State Machine](../../../../img/zkEVM/fig1-gen-state-mchn.png)
44

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.
5+
Some state machines can be monolithic, serving as prototypes for a specific computation, while others may specialize in performing multiple computations of the same type. 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.
66

77
The _Storage_ state machine is one of the secondary zkProver state machines 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.
88

docs/zkEVM/concepts/sparse-merkle-trees/detailed-smt.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ That is, use two different hash functions; one hash function to hash leaves, den
103103
Reconsider now, the Scenario A, given above. Recall that the Attacker provides the following;
104104

105105
- The key-value $(K_{\mathbf{fk}}, V_\mathbf{{fk}})$, where $K_{\mathbf{fk}} = 11010100$ and $V_{\mathbf{fk}} = \mathbf{L_{a}} \| \mathbf{L_{b}}$.
106-
- The root $ \mathbf{{root}_{ab..f}}$ , the number of levels to root, and the siblings $\mathbf{{S}_{\mathbf{cd}}}$ and $\mathbf{{S}_{\mathbf{ef}}}$.
106+
- The root $\mathbf{{root}_{ab..f}}$ , the number of levels to root, and the siblings $\mathbf{{S}_{\mathbf{cd}}}$ and $\mathbf{{S}_{\mathbf{ef}}}$.
107107

108108
The verifier suspecting no foul, uses $K_{\mathbf{fk}} = 11010100$ to navigate the tree until he finds $V_{\mathbf{fk}}$ stored at $\mathbf{L_{fk}} := \mathbf{{B}_{ab}}$.
109109

@@ -130,24 +130,24 @@ Whenever the verifier needs to check inclusion of the given key-value pair $(K_{
130130
Both computations involve climbing the tree from the located leaf $\mathbf{{L}_{x}}$ back to the root, $\mathbf{{root}_{a..x}}$. And the two computations are;
131131

132132
1. Checking correctness of the key $K_{\mathbf{x}}$.
133+
134+
That is, verifier takes the Remaining Key, $\text{RK}_{\mathbf{x}}$, and reconstructs the key $K_{\mathbf{x}}$ by concatenating the key bits used to navigate to $\mathbf{{L}_{x}}$ from $\mathbf{{root}_{a..x}}$, in the reverse order.
133135

134-
That is, verifier takes the Remaining Key, $\text{RK}_{\mathbf{x}}$, and reconstructs the key $K_{\mathbf{x}}$ by concatenating the key bits used to navigate to $\mathbf{{L}_{x}}$ from $\mathbf{{root}_{a..x}}$, in the reverse order.
136+
Suppose the number of levels to root is 3, and the least-significant bits used for navigation are $\text{kb}_\mathbf{2}$, $\text{kb}_\mathbf{1}$ and $\text{kb}_\mathbf{0}$.
135137

136-
Suppose the number of levels to root is 3, and the least-significant bits used for navigation are $\text{kb}_\mathbf{2}$, $\text{kb}_\mathbf{1}$ and $\text{kb}_\mathbf{0}$.
138+
In order to check key-correctness, verifier takes the remaining key $\text{RK}$ and,
137139

138-
In order to check key-correctness, verifier the remaining key $\text{RK}$ and,
140+
- Concatenates $\text{kb}_\mathbf{2}$ and gets $\text{ } \text{RK} \| \text{kb}_\mathbf{2}$,
139141

140-
- Concatenates $\text{kb}_\mathbf{2}$ and gets $\text{ } \text{RK} \| \text{kb}_\mathbf{2}$,
142+
- Concatenates $\text{kb}_\mathbf{1}$ then gets $\text{ } \text{RK} \| \text{kb}_\mathbf{2} \| \text{kb}_\mathbf{1}$,
141143

142-
- Concatenates $\text{kb}_\mathbf{1}$ then gets $\text{ } \text{RK} \| \text{kb}_\mathbf{2} \| \text{kb}_\mathbf{1}$,
144+
- Concatenates $\text{kb}_\mathbf{0}$ and gets $\text{ } \text{RK} \| \text{kb}_\mathbf{2} \| \text{kb}_\mathbf{1} \| \text{kb}_\mathbf{0}$.
143145

144-
- Concatenates $\text{kb}_\mathbf{0}$ and gets $\text{ } \text{RK} \| \text{kb}_\mathbf{2} \| \text{kb}_\mathbf{1} \| \text{kb}_\mathbf{0}$.
145-
146-
He then sets $\tilde{K}_{\mathbf{x}} := \text{RK} \| \text{kb}_\mathbf{2} \| \text{kb}_\mathbf{1} \| \text{kb}_\mathbf{0}$, and checks if $\tilde{K}_{\mathbf{x}}$ equals $K_{\mathbf{x}}$.
146+
He then sets $\tilde{K}_{\mathbf{x}} := \text{RK} \| \text{kb}_\mathbf{2} \| \text{kb}_\mathbf{1} \| \text{kb}_\mathbf{0}$, and checks if $\tilde{K}_{\mathbf{x}}$ equals $K_{\mathbf{x}}$.
147147

148148
2. The Merkle proof: That is, checking whether the value stored at the located leaf $\mathbf{{L}_{x}}$ was indeed included in computing the root, $\mathbf{{root}_{a..x}}$.
149-
150-
This computation was illustrated several times in the above discussions. Note that the key-correctness and the Merkle proof are simultaneously carried out.
149+
150+
This computation was illustrated several times in the above discussions. Note that the key-correctness and the Merkle proof are simultaneously carried out.
151151

152152
### Example: Indistinguishable leaves
153153

@@ -236,11 +236,13 @@ $$
236236
Consequently, although the key-value pairs $(K_{\mathbf{x}}, V_\mathbf{{x}})$ and $(K_{\mathbf{z}}, V_\mathbf{{z}})$ might falsely pass the key-correctness check, they do not pass the Merkle proof test. And this is because, collision-resistance also guarantees that the following series of inequalities hold true;
237237

238238
$$
239+
\begin{aligned}
239240
\mathbf{L_{x}} = \mathbf{H_{leaf}}(K_{\mathbf{x}} \| V_\mathbf{{x}}) \neq \mathbf{H_{leaf}}(K_{\mathbf{z}} \| V_\mathbf{{z}}) = \mathbf{L_{z}} \\
240241
\\
241242
\mathbf{B_{bx}} = \mathbf{H_{noleaf}}(\mathbf{S}_\mathbf{{b}} \| \mathbf{L}_{\mathbf{x}}) \neq \mathbf{H_{noleaf}}(\mathbf{S}'_\mathbf{{b}} \| \mathbf{L}_{\mathbf{z}}) = \mathbf{B_{bz}} \\
242243
\\
243244
\mathbf{B_{abx}} = \mathbf{H_{noleaf}}(\mathbf{S}_\mathbf{{a}} \| \mathbf{B_{bx}} ) \neq \mathbf{H_{noleaf}}(\mathbf{S}'_\mathbf{{a}} \| \mathbf{B_{bz}}) = \mathbf{B_{abz}}
245+
\end{aligned}
244246
$$
245247

246248
where; $\mathbf{S}_\mathbf{{b}}$ is a sibling to $\mathbf{L}_{\mathbf{x}}$ and $\mathbf{S}_\mathbf{{a}}$ is a sibling to $\mathbf{B_{bx}}$, making $\mathbf{B_{bx}}$ and $\mathbf{B_{abx}}$ branches traversed while climbing the tree from $\mathbf{L_{x}}$ to root; Similarly, $\mathbf{S}'_\mathbf{{b}}$ is a sibling to $\mathbf{L}_{\mathbf{z}}$, while $\mathbf{S}'_\mathbf{{a}}$ is a sibling to $\mathbf{B_{bx}}$, also making $\mathbf{B_{bz}}$ and $\mathbf{B_{abz}}$ branches traversed while climbing the tree from $\mathbf{L_{z}}$ to root.
@@ -300,7 +302,7 @@ The verifier, on the other hand, has to adjust the Merkle proof by starting with
300302
- Secondly, concatenating the hashed-value $\text{HV}_\mathbf{{x}}$ and the remaining key $\text{RK}_\mathbf{{x}}$,
301303
- Thirdly, hashing the concatenation in order to form the leaf, $\mathbf{L_{x}} := \mathbf{H_{leaf}}( \text{RK}_\mathbf{x} \| \text{HV}_\mathbf{{x}})$.
302304

303-
### Example: Zero-Knowledge Merkle Proof
305+
### Example. (Merkle proof on hidden values)
304306

305307
The following example illustrates a Merkle proof when the above strategy is applied.
306308

docs/zkEVM/concepts/sparse-merkle-trees/sparse-merkle-tree.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ Firstly, each leaf is nothing but the hash value $\mathbf{H}(\text{V}_{\mathbf{i
1818
Secondly, the branch nodes are computed as follows;
1919

2020
$$
21-
\mathbf{B}_{\mathbf{ab}} = \mathbf{H} \big(\mathbf{H}(\text{V}_{\mathbf{a}})\| \mathbf{H}(\text{V}_{\mathbf{b}})\big), \\
21+
\begin{aligned}
22+
&\mathbf{B}_{\mathbf{ab}} = \mathbf{H} \big(\mathbf{H}(\text{V}_{\mathbf{a}})\| \mathbf{H}(\text{V}_{\mathbf{b}})\big),\
2223
\mathbf{B}_{\mathbf{cd}} = \mathbf{H} \big(\mathbf{H}(\text{V}_{\mathbf{c}})\| \mathbf{H}(\text{V}_{\mathbf{d}})\big), \\
23-
\mathbf{B}_{\mathbf{ef}} = \mathbf{H} \big(\mathbf{H}(\text{V}_{\mathbf{e}})\| \mathbf{H}(\text{V}_{\mathbf{f}})\big),\text{ } \\
24+
&\mathbf{B}_{\mathbf{ef}} = \mathbf{H} \big(\mathbf{H}(\text{V}_{\mathbf{e}})\| \mathbf{H}(\text{V}_{\mathbf{f}})\big),\
2425
\mathbf{B}_{\mathbf{gh}} = \mathbf{H} \big(\mathbf{H}(\text{V}_{\mathbf{g}})\| \mathbf{H}(\text{V}_{\mathbf{h}})\big), \\
25-
\mathbf{B}_{\mathbf{abcd}} = \mathbf{H} \big(\mathbf{B}_{\mathbf{ab}}\| \mathbf{B}_{\mathbf{cd}}\big), \text{} \text{and} \\
26-
\mathbf{B}_{\mathbf{efgh}} = \mathbf{H} \big( \mathbf{B}_{\mathbf{ef}}\| \mathbf{B}_{\mathbf{gh}}\big). \quad \text{ } \text{ } \text{ }
26+
&\mathbf{B}_{\mathbf{abcd}} = \mathbf{H} \big(\mathbf{B}_{\mathbf{ab}}\| \mathbf{B}_{\mathbf{cd}}\big),\ \text{and}\
27+
\mathbf{B}_{\mathbf{efgh}} = \mathbf{H} \big( \mathbf{B}_{\mathbf{ef}}\| \mathbf{B}_{\mathbf{gh}}\big).
28+
\end{aligned}
2729
$$
2830

2931
Thirdly, the root is computed as $\mathbf{root}_{\mathbf{a..h}} = \mathbf{H} \big(\mathbf{B}_{\mathbf{abcd}}\| \mathbf{B}_{\mathbf{efgh}} \big)$.

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ nav:
276276
- Concepts:
277277
- Concepts: zkEVM/concepts/index.md
278278
- EVM basics: zkEVM/concepts/evm-basics.md
279-
- Sparse merkle trees:
279+
- Sparse Merkle trees:
280280
- Merkle trees: zkEVM/concepts/sparse-merkle-trees/sparse-merkle-tree.md
281281
- Constructing simple SMTs: zkEVM/concepts/sparse-merkle-trees/simple-smt.md
282282
- SMT concepts: zkEVM/concepts/sparse-merkle-trees/detailed-smt.md

0 commit comments

Comments
 (0)