Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-constructing paths of leaves during verification #25

Open
s1na opened this issue Sep 10, 2019 · 1 comment
Open

Re-constructing paths of leaves during verification #25

s1na opened this issue Sep 10, 2019 · 1 comment

Comments

@s1na
Copy link
Collaborator

s1na commented Sep 10, 2019

This is more related to an EE wanting to do token transfers using this multiproof algorithm. I'm not sure if it makes sense to merge it in the repo.

EE receives an array of txes which include among other things a signature from sender and the address of the recipient. The EE also receives a multiproof. In order to make sure addresses of the sender and recipient of the tx corresponds to the leaves sent in the multiproof, the EE needs to re-construct the path to those leaves when it's verifying the multiproof. Here's my attempt at how one could do this:

  • Initialize an array of addrs with same length as leaves
  • When a leaf is read in via LEAF add its partial path to corresponding index of addrs, and add this index to the leaf node being pushed on stack
  • In BRANCH, EXTENSION or ADD:
    • if the node popped from stack is a leaf, read its index and prepend a partial path to its addrs entry. Also add its addrs index (for the leaf) to the node being pushed on stack
    • else, read list of indices for all leaves this node is pointing to and prepend their paths with the partial path (e.g. branch idx, or extkey)
  • After verification is done, all these paths need to be encoded form their nibbles form to get the addresses
@s1na
Copy link
Collaborator Author

s1na commented Sep 16, 2019

Added a prototype of this to the typescript version: ethereumjs/merkle-patricia-tree@78810c5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant