diff --git a/circuits/circom/tallyVotes.circom b/circuits/circom/tallyVotes.circom index 645995d13a..fa72580f7c 100644 --- a/circuits/circom/tallyVotes.circom +++ b/circuits/circom/tallyVotes.circom @@ -132,12 +132,18 @@ template TallyVotes( voteTree[i].root === ballots[i][BALLOT_VO_ROOT_IDX]; } + component isFirstBatch = IsZero(); + isFirstBatch.in <== batchStartIndex; + + component iz = IsZero(); + iz.in <== isFirstBatch.out; + // ----------------------------------------------------------------------- // Tally the new results component resultCalc[numVoteOptions]; for (var i = 0; i < numVoteOptions; i ++) { resultCalc[i] = CalculateTotal(batchSize + 1); - resultCalc[i].nums[batchSize] <== currentResults[i]; + resultCalc[i].nums[batchSize] <== currentResults[i] * iz.out; for (var j = 0; j < batchSize; j ++) { resultCalc[i].nums[j] <== votes[j][i]; } @@ -163,9 +169,6 @@ template TallyVotes( } } - component isFirstBatch = IsZero(); - isFirstBatch.in <== batchStartIndex; - // Verify the current and new tally component rcv = ResultCommitmentVerifier(voteOptionTreeDepth); rcv.isFirstBatch <== isFirstBatch.out;