Minimal Anti Collusion Infrastructure (MACI) v2.4.0 / StateLeaf
Class: StateLeaf
Notice
A leaf in the state tree, which maps public keys to voice credit balances
Implements
Constructors
new StateLeaf()
new StateLeaf(
pubKey
,voiceCreditBalance
,timestamp
):StateLeaf
Create a new instance of a state leaf
Parameters
• pubKey: PubKey
the public key of the user signin up
• voiceCreditBalance: bigint
the voice credit balance of the user
• timestamp: bigint
the timestamp of when the user signed-up
Returns
Defined in
stateLeaf.ts:25
Properties
pubKey
pubKey:
PubKey
Implementation of
Defined in
stateLeaf.ts:13
timestamp
timestamp:
bigint
Defined in
stateLeaf.ts:17
voiceCreditBalance
voiceCreditBalance:
bigint
Implementation of
Defined in
stateLeaf.ts:15
Methods
asCircuitInputs()
asCircuitInputs():
bigint
[]
Return this state leaf as an array of bigints
Returns
bigint
[]
the state leaf as an array of bigints
Defined in
stateLeaf.ts:85
asContractParam()
asContractParam():
IStateLeafContractParams
Return this state leaf as a contract param
Returns
the state leaf as a contract param (object)
Defined in
stateLeaf.ts:97
copy()
copy():
StateLeaf
Crate a deep copy of the object
Returns
a copy of the state leaf
Defined in
stateLeaf.ts:35
equals()
equals(
s
):boolean
Check if two state leaves are equal
Parameters
• s: StateLeaf
the state leaf to compare with
Returns
boolean
whether they are equal or not
Defined in
stateLeaf.ts:110
hash()
hash():
bigint
Hash this state leaf (first convert as array)
Returns
bigint
the has of the state leaf elements
Defined in
stateLeaf.ts:91
serialize()
serialize():
string
Serialize the state leaf
Returns
string
Notice
serialize the public key
Notice
convert the voice credit balance and timestamp to a hex string
Defined in
stateLeaf.ts:122
toJSON()
toJSON():
IJsonStateLeaf
Serialize to a JSON object
Returns
Defined in
stateLeaf.ts:143
deserialize()
static
deserialize(serialized
):StateLeaf
Deserialize the state leaf
Parameters
• serialized: string
the serialized state leaf
Returns
a deserialized state leaf
Defined in
stateLeaf.ts:133
fromJSON()
static
fromJSON(json
):StateLeaf
Deserialize into a StateLeaf instance
Parameters
• json: IJsonStateLeaf
the json representation
Returns
the deserialized object as a StateLeaf instance
Defined in
stateLeaf.ts:156
genBlankLeaf()
static
genBlankLeaf():StateLeaf
Generate a blank state leaf
Returns
a blank state leaf
Defined in
stateLeaf.ts:47
genRandomLeaf()
static
genRandomLeaf():StateLeaf
Generate a random leaf (random salt and random key pair)
Returns
a random state leaf
Defined in
stateLeaf.ts:70