githubEdit

@unirep/crypto

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

arrow-up-rightGithub license arrow-up-rightNPM version arrow-up-rightDownloads arrow-up-rightLinter eslint arrow-up-rightCode style prettierarrow-up-right

๐Ÿ›  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