Skip to content

Commit 13bd308

Browse files
committed
Restore Merkle examples and statements table
1 parent eb9dd94 commit 13bd308

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

book/src/merkletree.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ root = hash((L_root, R_root, 2)).
9494
The full `Dictionary` is then represented in the backend as `root` (four field elements in the Plonky2 backend).
9595

9696
### Example 2
97+
So for example, imagine we have 8 key-pairs, where the keys are just an enumeration from 0 to 7, then the tree leaves positions would look like:
98+
![](img/merkletree-example-1-a.png)
99+
100+
Now let's change the key of the leaf `key=1`, and set it as `key=13`. Then, their respective leaf paths will be the same until they diverge in the 4-th bit:
101+
102+
![](img/merkletree-example-1-b.png)
103+
104+
105+
### Example 3
97106

98107
Suppose we have 4 key-values, where the first four bits of the hashes of the keys are `0000`, `0100`, `1010` and `1011`. The tree would look like:
99108
![](img/merkletree-example-2-a.png)

book/src/statements.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,30 @@ On the back end, a statement is identified by a unique numerical _identifier_.
1616

1717
The POD system has several builtin statements. These statements are associated to a reserved set of statement IDs.
1818

19+
### Backend statements
20+
21+
<font color="red">TODO: update table of backend statements </font>
22+
23+
A statement is a code (or, in the frontend, string identifier) followed by 0 or more arguments. These arguments may consist of up to three anchored keys and up to one POD value.
24+
25+
The following table summarises the natively-supported statements, where we write `value_of(ak)` for 'the value anchored key `ak` maps to', which is of type `PODValue`, and `key_of(ak)` for the key part of `ak`:
26+
27+
| Code | Identifier | Args | Meaning |
28+
|------|-------------|---------------------|-------------------------------------------------------------------|
29+
| 0 | `None` | | no statement (useful for padding) |
30+
| 1 | `ValueOf` | `ak`, `value` | `value_of(ak) = value` |
31+
| 2 | `Eq` | `ak1`, `ak2` | `value_of(ak1) = value_of(ak2)` |
32+
| 3 | `NEq` | `ak1`, `ak2` | `value_of(ak1) != value_of(ak2)` |
33+
| 4 | `Gt` | `ak1`, `ak2` | `value_of(ak1) > value_of(ak2)` |
34+
| 5 | `LEq` | `ak1`, `ak2` | `value_of(ak1) <= value_of(ak2)` |
35+
| 6 | `Contains` | `ak1`, `ak2` | `(key_of(ak2), value_of(ak2)) ∈ value_of(ak1)` (Merkle inclusion) |
36+
| 7 | `Sintains` | `ak1`, `ak2` | `(key_of(ak2), value_of(ak2)) ∉ value_of(ak1)` (Merkle exclusion) |
37+
| 8 | `SumOf` | `ak1`, `ak2`, `ak3` | `value_of(ak1) = value_of(ak2) + value_of(ak3)` |
38+
| 9 | `ProductOf` | `ak1`, `ak2`, `ak3` | `value_of(ak1) = value_of(ak2) * value_of(ak3)` |
39+
| 10 | `MaxOf` | `ak1`, `ak2`, `ak3` | `value_of(ak1) = max(value_of(ak2), value_of(ak3))` |
40+
41+
### Frontend statements
42+
1943
```
2044
ValueOf(key: AnchoredKey, value: ScalarOrVec)
2145

0 commit comments

Comments
 (0)