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

Move Ordered Merkle Tree to Open Zeppelin #11

Open
hswick opened this issue Mar 22, 2018 · 3 comments
Open

Move Ordered Merkle Tree to Open Zeppelin #11

hswick opened this issue Mar 22, 2018 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@hswick
Copy link
Contributor

hswick commented Mar 22, 2018

Right now it uses a linked list approach, need a more complex data structure for better performance

@hswick
Copy link
Contributor Author

hswick commented Mar 23, 2018

@mrsmkl has these little util functions that should be used here:


   function makeMerkle(bytes arr, uint idx, uint level) internal pure returns (bytes32) {
      if (level == 0) return idx < arr.length ? bytes32(uint(arr[idx])) : bytes32(0);
      else return keccak256(makeMerkle(arr, idx, level-1), makeMerkle(arr, idx+(2**(level-1)), level-1));
   }

   function calcMerkle(bytes32[] arr, uint idx, uint level) internal returns (bytes32) {
      if (level == 0) return idx < arr.length ? arr[idx] : bytes32(0);
      else return keccak256(calcMerkle(arr, idx, level-1), calcMerkle(arr, idx+(2**(level-1)), level-1));
}

@hswick
Copy link
Contributor Author

hswick commented Mar 27, 2018

https://github.com/ameensol/merkle-tree-solidity seems like the way to go

@hswick
Copy link
Contributor Author

hswick commented Mar 28, 2018

Merged a rudimentary integration for now. I think long term it would be best to move this code to a more permanent location where Truebit is not responsible for maintaining it like say the open-zeppelin repos.

The code was taken from here and modified it a bit to work with this code for now.

Like I said above, I think its final form would be to add the Ordered Merkle Tree features to this repo (see relevant code here)

This way we can simply import the code as a dependency

@hswick hswick changed the title Use binary tree for merkleProofing Move Ordered Merkle Tree to Open Zeppelin Mar 28, 2018
@hswick hswick added the help wanted Extra attention is needed label Apr 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant