Poll
A representation of the Poll contract.
Implements
IPoll
Table of contents
Constructors
Properties
- actualStateTreeDepth
- ballotTree
- ballots
- batchSizes
- commands
- coordinatorKeypair
- currentMessageBatchIndex
- emptyBallot
- emptyBallotHash
- encPubKeys
- maciStateRef
- maxValues
- messageTree
- messages
- numBatchesProcessed
- numBatchesTallied
- numSignups
- perVOSpentVoiceCredits
- pollEndTimestamp
- pollId
- preVOSpentVoiceCreditsRootSalts
- resultRootSalts
- sbSalts
- spentVoiceCreditSubtotalSalts
- stateCopied
- stateLeaves
- stateTree
- stateTreeDepth
- tallyResult
- totalSpentVoiceCredits
- treeDepths
Methods
- copy
- equals
- genPerVOSpentVoiceCreditsCommitment
- genProcessMessagesCircuitInputsPartial
- genSpentVoiceCreditSubtotalCommitment
- getNumSignups
- hasUnprocessedMessages
- hasUntalliedBallots
- processAllMessages
- processMessage
- processMessages
- publishMessage
- setCoordinatorKeypair
- setNumSignups
- tallyVotes
- tallyVotesNonQv
- toJSON
- topupMessage
- updatePoll
- fromJSON
Constructors
constructor
• new Poll(pollEndTimestamp
, coordinatorKeypair
, treeDepths
, batchSizes
, maxValues
, maciStateRef
): Poll
Constructs a new Poll object.
Parameters
Name | Type | Description |
---|---|---|
pollEndTimestamp | bigint | The Unix timestamp at which the poll ends. |
coordinatorKeypair | Keypair | The keypair of the coordinator. |
treeDepths | TreeDepths | The depths of the trees used in the poll. |
batchSizes | BatchSizes | The sizes of the batches used in the poll. |
maxValues | MaxValues | The maximum values the MACI circuits can accept. |
maciStateRef | MaciState | The reference to the MACI state. |
Returns
Defined in
Poll.ts:136
Properties
actualStateTreeDepth
• actualStateTreeDepth: number
Defined in
Poll.ts:70
ballotTree
• Optional
ballotTree: IncrementalQuinTree
Defined in
Poll.ts:76
ballots
• ballots: Ballot
[] = []
Defined in
Poll.ts:74
batchSizes
• batchSizes: BatchSizes
Defined in
Poll.ts:62
commands
• commands: ICommand
[] = []
Defined in
Poll.ts:82
coordinatorKeypair
• coordinatorKeypair: Keypair
Defined in
Poll.ts:58
currentMessageBatchIndex
• Optional
currentMessageBatchIndex: number
Defined in
Poll.ts:95
emptyBallot
• emptyBallot: Ballot
Defined in
Poll.ts:120
emptyBallotHash
• Optional
emptyBallotHash: bigint
Defined in
Poll.ts:122
encPubKeys
• encPubKeys: PubKey
[] = []
Defined in
Poll.ts:84
maciStateRef
• maciStateRef: MaciState
Defined in
Poll.ts:97
maxValues
• maxValues: MaxValues
Defined in
Poll.ts:64
messageTree
• messageTree: IncrementalQuinTree
Defined in
Poll.ts:80
messages
• messages: Message
[] = []
Defined in
Poll.ts:78
numBatchesProcessed
• numBatchesProcessed: number
= 0
Defined in
Poll.ts:93
numBatchesTallied
• numBatchesTallied: number
= 0
Defined in
Poll.ts:114
numSignups
• Private
numSignups: bigint
Defined in
Poll.ts:125
perVOSpentVoiceCredits
• perVOSpentVoiceCredits: bigint
[] = []
Defined in
Poll.ts:112
pollEndTimestamp
• pollEndTimestamp: bigint
Defined in
Poll.ts:72
pollId
• pollId: bigint
Defined in
Poll.ts:99
preVOSpentVoiceCreditsRootSalts
• preVOSpentVoiceCreditsRootSalts: Record
<string
| number
, bigint
> = {}
Defined in
Poll.ts:105
resultRootSalts
• resultRootSalts: Record
<string
| number
, bigint
> = {}
Defined in
Poll.ts:103
sbSalts
• sbSalts: Record
<string
| number
, bigint
> = {}
Defined in
Poll.ts:101
spentVoiceCreditSubtotalSalts
• spentVoiceCreditSubtotalSalts: Record
<string
| number
, bigint
> = {}
Defined in
Poll.ts:107
stateCopied
• stateCopied: boolean
= false
Defined in
Poll.ts:86
stateLeaves
• stateLeaves: StateLeaf
[]
Defined in
Poll.ts:88
stateTree
• Optional
stateTree: IncrementalQuinTree
Defined in
Poll.ts:90
stateTreeDepth
• stateTreeDepth: number
Defined in
Poll.ts:67
tallyResult
• tallyResult: bigint
[] = []
Defined in
Poll.ts:110
totalSpentVoiceCredits
• totalSpentVoiceCredits: bigint
Defined in
Poll.ts:116
treeDepths
• treeDepths: TreeDepths
Defined in
Poll.ts:60
Methods
copy
▸ copy(): Poll
Create a deep copy of the Poll object.
Returns
A new instance of the Poll object with the same properties.
Implementation of
IPoll.copy
Defined in
Poll.ts:1287
equals
▸ equals(p
): boolean
Check if the Poll object is equal to another Poll object.
Parameters
Name | Type | Description |
---|---|---|
p | Poll | The Poll object to compare. |
Returns
boolean
True if the two Poll objects are equal, false otherwise.
Implementation of
IPoll.equals
Defined in
Poll.ts:1361
genPerVOSpentVoiceCreditsCommitment
▸ genPerVOSpentVoiceCreditsCommitment(salt
, numBallotsToCount
, useQuadraticVoting?
): bigint
This method generates a commitment to the spent voice credits per vote option.
This is the hash of the Merkle root of the spent voice credits per vote option and a salt, computed as Poseidon([root, _salt]).
Parameters
Name | Type | Default value | Description |
---|---|---|---|
salt | bigint | undefined | The salt used in the hash function. |
numBallotsToCount | number | undefined | The number of ballots to count for the calculation. |
useQuadraticVoting | boolean | true | Whether to use quadratic voting or not. Default is true. |
Returns
bigint
Returns the hash of the Merkle root of the spent voice credits per vote option and a salt, computed as Poseidon([root, _salt]).
Defined in
Poll.ts:1261
genProcessMessagesCircuitInputsPartial
▸ genProcessMessagesCircuitInputsPartial(index
): CircuitInputs
Generates partial circuit inputs for processing a batch of messages
Parameters
Name | Type | Description |
---|---|---|
index | number | The index of the partial batch. |
Returns
stringified partial circuit inputs
Defined in
Poll.ts:785
genSpentVoiceCreditSubtotalCommitment
▸ genSpentVoiceCreditSubtotalCommitment(salt
, numBallotsToCount
, useQuadraticVoting?
): bigint
This method generates a commitment to the total spent voice credits.
This is the hash of the total spent voice credits and a salt, computed as Poseidon([totalCredits, _salt]).
Parameters
Name | Type | Default value | Description |
---|---|---|---|
salt | bigint | undefined | The salt used in the hash function. |
numBallotsToCount | number | undefined | The number of ballots to count for the calculation. |
useQuadraticVoting | boolean | true | Whether to use quadratic voting or not. Default is true. |
Returns
bigint
Returns the hash of the total spent voice credits and a salt, computed as Poseidon([totalCredits, _salt]).
Defined in
Poll.ts:1233
getNumSignups
▸ getNumSignups(): bigint
Get the number of signups
Returns
bigint
The number of signups
Defined in
Poll.ts:1486
hasUnprocessedMessages
▸ hasUnprocessedMessages(): boolean
This method checks if there are any unprocessed messages in the Poll instance.
Returns
boolean
Returns true if the number of processed batches is less than the total number of batches, false otherwise.
Implementation of
IPoll.hasUnprocessedMessages
Defined in
Poll.ts:403
hasUntalliedBallots
▸ hasUntalliedBallots(): boolean
Checks whether there are any untallied ballots.
Returns
boolean
Whether there are any untallied ballots
Implementation of
IPoll.hasUntalliedBallots
Defined in
Poll.ts:906
processAllMessages
▸ processAllMessages(): Object
Process all messages. This function does not update the ballots or state leaves; rather, it copies and then updates them. This makes it possible to test the result of multiple processMessage() invocations.
Returns
Object
The state leaves and ballots of the poll
Name | Type |
---|---|
ballots | Ballot [] |
stateLeaves | StateLeaf [] |
Implementation of
IPoll.processAllMessages
Defined in
Poll.ts:890
processMessage
▸ processMessage(message
, encPubKey
, qv?
): IProcessMessagesOutput
Process one message.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
message | Message | undefined | The message to process. |
encPubKey | PubKey | undefined | The public key associated with the encryption private key. |
qv | boolean | true | - |
Returns
IProcessMessagesOutput
A number of variables which will be used in the zk-SNARK circuit.