Minimal Anti Collusion Infrastructure (MACI) / IncrementalQuinTree
Class: IncrementalQuinTree
Defined in: packages/crypto/ts/quinTree.ts:7
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
Defined in: packages/crypto/ts/quinTree.ts:42
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
(leaves
) => bigint
The hash function of the tree
Returns
Properties
arity
arity:
number
Defined in: packages/crypto/ts/quinTree.ts:15
capacity
capacity:
number
Defined in: packages/crypto/ts/quinTree.ts:33
depth
depth:
number
Defined in: packages/crypto/ts/quinTree.ts:9
hashFunc()
hashFunc: (
leaves
) =>bigint
Defined in: packages/crypto/ts/quinTree.ts:18
Parameters
leaves
bigint
[]
Returns
bigint
nextIndex
nextIndex:
number
=0
Defined in: packages/crypto/ts/quinTree.ts:21
nodes
nodes:
Node
Defined in: packages/crypto/ts/quinTree.ts:29
numNodes
numNodes:
number
Defined in: packages/crypto/ts/quinTree.ts:31
root
root:
bigint
Defined in: packages/crypto/ts/quinTree.ts:27
zeros
zeros:
bigint
[] =[]
Defined in: packages/crypto/ts/quinTree.ts:25
zeroValue
zeroValue:
bigint
Defined in: packages/crypto/ts/quinTree.ts:12
Methods
calcChildIndices()
calcChildIndices(
index
):number
[]
Defined in: packages/crypto/ts/quinTree.ts:272
Calculate the indices of the children of a node
Parameters
index
number
The index of the node
Returns
number
[]
The indices of the children
calcLeafIndices()
calcLeafIndices(
index
):number
[]
Defined in: packages/crypto/ts/quinTree.ts:105
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
calcParentIndices()
calcParentIndices(
index
):number
[]
Defined in: packages/crypto/ts/quinTree.ts:248
Calculate the indices of the parent
Parameters
index
number
The index of the leaf
Returns
number
[]
The indices of the parent
copy()
copy():
IncrementalQuinTree
Defined in: packages/crypto/ts/quinTree.ts:338
Copy the tree to a new instance
Returns
The new instance
genProof()
genProof(
index
):IMerkleProof
Defined in: packages/crypto/ts/quinTree.ts:122
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
genSubrootProof()
genSubrootProof(
startIndex
,endIndex
):IMerkleProof
Defined in: packages/crypto/ts/quinTree.ts:168
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
getNode()
getNode(
index
):bigint
Defined in: packages/crypto/ts/quinTree.ts:299
Get a node at a given index
Parameters
index
number
The index of the node
Returns
bigint
The node
insert()
insert(
value
):void
Defined in: packages/crypto/ts/quinTree.ts:68
Insert a leaf at the next available index
Parameters
value
bigint
The value to insert
Returns
void
setNode()
setNode(
index
,value
):void
Defined in: packages/crypto/ts/quinTree.ts:327
Set a node (not the root)
Parameters
index
number
the index of the node
value
bigint
the value of the node
Returns
void
update()
update(
index
,value
):void
Defined in: packages/crypto/ts/quinTree.ts:79
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
verifyProof()
verifyProof(
proof
):boolean
Defined in: packages/crypto/ts/quinTree.ts:221
Verify a proof
Parameters
proof
IMerkleProof
The proof to verify
Returns
boolean
Whether the proof is valid