Minimal Anti Collusion Infrastructure (MACI) v2.0.0-alpha / IncrementalQuinTree
Class: IncrementalQuinTree
An implementation of an incremental Merkle tree
Dev
adapted from https://github.com/weijiekoh/optimisedmt
Constructors
new IncrementalQuinTree()
new IncrementalQuinTree(
depth
,zeroValue
,arity
,hashFunc
):IncrementalQuinTree
Create a new instance of the MaciQuinTree
Parameters
• depth: number
The depth of the tree
• zeroValue: bigint
The zero value of the tree
• arity: number
The arity of the tree
• hashFunc
The hash function of the tree
Returns
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
Parameters
• leaves: bigint
[]
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
• index: number
The index of the node
Returns
number
[]
The indices of the children
Defined in
crypto/ts/quinTree.ts:272
calcLeafIndices()
calcLeafIndices(
index
):number
[]
Calculate the indices of the leaves in the path to the root
Parameters
• index: number
The 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
• index: number
The 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
The new instance
Defined in
crypto/ts/quinTree.ts:338
genProof()
genProof(
index
):IMerkleProof
Generate a proof for a given leaf index
Parameters
• index: number
The 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
• startIndex: number
The index of the first leaf
• endIndex: number
The 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
• index: number
The 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
• value: bigint
The value to insert
Returns
void
Defined in
crypto/ts/quinTree.ts:68
setNode()
setNode(
index
,value
):void
Set a node (not the root)
Parameters
• index: number
the index of the node
• value: bigint
the 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
• index: number
The index of the leaf to update
• value: bigint
The value to update the leaf with
Returns
void
Defined in
crypto/ts/quinTree.ts:79
verifyProof()
verifyProof(
proof
):boolean
Verify a proof
Parameters
• proof: IMerkleProof
The proof to verify
Returns
boolean
Whether the proof is valid
Defined in
crypto/ts/quinTree.ts:221