Skip to main content
Version: v3.x

Minimal Anti Collusion Infrastructure (MACI) / StateLeaf

Class: StateLeaf

Defined in: stateLeaf.ts:12

Notice​

A leaf in the state tree, which maps public keys to voice credit balances

Implements​

Constructors​

Constructor​

new StateLeaf(publicKey, voiceCreditBalance): StateLeaf

Defined in: stateLeaf.ts:22

Create a new instance of a state leaf

Parameters​

publicKey​

PublicKey

the public key of the user signin up

voiceCreditBalance​

bigint

the voice credit balance of the user

Returns​

StateLeaf

Properties​

publicKey​

publicKey: PublicKey

Defined in: stateLeaf.ts:13

Implementation of​

IStateLeaf.publicKey


voiceCreditBalance​

voiceCreditBalance: bigint

Defined in: stateLeaf.ts:15

Implementation of​

IStateLeaf.voiceCreditBalance

Methods​

asCircuitInputs()​

asCircuitInputs(): bigint[]

Defined in: stateLeaf.ts:76

Return this state leaf as an array of bigints

Returns​

bigint[]

the state leaf as an array of bigints


asContractParam()​

asContractParam(): IStateLeafContractParams

Defined in: stateLeaf.ts:88

Return this state leaf as a contract param

Returns​

IStateLeafContractParams

the state leaf as a contract param (object)


copy()​

copy(): StateLeaf

Defined in: stateLeaf.ts:31

Crate a deep copy of the object

Returns​

StateLeaf

a copy of the state leaf


equals()​

equals(leaf): boolean

Defined in: stateLeaf.ts:100

Check if two state leaves are equal

Parameters​

leaf​

StateLeaf

the state leaf to compare with

Returns​

boolean

whether they are equal or not


hash()​

hash(): bigint

Defined in: stateLeaf.ts:82

Hash this state leaf (first convert as array)

Returns​

bigint

the has of the state leaf elements


serialize()​

serialize(): string

Defined in: stateLeaf.ts:110

Serialize the state leaf

Returns​

string

Notice​

serialize the public key

Notice​

convert the voice credit balance to a hex string


toJSON()​

toJSON(): IJsonStateLeaf

Defined in: stateLeaf.ts:131

Serialize to a JSON object

Returns​

IJsonStateLeaf


deserialize()​

static deserialize(serialized): StateLeaf

Defined in: stateLeaf.ts:121

Deserialize the state leaf

Parameters​

serialized​

string

the serialized state leaf

Returns​

StateLeaf

a deserialized state leaf


fromJSON()​

static fromJSON(json): StateLeaf

Defined in: stateLeaf.ts:143

Deserialize into a StateLeaf instance

Parameters​

json​

IJsonStateLeaf

the json representation

Returns​

StateLeaf

the deserialized object as a StateLeaf instance


generateBlank()​

static generateBlank(): StateLeaf

Defined in: stateLeaf.ts:39

Generate a blank state leaf

Returns​

StateLeaf

a blank state leaf


generateRandom()​

static generateRandom(): StateLeaf

Defined in: stateLeaf.ts:61

Generate a random leaf (random salt and random key pair)

Returns​

StateLeaf

a random state leaf