Skip to main content
Version: v3.x

IPoll

Poll interface

joinPoll

function joinPoll(uint256 _nullifier, struct DomainObjs.PubKey _pubKey, uint256 _stateRootIndex, uint256[8] _proof, bytes _signUpPolicyData, bytes _initialVoiceCreditProxyData) external

Join the poll for voting

Parameters

NameTypeDescription
_nullifieruint256Hashed user's private key to check whether user has already voted
_pubKeystruct DomainObjs.PubKeyPoll user's public key
_stateRootIndexuint256Index of the MACI's stateRootOnSignUp for which the inclusion proof is generated
_proofuint256[8]The zk-SNARK proof
_signUpPolicyDatabytesData to pass to the signup policy
_initialVoiceCreditProxyDatabytesData to pass to the InitialVoiceCreditProxy

numSignUpsAndMessages

function numSignUpsAndMessages() external view returns (uint256 numSignups, uint256 numMsgs)

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

Return Values

NameTypeDescription
numSignupsuint256The number of signups
numMsgsuint256The number of messages sent by voters

getBatchHashes

function getBatchHashes() external view returns (uint256[])

Get all message batch hashes

Return Values

NameTypeDescription
[0]uint256[]betchHashes array containing all batch hashes

padLastBatch

function padLastBatch() external

Pad last unclosed batch

publishMessage

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

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 ephemeral 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

relayMessagesBatch

function relayMessagesBatch(uint256[] _messageHashes, bytes32 _ipfsHash) external

Allows relayer to publish messages using IPFS.

Parameters

NameTypeDescription
_messageHashesuint256[]The message hashes
_ipfsHashbytes32The IPFS hash of the messages batch

mergeState

function mergeState() external

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

getStartAndEndDate

function getStartAndEndDate() external view returns (uint256 _startDate, uint256 _endDate)

Returns the Poll's start and end dates

Return Values

NameTypeDescription
_startDateuint256The start date of the poll
_endDateuint256The end date of the poll

endDate

function endDate() external view returns (uint256)

Returns the Poll's end date

Return Values

NameTypeDescription
[0]uint256_endDate The end date of the poll

startDate

function startDate() external view returns (uint256)

Returns the Poll's start date

Return Values

NameTypeDescription
[0]uint256_startDate The start date of the poll

stateMerged

function stateMerged() external view returns (bool)

Get the result of whether the MACI contract's stateAq has been merged by this contract

Return Values

NameTypeDescription
[0]boolWhether the MACI contract's stateAq has been merged by this contract

treeDepths

function treeDepths() external view returns (uint8 intStateTreeDepth, uint8 voteOptionTreeDepth)

Get the depths of the merkle trees

Return Values

NameTypeDescription
intStateTreeDepthuint8The depth of the state tree
voteOptionTreeDepthuint8The subdepth of the vote option tree

voteOptions

function voteOptions() external view returns (uint256)

Get the number of vote options for the poll

Return Values

NameTypeDescription
[0]uint256voteOptions The number of vote options

messageBatchSize

function messageBatchSize() external view returns (uint8)

Get message batch size for the poll

Return Values

NameTypeDescription
[0]uint8The message batch size

coordinatorPubKeyHash

function coordinatorPubKeyHash() external view returns (uint256 _coordinatorPubKeyHash)

Get the hash of coordinator's public key

Return Values

NameTypeDescription
_coordinatorPubKeyHashuint256the hash of coordinator's public key

currentSbCommitment

function currentSbCommitment() external view returns (uint256)

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.

Return Values

NameTypeDescription
[0]uint256The commitment to the state leaves and the ballots

actualStateTreeDepth

function actualStateTreeDepth() external view returns (uint8)

Get the dynamic depth of the state tree at the time of poll finalization (based on the number of leaves inserted)

getMaciContract

function getMaciContract() external view returns (contract IMACI maci)

Get the external contracts

Return Values

NameTypeDescription
macicontract IMACIThe IMACI contract

getStateIndex

function getStateIndex(uint256 element) external view returns (uint40)

Get the index of a state leaf in the state tree

Parameters

NameTypeDescription
elementuint256The hash of thestate leaf

Return Values

NameTypeDescription
[0]uint40index The index of the state leaf in the state tree