IncrementalQuinTree
An implementation of an incremental Merkle tree
Dev
adapted from https://github.com/weijiekoh/optimisedmt
Table of contents
Constructors
Properties
Methods
- calcChildIndices
- calcInitialVals
- calcLeafIndices
- calcParentIndices
- copy
- genProof
- genSubrootProof
- getNode
- insert
- setNode
- update
- verifyProof
Constructors
constructor
• new IncrementalQuinTree(depth, zeroValue, arity, hashFunc): IncrementalQuinTree
Create a new instance of the MaciQuinTree
Parameters
| Name | Type | Description |
|---|---|---|
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[]) => bigint | The hash function of the tree |
Returns
Defined in
Properties
arity
• arity: number
Defined in
capacity
• capacity: number
Defined in
depth
• depth: number
Defined in
hashFunc
• hashFunc: (leaves: bigint[]) => bigint
Type declaration
▸ (leaves): bigint
Parameters
| Name | Type |
|---|---|
leaves | bigint[] |
Returns
bigint
Defined in
nextIndex
• nextIndex: number = 0
Defined in
nodes
• nodes: Node
Defined in
numNodes
• numNodes: number
Defined in
root
• root: bigint
Defined in
zeroValue
• zeroValue: bigint
Defined in
zeros
• zeros: bigint[] = []
Defined in
Methods
calcChildIndices
▸ calcChildIndices(index): number[]
Calculate the indices of the children of a node
Parameters
| Name | Type | Description |
|---|---|---|
index | number | The index of the node |
Returns
number[]
The indices of the children
Defined in
calcInitialVals
▸ calcInitialVals(arity, depth, zeroValue, hashFunc): Object
Calculate the zeroes and the root of a tree
Parameters
| Name | Type | Description |
|---|---|---|
arity | number | The arity of the tree |
depth | number | The depth of the tree |
zeroValue | bigint | The zero value of the tree |
hashFunc | (leaves: bigint[]) => bigint | The hash function of the tree |
Returns
Object
The zeros and the root
| Name | Type |
|---|---|
root | bigint |
zeros | bigint[] |
Defined in
calcLeafIndices
▸ calcLeafIndices(index): number[]
Calculate the indices of the leaves in the path to the root
Parameters
| Name | Type | Description |
|---|---|---|
index | number | The index of the leaf |
Returns
number[]
The indices of the leaves in the path to the root
Defined in
calcParentIndices
▸ calcParentIndices(index): number[]
Calculate the indices of the parent
Parameters
| Name | Type | Description |
|---|---|---|
index | number | The index of the leaf |
Returns
number[]
The indices of the parent
Defined in
copy
▸ copy(): IncrementalQuinTree
Copy the tree to a new instance
Returns
The new instance
Defined in
genProof
▸ genProof(index): IMerkleProof
Generate a proof for a given leaf index
Parameters
| Name | Type | Description |
|---|---|---|
index | number | The index of the leaf to generate a proof for |
Returns
IMerkleProof
The proof