1.1.4 • Published 1 year ago
@dcl/content-hash-tree v1.1.4
@dcl/content-hash-tree
Idea from @uniswap/merkle-distributor
Local Development
The following assumes the use of node@>=10
.
Install Dependencies
npm ci
Lib
Generate a tree
import { generateTree } from '@dcl/content-hash-tree'
const contentHashes = ['hash1', 'hash2', 'hash3']
const tree = generateTree(contentHashes)
Verify whether a contnet hash is part of the tree or not
import { verifyProof } from '@dcl/content-hash-tree'
const contentHashes = ['hash1', 'hash2', 'hash3']
const proof = tree.getProof(0, contentHashes[0])
const root = tree.getHexRoot()
const isPartOfTheTree = verifyProof(0, contentHashes[0], proof, root)
CLI (Benchmark)
Generate a tree with content hashes
npm run generate-merkle-root:data
~10k items: time to completion 788.8ms. Json size: 10mb ~100k items: time to completion 6.7s. Json size: 124mb
This will generate a proofs.json
file in the root of the project.
Verify a single proof of a tree with ~100k leafs
npm run verify-merkle-root:proof
Time to completion 9.294ms. Json size: 4kb
1.1.4
1 year ago
1.1.4-20230103185206.commit-ef01cde
1 year ago
1.1.3-20220531194205.commit-7fe6691
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.1.2-20220310184123.commit-f952147
2 years ago
1.1.2-20220125185848.commit-bce102b
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.0.1-20220123140230.commit-e38cfb1
2 years ago
1.0.1-20220115230101.commit-d450665
2 years ago
1.0.1-20220115230032.commit-6705ef1
2 years ago
1.0.1-20220115225810.commit-921dbf8
2 years ago
1.0.1-20220115225719.commit-4515b18
2 years ago
1.0.0
2 years ago
1.0.0-20220115225103.commit-db002f5
2 years ago