Skip to main content
Version: v1.3_alpha

Utilities

An utility contract that can be used to:

  • hash a state leaf
  • pad and hash a MACI message
  • hash a MACI message and an encryption public key

InvalidMessage

error InvalidMessage()

custom errors

hashStateLeaf

function hashStateLeaf(struct DomainObjs.StateLeaf _stateLeaf) public pure returns (uint256 ciphertext)

An utility function used to hash a state leaf

Parameters

NameTypeDescription
_stateLeafstruct DomainObjs.StateLeafthe state leaf to be hashed

Return Values

NameTypeDescription
ciphertextuint256The hash of the state leaf

padAndHashMessage

function padAndHashMessage(uint256[2] dataToPad, uint256 msgType) public pure returns (struct DomainObjs.Message message, struct DomainObjs.PubKey padKey, uint256 msgHash)

An utility function used to pad and hash a MACI message

Parameters

NameTypeDescription
dataToPaduint256[2]the data to be padded
msgTypeuint256the type of the message

Return Values

NameTypeDescription
messagestruct DomainObjs.MessageThe padded message
padKeystruct DomainObjs.PubKeyThe padding public key
msgHashuint256The hash of the padded message and encryption key

hashMessageAndEncPubKey

function hashMessageAndEncPubKey(struct DomainObjs.Message _message, struct DomainObjs.PubKey _encPubKey) public pure returns (uint256 msgHash)

An utility function used to hash a MACI message and an encryption public key

Parameters

NameTypeDescription
_messagestruct DomainObjs.Messagethe message to be hashed
_encPubKeystruct DomainObjs.PubKeythe encryption public key to be hashed

Return Values

NameTypeDescription
msgHashuint256The hash of the message and the encryption public key