Skip to main content
Version: v2.0_alpha

MessageProcessor

MessageProcessor is used to process messages published by signup users. It will process message by batch due to large size of messages. After it finishes processing, the sbCommitment will be used for Tally and Subsidy contracts.

NoMoreMessages

error NoMoreMessages()

custom errors

StateNotMerged

error StateNotMerged()

MessageAqNotMerged

error MessageAqNotMerged()

InvalidProcessMessageProof

error InvalidProcessMessageProof()

MaxVoteOptionsTooLarge

error MaxVoteOptionsTooLarge()

NumSignUpsTooLarge

error NumSignUpsTooLarge()

CurrentMessageBatchIndexTooLarge

error CurrentMessageBatchIndexTooLarge()

BatchEndIndexTooLarge

error BatchEndIndexTooLarge()

CircuitPublicInputs

Circuit public inputs

struct CircuitPublicInputs {
uint256 maxVoteOptions;
uint256 numSignUps;
uint256 index;
uint256 messageBatchSize;
uint256 batchEndIndex;
uint256 coordinatorPubKeyHash;
uint256 messageRoot;
uint256 currentSbCommitment;
uint256 newSbCommitment;
uint256 pollEndTimestamp;
uint256 actualStateTreeDepth;
}

TREE_ARITY

uint256 TREE_ARITY

processingComplete

bool processingComplete

Get the result of whether there are unprocessed messages left

Return Values

NameTypeDescription

numBatchesProcessed

uint256 numBatchesProcessed

The number of batches processed

currentMessageBatchIndex

uint256 currentMessageBatchIndex

The current message batch index. When the coordinator runs processMessages(), this action relates to messages currentMessageBatchIndex to currentMessageBatchIndex + messageBatchSize.

sbCommitment

uint256 sbCommitment

Get the commitment to the state and ballot roots

Return Values

NameTypeDescription

poll

contract IPoll poll

verifier

contract IVerifier verifier

vkRegistry

contract IVkRegistry vkRegistry

mode

enum DomainObjs.Mode mode

constructor

constructor(address _verifier, address _vkRegistry, address _poll, address _mpOwner, enum DomainObjs.Mode _mode) public payable

Create a new instance

Parameters

NameTypeDescription
_verifieraddressThe Verifier contract address
_vkRegistryaddressThe VkRegistry contract address
_polladdressThe Poll contract address
_mpOwneraddressThe owner of the MessageProcessor contract
_modeenum DomainObjs.ModeVoting mode

processMessages

function processMessages(struct MessageProcessor.CircuitPublicInputs _publicCircuitInputs, uint256[8] _proof) external

Update the Poll's currentSbCommitment if the proof is valid.

Parameters

NameTypeDescription
_publicCircuitInputsstruct MessageProcessor.CircuitPublicInputsThe public circuit inputs
_proofuint256[8]The zk-SNARK proof

verifyProcessProof

function verifyProcessProof(struct MessageProcessor.CircuitPublicInputs circuitPublicInputs, uint256[8] _proof) internal view returns (bool isValid)

Verify the proof for processMessage

used to update the sbCommitment

Parameters

NameTypeDescription
circuitPublicInputsstruct MessageProcessor.CircuitPublicInputsThe circuit public inputs
_proofuint256[8]The zk-SNARK proof

Return Values

NameTypeDescription
isValidboolWhether the proof is valid

updateMessageProcessingData

function updateMessageProcessingData(uint256 _newSbCommitment, uint256 _currentMessageBatchIndex, bool _processingComplete) internal

update message processing state variables

Parameters

NameTypeDescription
_newSbCommitmentuint256sbCommitment to be updated
_currentMessageBatchIndexuint256currentMessageBatchIndex to be updated
_processingCompleteboolupdate flag that indicate processing is finished or not