Skip to main content
Version: v2.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

new StateLeaf()

new StateLeaf(pubKey, voiceCreditBalance, timestamp): StateLeaf

Defined in: stateLeaf.ts:25

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

StateLeaf

Properties

pubKey

pubKey: PubKey

Defined in: stateLeaf.ts:13

Implementation of

IStateLeaf.pubKey


timestamp

timestamp: bigint

Defined in: stateLeaf.ts:17


voiceCreditBalance

voiceCreditBalance: bigint

Defined in: stateLeaf.ts:15

Implementation of

IStateLeaf.voiceCreditBalance

Methods

asCircuitInputs()

asCircuitInputs(): bigint[]

Defined in: stateLeaf.ts:85

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:97

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:35

Crate a deep copy of the object

Returns

StateLeaf

a copy of the state leaf


equals()

equals(s): boolean

Defined in: stateLeaf.ts:110

Check if two state leaves are equal

Parameters

s

StateLeaf

the state leaf to compare with

Returns

boolean

whether they are equal or not


hash()

hash(): bigint

Defined in: stateLeaf.ts:91

Hash this state leaf (first convert as array)

Returns

bigint

the has of the state leaf elements


serialize()

serialize(): string

Defined in: stateLeaf.ts:122

Serialize the state leaf

Returns

string

Notice

serialize the public key

Notice

convert the voice credit balance and timestamp to a hex string


toJSON()

toJSON(): IJsonStateLeaf

Defined in: stateLeaf.ts:143

Serialize to a JSON object

Returns

IJsonStateLeaf


deserialize()

static deserialize(serialized): StateLeaf

Defined in: stateLeaf.ts:133

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:156

Deserialize into a StateLeaf instance

Parameters

json

IJsonStateLeaf

the json representation

Returns

StateLeaf

the deserialized object as a StateLeaf instance


genBlankLeaf()

static genBlankLeaf(): StateLeaf

Defined in: stateLeaf.ts:47

Generate a blank state leaf

Returns

StateLeaf

a blank state leaf


genRandomLeaf()

static genRandomLeaf(): StateLeaf

Defined in: stateLeaf.ts:70

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

Returns

StateLeaf

a random state leaf