Let's say we have a trie which has one branch under which there are two branches. Each of these two branches has 16 leaves.
The first branch has: leaf1a, …, leaf16a.
The second branch has: leaf1b, …, leaf16b.
We make two changes:
The root hash at the beginning is H1, after first change it's H2, after second change it's H3.
The public inputs are H1 and H3. We need to prove we know the witnesses for the transition H1 -> H3.
The layout is as follows:
The first change (left2a -> left2aa) implies:
We fill the block as we did for the first one, but we have some new values: leaf2aa, h2aa, f1aa, H2. We check the propagation of hashes (we might have a chip for this). Additionally, we check whether the value in the 17-th row is the same in both blocks. 17-th row constraints will make sure we are climbing up to the root by the same path as in the previous block.
The second change (left1b -> left1bb) implies:
Now we need to prove we have another witness for H2. We fill the block with leaf1b, leaf2b, …, leaf16b.
We check the propagation of the hashes. And finally we check the root hash is the same as in the previous block (H2).
Now we need to prove we have a witness for H3 which uses the same path as the previous block.
We fill in leaf1bb, …, leaf16b. We check the propagation of hashes. We check the 17-th row is the same as in the previous block.
Finally, we compare H3 to the public input.
I think the approach above works for updating the value, inserting a new leaf to the existing branch, and deleting a leaf from the branch.
To support converting a leaf into a branch, we can add another two columns (which would be the second and third column now) which would be left empty unless a leaf is turned into branch and a leaf is added to this branch. Then we would have a leaf in the first (of these two) column and its hash in the second column.
To support extension nodes we add another row (18-th) to the block which would tell the parent type. The constraints would be a bit different and some cells would be left empty for extension nodes. One thing that would cause problems is if the trie layout changes in the middle of the path (branch <-> extension node), need to check this.
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing