1.0.13 • Published 4 years ago

semaphore-merkle-tree v1.0.13

Weekly downloads
111
License
GPL-3.0
Repository
github
Last release
4 years ago

semaphore-merkle-tree

This package offers a Merkle tree implementation which is meant to work with the Semaphore zero-knowledge signalling system.

Installation

npm i semaphore-merkle-tree

Usage

import { storage, hashers, tree } from 'semaphore-merkle-tree'

const storage = new hashers.MemStorage()
const hasher = new storage.MimcSpongeHasher();
const prefix = 'semaphore';
const default_value = '0';
const depth = 2

const tree = new tree.MerkleTree(
    prefix,
    storage,
    hasher,
    depth,
    default_value,
)

Functions

tree.update(index, value)

Adds value to the leaf at index

tree.path(index)

Returns the Merkle path to the leaf at the specified index

tree.rollback(updates)

Rolls back the tree by the specified number of updates

Building

git clone https://github.com/weijiekoh/semaphore-merkle-tree.git && \
cd semaphore-merkle-tree && \
npm i && \
npm run build

Testing

npm run test
1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago