From 253277c91c8ffee33bfb4bc5abd8a0db0251df61 Mon Sep 17 00:00:00 2001 From: Paul Rodas Lema Date: Mon, 2 Sep 2024 04:13:58 -0500 Subject: [PATCH] docs: added Merkle tree use recommendations (#315) * docs: added Merkle tree use recommendations Added FAQ to guide the developers about when and why use a specific type of Merkle tree for their projects The FAQ has a short text answer plus a comparison table with more detailed data Refs: #311 * docs: merkle tree use recommendations changes format fixes Fix README format (prettier) Fix missing new lines in explanation text Add links to the homepage of the projects re 315 * docs: merkle tree use recommendations changes format fixes (correction) Fix README format (prettier) Fix missing new lines in explanation text Add links to the homepage of the projects re 315 --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 1bd15ad55..2503d9e4e 100644 --- a/README.md +++ b/README.md @@ -499,3 +499,17 @@ grep -r -l "smt" . | xargs sed -i 's/smt/my-package/' #### How can I create benchmarks for my library? You can see some examples in the `benchmarks` folder. All you have to do is create a file that exports a function to run your benchmark in that folder, and add that function to the `index.ts` file. The `yarn benchmarks` command can be run with no parameters (it will run all the benchmarks), or you can specify the name of your benchmark file to run just that. When you run the command it will create a `benchmarks/results` folder with your results. + +#### I need to use a Merkle Tree to prove the inclusion or exclusion of data elements within a set. Which type of Merkle Tree should I use? + +**Incremental:** Ideal for applications where you frequently add new elements and need to update the tree efficiently. + +**Lean Incremental:** A more memory-efficient version of the incremental Merkle tree, suitable for use cases with memory constraints. + +**Sparse:** Best suited for scenarios where you need to manage a large, mostly empty set of possible elements. + +| Type | Library Name | Main Feature | Recommended for | Not Recommended for | Used by | Proof Gen Speed | +| -------------------- | ---------------- | -------------------------------------- | ---------------------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | +| **Incremental** | @zk-kit/imt | Fastest for incremental updates | Applications requiring frequent updates | Scenarios with very large datasets | [Semaphore](https://github.com/semaphore-protocol/semaphore), [Tornado Cash](https://github.com/tornadocash/tornado-core) | Fast | +| **Lean incremental** | @zk-kit/lean-imt | Optimized for lightweight environments | Mobile and browser-based ZK applications | High-frequency update requirements | [zkSync](https://github.com/matter-labs/zksync), [Loopring](https://github.com/Loopring) | Moderate | +| **Sparse** | @zk-kit/smt | Handles very large sets efficiently | Applications with large static datasets | Frequent updates due to higher computational cost | [Aztec](https://github.com/AztecProtocol), [Zcash](https://github.com/zcash) | Slow (due to large set handling) |