Skip to main content
Version: v1.3_alpha

Poll

A Poll contract allows voters to submit encrypted messages which can be either votes, key change messages or topup messages.

Do not deploy this directly. Use PollFactory.deploy() which performs some checks on the Poll constructor arguments.

isInit

bool isInit

Whether the Poll has been initialized

coordinatorPubKey

struct DomainObjs.PubKey coordinatorPubKey

The coordinator's public key

coordinatorPubKeyHash

uint256 coordinatorPubKeyHash

Hash of the coordinator's public key

mergedStateRoot

uint256 mergedStateRoot

the state root of the state merkle tree

deployTime

uint256 deployTime

duration

uint256 duration

stateAqMerged

bool stateAqMerged

Whether the MACI contract's stateAq has been merged by this contract

currentSbCommitment

uint256 currentSbCommitment

Get the commitment to the state leaves and the ballots. This is hash3(stateRoot, ballotRoot, salt). Its initial value should be hash(maciStateRootSnapshot, emptyBallotRoot, 0) Each successful invocation of processMessages() should use a different salt to update this value, so that an external observer cannot tell in the case that none of the messages are valid.

numMessages

uint256 numMessages

The number of messages that have been published

numSignups

uint256 numSignups

The number of signups that have been processed before the Poll ended (stateAq merged)

actualStateTreeDepth

uint8 actualStateTreeDepth

The actual depth of the state tree to be used as public input for the circuit

maxValues

struct Params.MaxValues maxValues

Max values for the poll

treeDepths

struct Params.TreeDepths treeDepths

Depths of the merkle trees

extContracts

struct Params.ExtContracts extContracts

The contracts used by the Poll

VotingPeriodOver

error VotingPeriodOver()

VotingPeriodNotOver

error VotingPeriodNotOver()

PollAlreadyInit

error PollAlreadyInit()

TooManyMessages

error TooManyMessages()

InvalidPubKey

error InvalidPubKey()

StateAqAlreadyMerged

error StateAqAlreadyMerged()

StateAqSubtreesNeedMerge

error StateAqSubtreesNeedMerge()

InvalidBatchLength

error InvalidBatchLength()

PublishMessage

event PublishMessage(struct DomainObjs.Message _message, struct DomainObjs.PubKey _encPubKey)

TopupMessage

event TopupMessage(struct DomainObjs.Message _message)

MergeMaciStateAqSubRoots

event MergeMaciStateAqSubRoots(uint256 _numSrQueueOps)

MergeMaciStateAq

event MergeMaciStateAq(uint256 _stateRoot, uint256 _numSignups)

MergeMessageAqSubRoots

event MergeMessageAqSubRoots(uint256 _numSrQueueOps)

MergeMessageAq

event MergeMessageAq(uint256 _messageRoot)

constructor

constructor(uint256 _duration, struct Params.MaxValues _maxValues, struct Params.TreeDepths _treeDepths, struct DomainObjs.PubKey _coordinatorPubKey, struct Params.ExtContracts _extContracts) public payable

Each MACI instance can have multiple Polls. When a Poll is deployed, its voting period starts immediately.

Parameters

NameTypeDescription
_durationuint256The duration of the voting period, in seconds
_maxValuesstruct Params.MaxValuesThe maximum number of messages and vote options
_treeDepthsstruct Params.TreeDepthsThe depths of the merkle trees
_coordinatorPubKeystruct DomainObjs.PubKeyThe coordinator's public key
_extContractsstruct Params.ExtContractsThe external contracts

isAfterVotingDeadline

modifier isAfterVotingDeadline()

A modifier that causes the function to revert if the voting period is not over.

isWithinVotingDeadline

modifier isWithinVotingDeadline()

A modifier that causes the function to revert if the voting period is over

init

function init() public

The initialization function.

Should be called immediately after Poll creation and messageAq ownership transferred

topup

function topup(uint256 stateIndex, uint256 amount) public virtual

Allows to publish a Topup message

Parameters

NameTypeDescription
stateIndexuint256The index of user in the state queue
amountuint256The amount of credits to topup

publishMessage

function publishMessage(struct DomainObjs.Message _message, struct DomainObjs.PubKey _encPubKey) public virtual

Allows anyone to publish a message (an encrypted command and signature). This function also enqueues the message.

Parameters

NameTypeDescription
_messagestruct DomainObjs.MessageThe message to publish
_encPubKeystruct DomainObjs.PubKeyAn epheremal public key which can be combined with the coordinator's private key to generate an ECDH shared key with which to encrypt the message.

publishMessageBatch

function publishMessageBatch(struct DomainObjs.Message[] _messages, struct DomainObjs.PubKey[] _encPubKeys) external

submit a message batch

Can only be submitted before the voting deadline

Parameters

NameTypeDescription
_messagesstruct DomainObjs.Message[]the messages
_encPubKeysstruct DomainObjs.PubKey[]the encrypted public keys

mergeMaciStateAq

function mergeMaciStateAq() public

The second step of merging the MACI state AccQueue. This allows the ProcessMessages circuit to access the latest state tree and ballots via currentSbCommitment.

mergeMessageAqSubRoots

function mergeMessageAqSubRoots(uint256 _numSrQueueOps) public

The first step in merging the message AccQueue so that the ProcessMessages circuit can access the message root.

Parameters

NameTypeDescription
_numSrQueueOpsuint256The number of subroot queue operations to perform

mergeMessageAq

function mergeMessageAq() public

The second step in merging the message AccQueue so that the ProcessMessages circuit can access the message root.

getDeployTimeAndDuration

function getDeployTimeAndDuration() public view returns (uint256 pollDeployTime, uint256 pollDuration)

Returns the Poll's deploy time and duration

Return Values

NameTypeDescription
pollDeployTimeuint256
pollDurationuint256

numSignUpsAndMessages

function numSignUpsAndMessages() public view returns (uint256 numSUps, uint256 numMsgs)

The number of messages which have been processed and the number of signups

Return Values

NameTypeDescription
numSUpsuint256
numMsgsuint256The number of messages sent by voters