Miha Stopar
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# MPT circuit 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: * leaf2a -> leaf2aa * leaf1b -> leaf1bb 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. ![](https://i.imgur.com/3o1dIvE.jpg) The layout is as follows: * a block has 17 rows - 16 for leaves and 1 for the position in the parent branch (this needs generalization for extension nodes) * the first column says what kind of block it is: for every second block (odd blocks, except for the first one) we need to prove that the root hash is the same as in the previous block, and also for every second block (even blocks) we need to prove the path is the same * the second column contains leaves, the 17-th row in the second column is the index of the leaf that is being changed (if even block, the other leaves need to be the same as in the previous block) * the third column contains hashes of leaves (constraint: hash of the second column = third column) * the third column also has an information (17th-row of block) where in the parent branch is hash of these columns (hash[h1a, ..., h16a]) * the fourth column contains hashes of the parent branch ([_, _, f1a, f1b, _...]), the constraint here is that hash([h1a,h2a,...,h16a]) = cols[2] (which is f1a), the position 2 is given in the 17-th row (here it might be a degree problem as we have 16 possible values for position) * the fifth column contains root hash H1; constraint: hash([_, _, f1a, f1b, _...]) = H1. * if we are deeper down in the trie, we have more columns * the problem might be that 16 values are checked when going from one column to the next one, that would mean constraint like: (pos - 1)(pos - 2) * ... * (pos - 15) * (hash = first row) + pos * (pos - 2) * ... * (pos - 15) * (hash = second row) + pos * (pos - 1) * (pos - 3) * ... * (pos - 15) * (hash = third row) + ... ![](https://i.imgur.com/ZSrhFiA.jpg) The first change (left2a -> left2aa) implies: * h2a -> h2aa * f1a -> f1aa * H1 -> H2 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. ![](https://i.imgur.com/PIJTGvt.jpg) The second change (left1b -> left1bb) implies: * h1b -> h1bb * f1b -> f1bb (picture wrongly says f2bb) * H2 -> H3 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). ![](https://i.imgur.com/rAz6yi7.jpg) 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. ## Generalization 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. ## Question & Thought 1. We somehow need to know what kind of node it is to perform correct encoding. 2. In such layout, we need a wide enough circuit to handle the deepest case, which could be 64 layer. Then in normal cases, we need to pad left (or right) to fill all cells, it seems half of cells will be wasted in average. Is it possible to only verify single layer per region (per block in your word)? 3. If state circuit has already sorted to prevent update same key twice, then in MPT circuit we don't need to do that again. In MPT circuit we only need to require all update key value pair to exist in state circuit. 4. If we are handling all MPT in this circuit, we need some kind of tag to identify different address (should be easy to add).

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

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.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully