{"id":17872601,"url":"https://github.com/gregors/merkle_fun","last_synced_at":"2025-03-21T19:33:00.846Z","repository":{"id":40582805,"uuid":"479529204","full_name":"gregors/merkle_fun","owner":"gregors","description":"Merkle Trees in Elixir","archived":false,"fork":false,"pushed_at":"2022-10-24T18:50:18.000Z","size":95,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-29T22:31:22.270Z","etag":null,"topics":["merkle-proof","merkle-root","merkle-tree","merkletree"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gregors.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-08T20:27:25.000Z","updated_at":"2024-05-29T22:31:22.271Z","dependencies_parsed_at":"2023-01-19T20:30:16.939Z","dependency_job_id":null,"html_url":"https://github.com/gregors/merkle_fun","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregors%2Fmerkle_fun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregors%2Fmerkle_fun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregors%2Fmerkle_fun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregors%2Fmerkle_fun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gregors","download_url":"https://codeload.github.com/gregors/merkle_fun/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221818167,"owners_count":16885697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["merkle-proof","merkle-root","merkle-tree","merkletree"],"created_at":"2024-10-28T10:43:30.932Z","updated_at":"2024-10-28T10:43:31.594Z","avatar_url":"https://github.com/gregors.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MerkleFun\n\n[Merkle tree](https://en.wikipedia.org/wiki/Merkle_tree) implementation using the excellent and fast rust-powered ex_keccak library under the hood.\nIf you'd like to know more about the basic algorithm, check out this great [introductory talk](https://youtu.be/HdGpG0kcEGU?t=132).\n\n[![CircleCI](https://circleci.com/gh/gregors/merkle_fun/tree/main.svg?style=svg)](https://circleci.com/gh/gregors/merkle_fun/tree/main)\n\n## Installation\n\nThe package can be installed\nby adding `merkle_fun` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:merkle_fun, \"~\u003e 0.6.0\"}\n  ]\nend\n```\n\n## Design\n\n### binary tree\n\nThere are multiple ways to implement a binary tree. We decided to use an [array format](https://opendsa-server.cs.vt.edu/ODSA/Books/Everything/html/CompleteTree.html) approach to minimize storage requirements and make the sibling lookup easy. If it's been a while since you've done a basic data structures course, check out this [refresher](https://www.youtube.com/watch?v=zDlTxrEwxvg).\n\nWait a minute you say! Elixir doesn't have arrays? Well there is an [Erlang implementation](https://www.erlang.org/doc/man/array.html) as well as a nice [Elixir library](https://github.com/Qqwy/elixir-arrays). However, after thinking about the problem our use case didn't need updates. We build the tree and don't need to append further nodes. In such a case a tuple suits our [read only needs](https://stackoverflow.com/questions/16447921/arrays-implementation-in-erlang/16464349#16464349) perfectly. If we decide to add Merkle Mountain Ranges (in the future) we will need something with better append performance.\n\n### leaf lookup\n\nInitial leaf lookup is currently looking through the entire tree. Yeah I need to fix that.\n\n## Warning\n\n* second pre-image attack\n* unbalanced trees attack\n\n## Todo's\n* [x] Make tree\n* [x] Make proof\n* [x] Validate proof\n* [ ] Pretty Print tree\n* [ ] Fast leaf look up\n\n\n\n## Thanks\n\nThanks goes out to Rodger Maarfi (@acrite22) for pairing with me on this.\n\nDocumentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)\nand published on [HexDocs](https://hexdocs.pm). Once published, the docs can\nbe found at \u003chttps://hexdocs.pm/merkle_fun\u003e.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregors%2Fmerkle_fun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregors%2Fmerkle_fun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregors%2Fmerkle_fun/lists"}