Skip to content

Commit

Permalink
fix(contracts): enforce msgType = 1 for vote messages at the contract…
Browse files Browse the repository at this point in the history
… level
  • Loading branch information
ctrlc03 committed Feb 19, 2024
1 parent 41fec3e commit c547e9c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion contracts/contracts/Poll.sol
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ contract Poll is Params, Utilities, SnarkCommon, Ownable, EmptyBallotRoots, IPol
}

/// @inheritdoc IPoll
function publishMessage(Message calldata _message, PubKey calldata _encPubKey) public virtual isWithinVotingDeadline {
function publishMessage(Message memory _message, PubKey calldata _encPubKey) public virtual isWithinVotingDeadline {

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

Check warning

Code scanning / Slither

Conformance to Solidity naming conventions Warning

// we check that we do not exceed the max number of messages
if (numMessages == maxValues.maxMessages) revert TooManyMessages();

Expand All @@ -177,6 +177,10 @@ contract Poll is Params, Utilities, SnarkCommon, Ownable, EmptyBallotRoots, IPol
numMessages++;
}

// we enforce that msgType here is 1 so we don't need checks
// at the circuit level
_message.msgType = 1;

uint256 messageLeaf = hashMessageAndEncPubKey(_message, _encPubKey);
extContracts.messageAq.enqueue(messageLeaf);

Expand Down
2 changes: 1 addition & 1 deletion contracts/contracts/interfaces/IPoll.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface IPoll {
/// @param _encPubKey An 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.
function publishMessage(DomainObjs.Message calldata _message, DomainObjs.PubKey calldata _encPubKey) external;
function publishMessage(DomainObjs.Message memory _message, DomainObjs.PubKey calldata _encPubKey) external;

/// @notice The first step of merging the MACI state AccQueue. This allows the
/// ProcessMessages circuit to access the latest state tree and ballots via
Expand Down

0 comments on commit c547e9c

Please sign in to comment.