Skip to main content
Version: v3.x

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

InvalidProcessMessageProof​

error InvalidProcessMessageProof()

processingComplete​

bool processingComplete

Get the result of whether there are unprocessed messages left

Return Values​

NameTypeDescription

totalBatchesProcessed​

uint256 totalBatchesProcessed

The number of batches processed

currentBatchIndex​

uint256 currentBatchIndex

The current message batch index

sbCommitment​

uint256 sbCommitment

Get the commitment to the state and ballot roots

Return Values​

NameTypeDescription

poll​

contract IPoll poll

verifier​

contract IVerifier verifier

verifyingKeysRegistry​

contract IVerifyingKeysRegistry verifyingKeysRegistry

mode​

enum DomainObjs.Mode mode

_initialize​

function _initialize() internal

Initializes the contract.

processMessages​

function processMessages(uint256 _newSbCommitment, uint256[8] _proof) external

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

Parameters​

NameTypeDescription
_newSbCommitmentuint256The new state root and ballot root commitment after all messages are processed
_proofuint256[8]The zk-SNARK proof

getPublicCircuitInputs​

function getPublicCircuitInputs(uint256 _currentMessageBatchIndex, uint256 _newSbCommitment, uint256 _outputBatchHash) public view returns (uint256[] publicInputs)

Get public circuit inputs.

Parameters​

NameTypeDescription
_currentMessageBatchIndexuint256The current processed batch index
_newSbCommitmentuint256The new state root and ballot root commitment after all messages are processed
_outputBatchHashuint256The output batch hash

Return Values​

NameTypeDescription
publicInputsuint256[]publicInputs public circuit inputs

verifyProcessProof​

function verifyProcessProof(uint256 _currentBatchIndex, uint256 _outputBatchHash, uint256 _newSbCommitment, uint8 _messageBatchSize, uint8 _voteOptionTreeDepth, uint256[8] _proof) internal view returns (bool isValid)

Verify the proof for processMessage

used to update the sbCommitment

Parameters​

NameTypeDescription
_currentBatchIndexuint256The batch index of current message batch
_outputBatchHashuint256The output batch hash
_newSbCommitmentuint256The new sbCommitment after we update this message batch
_messageBatchSizeuint8The message batch size
_voteOptionTreeDepthuint8The vote option tree depth
_proofuint256[8]The zk-SNARK proof

Return Values​

NameTypeDescription
isValidboolWhether the proof is valid

updateMessageProcessingData​

function updateMessageProcessingData(uint256 _newSbCommitment, bool _processingComplete) internal

update message processing state variables

Parameters​

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