@unirep/crypto

Client library for cryptography related functions which are used in UniRep protocol.

Github license NPM version Downloads Linter eslint Code style prettier

๐Ÿ›  Install

npm or yarn

Install the @unirep/crypto package with npm:

npm i @unirep/crypto

or yarn:

yarn add @unirep/crypto

๐Ÿ“” Usage

ZkIdentity

Generate a random ZkIdentity

import { ZkIdentity } from '@unirep/crypto'
const identity = new ZkIdentity()

Generate identity commitment

const commitment = identity.genIdentityCommitment()

Get identity nullifier

const commitment = identity.identityNullifier

get identity trapdoor

Serialize/ unserialize identity

IncrementalMerkleTree

Create an IncrementalMerkleTree

Get tree root

Insert leaf

Generate merkle proof

Verify merkle proof

SparseMerkleTree

Create a SparseMerkleTree

Get tree root

Update leaf

Generate merkle proof

Verify merkle proof

Crypto utils

genRandomSalt

hash5

hashOne

hashLeftRight

stringifyBigInts/unstringifyBigInts

Last updated

Was this helpful?