zk-kit-lean-imt-custom-hash
v2.1.1
Published
Incremental Merkle tree implementations in Solidity.
Maintainers
Readme
[!NOTE]
This library has been audited as part of the Semaphore V4 PSE audit: https://semaphore.pse.dev/Semaphore_4.0.0_Audit.pdf.
The LeanIMT is an optimized binary version of the IMT into binary-focused model, eliminating the need for zero values and allowing dynamic depth adjustment. Unlike the IMT, which uses a zero hash for incomplete nodes, the LeanIMT directly adopts the left child's value when a node lacks a right counterpart. The tree's depth dynamically adjusts to the count of leaves, enhancing efficiency by reducing the number of required hash calculations. To understand more about the LeanIMT, take a look at this visual explanation.
🛠 Install
npm or yarn
Install the zk-kit-lean-imt-custom-hash package with npm:
npm i zk-kit-lean-imt-custom-hash --saveor yarn:
yarn add zk-kit-lean-imt-custom-hash📜 Usage
Please, see the test contracts for guidance on utilizing the libraries.
When using LeanIMT.sol, the poseidon contract might not be deployed yet on some networks. See the deployPoseidon in deploy-imt-test.ts function as an example to deploy it. Or the poseidon-solidity repo.
