Skip to main content
Version: v2.0_alpha

IncrementalQuinTree

An implementation of an incremental Merkle tree

Dev

adapted from https://github.com/weijiekoh/optimisedmt

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new IncrementalQuinTree(depth, zeroValue, arity, hashFunc): IncrementalQuinTree

Create a new instance of the MaciQuinTree

Parameters

NameTypeDescription
depthnumberThe depth of the tree
zeroValuebigintThe zero value of the tree
aritynumberThe arity of the tree
hashFunc(leaves: bigint[]) => bigintThe hash function of the tree

Returns

IncrementalQuinTree

Defined in

crypto/ts/quinTree.ts:42

Properties

arity

arity: number

Defined in

crypto/ts/quinTree.ts:15


capacity

capacity: number

Defined in

crypto/ts/quinTree.ts:33


depth

depth: number

Defined in

crypto/ts/quinTree.ts:9


hashFunc

hashFunc: (leaves: bigint[]) => bigint

Type declaration

▸ (leaves): bigint

Parameters
NameType
leavesbigint[]
Returns

bigint

Defined in

crypto/ts/quinTree.ts:18


nextIndex

nextIndex: number = 0

Defined in

crypto/ts/quinTree.ts:21


nodes

nodes: Node

Defined in

crypto/ts/quinTree.ts:29


numNodes

numNodes: number

Defined in

crypto/ts/quinTree.ts:31


root

root: bigint

Defined in

crypto/ts/quinTree.ts:27


zeroValue

zeroValue: bigint

Defined in

crypto/ts/quinTree.ts:12


zeros

zeros: bigint[] = []

Defined in

crypto/ts/quinTree.ts:25

Methods

calcChildIndices

calcChildIndices(index): number[]

Calculate the indices of the children of a node

Parameters

NameTypeDescription
indexnumberThe index of the node

Returns

number[]

The indices of the children

Defined in

crypto/ts/quinTree.ts:272


calcInitialVals

calcInitialVals(arity, depth, zeroValue, hashFunc): Object

Calculate the zeroes and the root of a tree

Parameters

NameTypeDescription
aritynumberThe arity of the tree
depthnumberThe depth of the tree
zeroValuebigintThe zero value of the tree
hashFunc(leaves: bigint[]) => bigintThe hash function of the tree

Returns

Object

The zeros and the root

NameType
rootbigint
zerosbigint[]

Defined in

crypto/ts/quinTree.ts:358


calcLeafIndices

calcLeafIndices(index): number[]

Calculate the indices of the leaves in the path to the root

Parameters

NameTypeDescription
indexnumberThe index of the leaf

Returns

number[]

The indices of the leaves in the path to the root

Defined in

crypto/ts/quinTree.ts:105


calcParentIndices

calcParentIndices(index): number[]

Calculate the indices of the parent

Parameters

NameTypeDescription
indexnumberThe index of the leaf

Returns

number[]

The indices of the parent

Defined in

crypto/ts/quinTree.ts:248


copy

copy(): IncrementalQuinTree

Copy the tree to a new instance

Returns

IncrementalQuinTree

The new instance

Defined in

crypto/ts/quinTree.ts:338


genProof

genProof(index): IMerkleProof

Generate a proof for a given leaf index

Parameters

NameTypeDescription
indexnumberThe index of the leaf to generate a proof for

Returns

IMerkleProof

The proof

Defined in

crypto/ts/quinTree.ts:122


genSubrootProof

genSubrootProof(startIndex, endIndex): IMerkleProof

Generates a Merkle proof from a subroot to the root.

Parameters

NameTypeDescription
startIndexnumberThe index of the first leaf
endIndexnumberThe index of the last leaf

Returns

IMerkleProof

The Merkle proof

Defined in

crypto/ts/quinTree.ts:168


getNode

getNode(index): bigint

Get a node at a given index

Parameters

NameTypeDescription
indexnumberThe index of the node

Returns

bigint

The node

Defined in

crypto/ts/quinTree.ts:299


insert

insert(value): void

Insert a leaf at the next available index

Parameters

NameTypeDescription
valuebigintThe value to insert

Returns

void

Defined in

crypto/ts/quinTree.ts:68


setNode

setNode(index, value): void

Set a node (not the root)

Parameters

NameTypeDescription
indexnumberthe index of the node
valuebigintthe value of the node

Returns

void

Defined in

crypto/ts/quinTree.ts:327


update

update(index, value): void

Update a leaf at a given index

Parameters

NameTypeDescription
indexnumberThe index of the leaf to update
valuebigintThe value to update the leaf with

Returns

void

Defined in

crypto/ts/quinTree.ts:79


verifyProof

verifyProof(proof): boolean

Verify a proof

Parameters

NameTypeDescription
proofIMerkleProofThe proof to verify

Returns

boolean

Whether the proof is valid

Defined in

crypto/ts/quinTree.ts:221