🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@zk-kit/incremental-merkle-tree

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zk-kit/incremental-merkle-tree

Incremental Merkle tree implementation in TypeScript.

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
3
Created
Source

Incremental Merkle Tree

Incremental Merkle tree implementation in TypeScript.

Github license NPM version Downloads npm bundle size (scoped) Linter eslint Code style prettier

🗣️ Chat & Support   |   📘 Docs

🛠 Install

npm or yarn

Install the @zk-kit/incremental-merkle-tree package with npm:

npm i @zk-kit/incremental-merkle-tree --save

or yarn:

yarn add @zk-kit/incremental-merkle-tree

CDN

You can also load it using a script tag using unpkg:

<script src="https://unpkg.com/@zk-kit/incremental-merkle-tree/"></script>

or JSDelivr:

<script src="https://cdn.jsdelivr.net/npm/@zk-kit/incremental-merkle-tree/"></script>

📜 Usage

# new IncrementalMerkleTree(hash: HashFunction, depth: number, zero: Node, arity: number, leaves: Node[]): IncrementalMerkleTree

import { IncrementalMerkleTree } from "@zk-kit/incremental-merkle-tree"
import { poseidon } from "circomlibjs" // v0.0.8

const tree = new IncrementalMerkleTree(poseidon, 16, BigInt(0), 2) // Binary tree.

// Or, if you already have tree leaves to insert:
const leaves = [1, 2, 3]
const tree = new IncrementalMerkleTree(poseidon, 16, BigInt(0), 2, leaves)

# insert(leaf: Node)

tree.insert(BigInt(1))

# update(index: number, newLeaf: Node)

tree.update(0, BigInt(2))

# delete(index: number)

tree.delete(0)

# indexOf(leaf: Node): number

tree.insert(BigInt(2))

const index = tree.indexOf(BigInt(2))

# createProof(index: number): Proof

const proof = tree.createProof(1)

# verifyProof(proof: Proof): boolean

console.log(tree.verifyProof(proof)) // true

Contacts

Developers

FAQs

Package last updated on 15 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts