@@ -334,15 +334,13 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
334334 {
335335 (uint96 courtID , , , , ) = core.disputes (_coreDisputeID);
336336 (, bool hiddenVotes , , , , ) = core.courts (courtID);
337- bytes32 actualVoteHash = hashVote (_choice, _salt, _justification);
337+ if (hiddenVotes) {
338+ _verifyHiddenVoteCommitments (localDisputeID, localRoundID, _voteIDs, _choice, _justification, _salt);
339+ }
338340
339341 // Save the votes.
340342 for (uint256 i = 0 ; i < _voteIDs.length ; i++ ) {
341343 if (round.votes[_voteIDs[i]].account != _juror) revert JurorHasToOwnTheVote ();
342- if (hiddenVotes && _getExpectedVoteHash (localDisputeID, localRoundID, _voteIDs[i]) != actualVoteHash)
343- revert HashDoesNotMatchHiddenVoteCommitment ();
344- if (! _checkJustification (localDisputeID, localRoundID, _voteIDs[i], _justification, _salt))
345- revert WrongJustification ();
346344 if (round.votes[_voteIDs[i]].voted) revert VoteAlreadyCast ();
347345 round.votes[_voteIDs[i]].choice = _choice;
348346 round.votes[_voteIDs[i]].voted = true ;
@@ -713,29 +711,26 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
713711 // * Internal * //
714712 // ************************************* //
715713
716- /// @notice Returns the expected vote hash for a given vote.
714+ /// @notice Verifies that revealed choice and justification match the hidden vote commitments .
717715 /// @param _localDisputeID The ID of the dispute in the Dispute Kit.
718716 /// @param _localRoundID The ID of the round in the Dispute Kit.
719- /// @param _voteID The ID of the vote.
720- /// @return The expected vote hash.
721- function _getExpectedVoteHash (
717+ /// @param _voteIDs The IDs of the votes.
718+ /// @param _choice The choice.
719+ /// @param _justification The justification.
720+ /// @param _salt The salt.
721+ function _verifyHiddenVoteCommitments (
722722 uint256 _localDisputeID ,
723723 uint256 _localRoundID ,
724- uint256 _voteID
725- ) internal view virtual returns (bytes32 ) {
726- return disputes[_localDisputeID].rounds[_localRoundID].votes[_voteID].commit;
727- }
728-
729- /// @notice Returns true if submitted justification matches. Only used by specific Dispute Kits (eg Shutter).
730- /// @return Whether justification matches or not.
731- function _checkJustification (
732- uint256 /*_localDisputeID*/ ,
733- uint256 /*_localRoundID*/ ,
734- uint256 /*_voteID*/ ,
735- string memory /*_justification*/ ,
736- uint256 /*_salt*/
737- ) internal view virtual returns (bool ) {
738- return true ;
724+ uint256 [] calldata _voteIDs ,
725+ uint256 _choice ,
726+ string memory _justification ,
727+ uint256 _salt
728+ ) internal view virtual {
729+ bytes32 actualVoteHash = hashVote (_choice, _salt, _justification);
730+ for (uint256 i = 0 ; i < _voteIDs.length ; i++ ) {
731+ if (disputes[_localDisputeID].rounds[_localRoundID].votes[i].commit != actualVoteHash)
732+ revert HashDoesNotMatchHiddenVoteCommitment ();
733+ }
739734 }
740735
741736 /// @notice Checks that the chosen address satisfies certain conditions for being drawn.
@@ -785,5 +780,4 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
785780 error AppealFeeIsAlreadyPaid ();
786781 error DisputeNotResolved ();
787782 error CoreIsPaused ();
788- error WrongJustification ();
789783}
0 commit comments