Minimal Anti Collusion Infrastructure (MACI) v2.0.0-alpha / AccQueue
Class: AccQueue
An Accumulator Queue which conforms to the implementation in AccQueue.sol. Each enqueue() operation updates a subtree, and a merge() operation combines all subtrees into a main tree.
Notice
It supports 2 or 5 elements per leaf.
Constructors
new AccQueue()
new AccQueue(
subDepth
,hashLength
,zeroValue
):AccQueue
Create a new instance of AccQueue
Parameters
• subDepth: number
the depth of the subtrees
• hashLength: number
the number of leaves per node
• zeroValue: bigint
the default value for empty leaves
Returns
Defined in
crypto/ts/AccQueue.ts:76
Properties
hashFunc()
readonly
hashFunc: (leaves
) =>bigint
Parameters
• leaves: bigint
[]
Returns
bigint
Defined in
crypto/ts/AccQueue.ts:68
subHashFunc()
readonly
subHashFunc: (leaves
) =>bigint
Parameters
• leaves: bigint
[]
Returns
bigint
Defined in
crypto/ts/AccQueue.ts:65
Methods
calcSRTdepth()
calcSRTdepth():
number
Calculate the depth of the smallest possible Merkle tree which fits all
Returns
number
the depth of the smallest possible Merkle tree which fits all
Defined in
crypto/ts/AccQueue.ts:343
copy()
copy():
AccQueue
Returns
a deep copy of this object
Notice
Deep-copies this object
Defined in
crypto/ts/AccQueue.ts:572
enqueue()
enqueue(
leaf
):number
Enqueue a leaf into the current subtree
Parameters
• leaf: bigint
The leaf to insert.
Returns
number
The index of the leaf
Defined in
crypto/ts/AccQueue.ts:185
fill()
fill():
void
Fill any empty leaves of the last subtree with zeros and store the resulting subroot.
Returns
void
Defined in
crypto/ts/AccQueue.ts:267
getHashLength()
getHashLength():
number
Get the number of inputs per hash function
Returns
number
the number of inputs
Defined in
crypto/ts/AccQueue.ts:176
getMainRoots()
getMainRoots():
bigint
[]
Get the root of merged subtrees
Returns
bigint
[]
the root of merged subtrees
Defined in
crypto/ts/AccQueue.ts:149
getRoot()
getRoot(
depth
):undefined
|null
|bigint
Get the root at a certain depth
Parameters
• depth: number
The depth of the tree
Returns
undefined
| null
| bigint
the root
Defined in
crypto/ts/AccQueue.ts:554
getSmallSRTroot()
getSmallSRTroot():
bigint
Get the small SRT root
Returns
bigint
small SRT root
Defined in
crypto/ts/AccQueue.ts:125
getSubDepth()
getSubDepth():
number
Get the subdepth
Returns
number
subdepth
Defined in
crypto/ts/AccQueue.ts:141
getSubRoot()
getSubRoot(
index
):bigint
Get the subroot at a given index
Parameters
• index: number
The index of the subroot
Returns
bigint
the subroot
Defined in
crypto/ts/AccQueue.ts:167
getSubRoots()
getSubRoots():
bigint
[]
Get the subroots
Returns
bigint
[]
subroots
Defined in
crypto/ts/AccQueue.ts:133
getZeros()
getZeros():
bigint
[]
Get the zero values per level. i.e. zeros[0] is zeroValue, zeros[1] is the hash of leavesPerNode zeros, and so on.
Returns
bigint
[]
zeros
Defined in
crypto/ts/AccQueue.ts:158
hasRoot()
hasRoot(
depth
):boolean
Check if the root at a certain depth exists (subtree root)
Parameters
• depth: number
the depth of the tree
Returns
boolean
whether the root exists
Defined in
crypto/ts/AccQueue.ts:563
hash()
hash(
leaves
):bigint
Hash an array of leaves
Parameters
• leaves: bigint
[]
The leaves to hash
Returns
bigint
the hash value of the leaves
Defined in
crypto/ts/AccQueue.ts:623
insertSubTree()
insertSubTree(
subRoot
):void
Insert a subtree into the queue. This is used when the subtree is already computed.
Parameters
• subRoot: bigint
The root of the subtree
Returns
void
Defined in
crypto/ts/AccQueue.ts:359
merge()
merge(
depth
):void
Merge all the subroots into a tree of a specified depth. It requires this.mergeSubRoots() to be run first.
Parameters
• depth: number
Returns
void
Defined in
crypto/ts/AccQueue.ts:381
mergeDirect()
mergeDirect(
depth
):void
Merge all the subroots into a tree of a specified depth. Uses an IncrementalQuinTree instead of the two-step method that AccQueue.sol uses.
Parameters
• depth: number
Returns
void
Defined in
crypto/ts/AccQueue.ts:415
mergeSubRoots()
mergeSubRoots(
numSrQueueOps
):void
Merge all subroots into the smallest possible Merkle tree which fits them. e.g. if there are 5 subroots and hashLength == 2, the tree depth is 3 since 2 ** 3 = 8 which is the next power of 2.
Parameters
• numSrQueueOps: number
= 0
The number of subroots to queue into the SRT
Returns
void
Defined in
crypto/ts/AccQueue.ts:462