Skip to main content
Version: 2.0.0-alpha-3

Hash functions


Poseidon hash of variable number of items.

import { hash1, hash2, hash3, /* etc */ } from '@unirep/utils'

hash1(items: any[]): bigint
hash2(items: any[]): bigint
hash3(items: any[]): bigint
hash8(items: any[]): bigint


Calculate an epoch key. maxEpochKey is the maximum value for a key. The hash will be modded by this value, e.g. H(...) % maxEpochKey. For a binary tree this should be 2**depth.

import { genEpochKey } from '@unirep/utils'

identityNullifier: bigint,
attesterId: bigint,
epoch: bigint | number,
nonce: bigint | number,
maxEpochKey: bigint | number
): bigint


Calculate a user state transition nullifier. TODO: update name

import { genEpochNullifier } from '@unirep/utils'

identityNullifier: bigint,
attesterId: bigint | string,
epoch: number | bigint
): bigint


Calculate a state tree leaf for a user.

import { genStateTreeLeaf } from '@unirep/utils'

idNullifier: bigint,
attesterId: bigint | string,
epoch: bigint | number,
posRep: bigint | number,
negRep: bigint | number,
graffiti: bigint | number,
timestamp: bigint | number
): bigint