Skip to main content
Version: v3.x

Minimal Anti Collusion Infrastructure (MACI) / VoteCounts

Class: VoteCounts

Defined in: voteCounts.ts:11

A VoteCounts represents a User's vote counts in a Poll, as well as their next valid nonce.

Constructors​

Constructor​

new VoteCounts(totalVoteOptions, voteOptionTreeDepth): VoteCounts

Defined in: voteCounts.ts:23

Create a new VoteCounts instance

Parameters​

totalVoteOptions​

number

How many vote options are available in the poll

voteOptionTreeDepth​

number

The depth of the merkle tree holding the vote options

Returns​

VoteCounts

Properties​

counts​

counts: bigint[] = []

Defined in: voteCounts.ts:12


nonce​

nonce: bigint = 0n

Defined in: voteCounts.ts:14


voteOptionTreeDepth​

voteOptionTreeDepth: number

Defined in: voteCounts.ts:16

Methods​

asArray()​

asArray(): bigint[]

Defined in: voteCounts.ts:65

Convert in a an array of bigints

Returns​

bigint[]

the vote counts as a bigint array

Notice​

this is the nonce and the root of the vote option tree


asCircuitInputs()​

asCircuitInputs(): bigint[]

Defined in: voteCounts.ts:58

Convert in a format suitable for the circuit

Returns​

bigint[]

the vote counts as a BigInt array


copy()​

copy(): VoteCounts

Defined in: voteCounts.ts:82

Create a deep clone of this VoteCounts

Returns​

VoteCounts

a copy of the vote counts


equals()​

equals(voteCounts): boolean

Defined in: voteCounts.ts:96

Check if two vote counts are equal (same counts and same nonce)

Parameters​

voteCounts​

VoteCounts

The vote counts to compare with

Returns​

boolean

whether the two vote counts are equal


hash()​

hash(): bigint

Defined in: voteCounts.ts:48

Generate an hash of this vote counts

Returns​

bigint

The hash of the vote counts


toJSON()​

toJSON(): IJsonVoteCounts

Defined in: voteCounts.ts:107

Serialize to a JSON object

Returns​

IJsonVoteCounts

the JSON representation of the vote counts


fromJSON()​

static fromJSON(json): VoteCounts

Defined in: voteCounts.ts:120

Deserialize into a VoteCounts instance

Parameters​

json​

IJsonVoteCounts

the json representation

Returns​

VoteCounts

the deserialized object as a VoteCounts instance


generateBlank()​

static generateBlank(totalVoteOptions, voteOptionTreeDepth): VoteCounts

Defined in: voteCounts.ts:40

Generate a blank VoteCounts object

Parameters​

totalVoteOptions​

number

How many vote options are available

voteOptionTreeDepth​

number

How deep is the merkle tree holding the vote options

Returns​

VoteCounts

a Blank VoteCounts object