Skip to content

Commit

Permalink
Merge pull request #277 from corydickson/tally-votes-circuit-initialize
Browse files Browse the repository at this point in the history
If it's the first batch ensure zero tally commitment
  • Loading branch information
corydickson authored Sep 3, 2021
2 parents 2693c23 + 9658c6c commit e61c684
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions circuits/circom/tallyVotes.circom
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand All @@ -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;
Expand Down

0 comments on commit e61c684

Please sign in to comment.