Skip to content

Commit 35ae461

Browse files
authored
Merge pull request #2863 from privacy-ethereum/fix/isolated/maci-15-unused-variables
fix(circuits & contracts): maci #15 remove unused variables
2 parents 8f92ea7 + 1109a89 commit 35ae461

5 files changed

Lines changed: 29 additions & 58 deletions

File tree

packages/circuits/circom/coordinator/full/MessageProcessor.circom

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ include "./SingleMessageProcessor.circom";
3333
var PACKED_COMMAND_LENGTH = 4;
3434
var STATE_LEAF_LENGTH = 3;
3535
var BALLOT_LENGTH = 2;
36-
var BALLOT_NONCE_INDEX = 0;
37-
var BALLOT_VOTE_OPTION_ROOT_INDEX = 1;
38-
var STATE_LEAF_PUBLIC_X_INDEX = 0;
39-
var STATE_LEAF_PUBLIC_Y_INDEX = 1;
40-
var STATE_LEAF_VOICE_CREDIT_BALANCE_INDEX = 2;
41-
var MESSAGE_TREE_ZERO_VALUE = 8370432830353022751713833565135785980866757267633941821328460903436894336785;
42-
// Number of options for this poll.
43-
var maxVoteOptions = VOTE_OPTION_TREE_ARITY ** voteOptionTreeDepth;
4436

4537
// Number of users that have completed the sign up.
4638
signal input totalSignups;
@@ -57,7 +49,7 @@ include "./SingleMessageProcessor.circom";
5749
// The current state root (before the processing).
5850
signal input currentStateRoot;
5951
// The actual tree depth (might be <= stateTreeDepth).
60-
// @note it is a public input to ensure fair processing from
52+
// @note it is a public input to ensure fair processing from
6153
// the coordinator (no censoring)
6254
signal input actualStateTreeDepth;
6355
// The coordinator public key hash
@@ -97,7 +89,7 @@ include "./SingleMessageProcessor.circom";
9789

9890
// The index of the first message in the batch, inclusive.
9991
signal input index;
100-
92+
10193
// The index of the last message in the batch to process, exclusive.
10294
// This value may be less than index + batchSize if this batch is
10395
// the last batch and the total number of messages is not a multiple of the batch size.
@@ -112,7 +104,7 @@ include "./SingleMessageProcessor.circom";
112104
var computedCurrentSbCommitment = PoseidonHasher(3)([currentStateRoot, currentBallotRoot, currentSbSalt]);
113105
computedCurrentSbCommitment === currentSbCommitment;
114106

115-
// -----------------------------------------------------------------------
107+
// -----------------------------------------------------------------------
116108
// 0. Ensure that the maximum vote options signal is valid and if
117109
// the maximum users signal is valid
118110
var voteOptionsValid = LessEqThan(32)([voteOptions, VOTE_OPTION_TREE_ARITY ** voteOptionTreeDepth]);
@@ -162,7 +154,7 @@ include "./SingleMessageProcessor.circom";
162154

163155
// Decrypt each Message into a Command.
164156
// The command i-th is composed by the following fields.
165-
// e.g., command 0 is made of commandsStateIndex[0],
157+
// e.g., command 0 is made of commandsStateIndex[0],
166158
// commandsNewPublicKey[0], ..., commandsPackedCommandOut[0]
167159
var computedCommandsStateIndex[batchSize];
168160
var computedCommandsNewPublicKey[batchSize][2];
@@ -205,7 +197,7 @@ include "./SingleMessageProcessor.circom";
205197
var computedCurrentStateLeavesPathElements[stateTreeDepth][STATE_TREE_ARITY - 1];
206198
var computedCurrentBallotPathElements[stateTreeDepth][STATE_TREE_ARITY - 1];
207199
var computedCurrentVoteWeightsPathElements[voteOptionTreeDepth][VOTE_OPTION_TREE_ARITY - 1];
208-
200+
209201
for (var j = 0; j < stateTreeDepth; j++) {
210202
for (var k = 0; k < STATE_TREE_ARITY - 1; k++) {
211203
computedCurrentStateLeavesPathElements[j][k] = currentStateLeavesPathElements[i][j][k];

packages/circuits/circom/coordinator/non-qv/MessageProcessor.circom

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ include "./SingleMessageProcessor.circom";
3333
var PACKED_COMMAND_LENGTH = 4;
3434
var STATE_LEAF_LENGTH = 3;
3535
var BALLOT_LENGTH = 2;
36-
var BALLOT_NONCE_INDEX = 0;
37-
var BALLOT_VOTE_OPTION_ROOT_INDEX = 1;
38-
var STATE_LEAF_PUBLIC_X_INDEX = 0;
39-
var STATE_LEAF_PUBLIC_Y_INDEX = 1;
40-
var STATE_LEAF_VOICE_CREDIT_BALANCE_INDEX = 2;
41-
var MESSAGE_TREE_ZERO_VALUE = 8370432830353022751713833565135785980866757267633941821328460903436894336785;
42-
// Number of options for this poll.
43-
var maxVoteOptions = VOTE_OPTION_TREE_ARITY ** voteOptionTreeDepth;
4436

4537
// Number of users that have completed the sign up.
4638
signal input totalSignups;
@@ -57,7 +49,7 @@ include "./SingleMessageProcessor.circom";
5749
// The current state root (before the processing).
5850
signal input currentStateRoot;
5951
// The actual tree depth (might be <= stateTreeDepth).
60-
// @note it is a public input to ensure fair processing from
52+
// @note it is a public input to ensure fair processing from
6153
// the coordinator (no censoring)
6254
signal input actualStateTreeDepth;
6355
// The coordinator public key hash
@@ -97,7 +89,7 @@ include "./SingleMessageProcessor.circom";
9789

9890
// The index of the first message in the batch, inclusive.
9991
signal input index;
100-
92+
10193
// The index of the last message in the batch to process, exclusive.
10294
// This value may be less than index + batchSize if this batch is
10395
// the last batch and the total number of messages is not a multiple of the batch size.
@@ -112,7 +104,7 @@ include "./SingleMessageProcessor.circom";
112104
var computedCurrentSbCommitment = PoseidonHasher(3)([currentStateRoot, currentBallotRoot, currentSbSalt]);
113105
computedCurrentSbCommitment === currentSbCommitment;
114106

115-
// -----------------------------------------------------------------------
107+
// -----------------------------------------------------------------------
116108
// 0. Ensure that the maximum vote options signal is valid and if
117109
// the maximum users signal is valid
118110
var voteOptionsValid = LessEqThan(32)([voteOptions, VOTE_OPTION_TREE_ARITY ** voteOptionTreeDepth]);
@@ -162,7 +154,7 @@ include "./SingleMessageProcessor.circom";
162154

163155
// Decrypt each Message into a Command.
164156
// The command i-th is composed by the following fields.
165-
// e.g., command 0 is made of commandsStateIndex[0],
157+
// e.g., command 0 is made of commandsStateIndex[0],
166158
// commandsNewPublicKey[0], ..., commandsPackedCommandOut[0]
167159
var computedCommandsStateIndex[batchSize];
168160
var computedCommandsNewPublicKey[batchSize][2];
@@ -205,7 +197,7 @@ include "./SingleMessageProcessor.circom";
205197
var computedCurrentStateLeavesPathElements[stateTreeDepth][STATE_TREE_ARITY - 1];
206198
var computedCurrentBallotPathElements[stateTreeDepth][STATE_TREE_ARITY - 1];
207199
var computedCurrentVoteWeightsPathElements[voteOptionTreeDepth][VOTE_OPTION_TREE_ARITY - 1];
208-
200+
209201
for (var j = 0; j < stateTreeDepth; j++) {
210202
for (var k = 0; k < STATE_TREE_ARITY - 1; k++) {
211203
computedCurrentStateLeavesPathElements[j][k] = currentStateLeavesPathElements[i][j][k];

packages/circuits/circom/coordinator/non-qv/SingleMessageProcessor.circom

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@ include "../../utils/non-qv/StateLeafAndBallotTransformer.circom";
1212

1313

1414
/**
15-
* Processes one message and updates the state accordingly.
16-
* This template involves complex interactions, including transformations based on message type,
17-
* validations against current states like voice credit balances or vote weights,
18-
* and updates to Merkle trees representing state and ballot information.
15+
* Processes one message and updates the state accordingly.
16+
* This template involves complex interactions, including transformations based on message type,
17+
* validations against current states like voice credit balances or vote weights,
18+
* and updates to Merkle trees representing state and ballot information.
1919
* This is a critical building block for ensuring the integrity and correctness of MACI state.
2020
* This template does not support Quadratic Voting (QV).
2121
*/
2222
template SingleMessageProcessorNonQv(stateTreeDepth, voteOptionTreeDepth) {
2323
// Constants defining the structure and size of state and ballots.
2424
var STATE_LEAF_LENGTH = 3;
2525
var BALLOT_LENGTH = 2;
26-
var MESSAGE_LENGTH = 10;
2726
var PACKED_COMMAND_LENGTH = 4;
2827
var VOTE_OPTION_TREE_ARITY = 5;
2928
var STATE_TREE_ARITY = 2;
@@ -37,7 +36,6 @@ template SingleMessageProcessorNonQv(stateTreeDepth, voteOptionTreeDepth) {
3736
var STATE_LEAF_PUBLIC_Y_INDEX = 1;
3837
// Voice Credit balance.
3938
var STATE_LEAF_VOICE_CREDIT_BALANCE_INDEX = 2;
40-
var NUMBER_BITS = 252;
4139

4240
// Number of users that have completed the sign up.
4341
signal input totalSignups;
@@ -121,7 +119,7 @@ template SingleMessageProcessorNonQv(stateTreeDepth, voteOptionTreeDepth) {
121119

122120
// 4. Verify that the original ballot exists in the given ballot root.
123121
var computedBallot = PoseidonHasher(2)([
124-
ballot[BALLOT_NONCE_INDEX],
122+
ballot[BALLOT_NONCE_INDEX],
125123
ballot[BALLOT_VOTE_OPTION_ROOT_INDEX]
126124
]);
127125
var computedStateLeafPathIndices[stateTreeDepth] = Num2Bits(stateTreeDepth)(stateIndexMux);
@@ -186,8 +184,8 @@ template SingleMessageProcessorNonQv(stateTreeDepth, voteOptionTreeDepth) {
186184
);
187185

188186
newStateRoot <== computedNewStateLeafQip;
189-
190-
// 7. Generate a new ballot root.
187+
188+
// 7. Generate a new ballot root.
191189
var computedNewBallot = PoseidonHasher(2)([computedNewBallotNonce, newBallotVoteOptionRoot]);
192190
var computedNewBallotQip = MerkleTreeInclusionProof(stateTreeDepth)(
193191
computedNewBallot,

packages/circuits/circom/coordinator/qv/MessageProcessor.circom

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ template MessageProcessorQv(
3434
var PACKED_COMMAND_LENGTH = 4;
3535
var STATE_LEAF_LENGTH = 3;
3636
var BALLOT_LENGTH = 2;
37-
var BALLOT_NONCE_INDEX = 0;
38-
var BALLOT_VOTE_OPTION_ROOT_INDEX = 1;
39-
var STATE_LEAF_PUBLIC_X_INDEX = 0;
40-
var STATE_LEAF_PUBLIC_Y_INDEX = 1;
41-
var STATE_LEAF_VOICE_CREDIT_BALANCE_INDEX = 2;
42-
var MESSAGE_TREE_ZERO_VALUE = 8370432830353022751713833565135785980866757267633941821328460903436894336785;
43-
// Number of options for this poll.
44-
var maxVoteOptions = VOTE_OPTION_TREE_ARITY ** voteOptionTreeDepth;
4537

4638
// Number of users that have completed the sign up.
4739
signal input totalSignups;
@@ -58,7 +50,7 @@ template MessageProcessorQv(
5850
// The current state root (before the processing).
5951
signal input currentStateRoot;
6052
// The actual tree depth (might be <= stateTreeDepth).
61-
// @note it is a public input to ensure fair processing from
53+
// @note it is a public input to ensure fair processing from
6254
// the coordinator (no censoring)
6355
signal input actualStateTreeDepth;
6456
// The coordinator public key hash
@@ -98,7 +90,7 @@ template MessageProcessorQv(
9890

9991
// The index of the first message in the batch, inclusive.
10092
signal input index;
101-
93+
10294
// The index of the last message in the batch to process, exclusive.
10395
// This value may be less than batchSize if this batch is
10496
// the last batch and the total number of messages is not a multiple of the batch size.
@@ -160,7 +152,7 @@ template MessageProcessorQv(
160152

161153
// Decrypt each Message into a Command.
162154
// The command i-th is composed by the following fields.
163-
// e.g., command 0 is made of commandsStateIndex[0],
155+
// e.g., command 0 is made of commandsStateIndex[0],
164156
// commandsNewPublicKey[0], ..., commandsPackedCommandOut[0]
165157
var computedCommandsStateIndex[batchSize];
166158
var computedCommandsNewPublicKey[batchSize][2];
@@ -203,7 +195,7 @@ template MessageProcessorQv(
203195
var computedCurrentStateLeavesPathElements[stateTreeDepth][STATE_TREE_ARITY - 1];
204196
var computedCurrentBallotPathElements[stateTreeDepth][STATE_TREE_ARITY - 1];
205197
var computedCurrentVoteWeightsPathElements[voteOptionTreeDepth][VOTE_OPTION_TREE_ARITY - 1];
206-
198+
207199
for (var j = 0; j < stateTreeDepth; j++) {
208200
for (var k = 0; k < STATE_TREE_ARITY - 1; k++) {
209201
computedCurrentStateLeavesPathElements[j][k] = currentStateLeavesPathElements[i][j][k];
@@ -216,7 +208,7 @@ template MessageProcessorQv(
216208
computedCurrentVoteWeightsPathElements[j][k] = currentVoteWeightsPathElements[i][j][k];
217209
}
218210
}
219-
211+
220212
(computedNewVoteStateRoot[i], computedNewVoteBallotRoot[i]) = SingleMessageProcessorQv(stateTreeDepth, voteOptionTreeDepth)(
221213
totalSignups,
222214
stateRoots[i + 1],

packages/circuits/circom/coordinator/qv/SingleMessageProcessor.circom

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,17 @@ include "../../utils/trees/QuinaryGeneratePathIndices.circom";
1111
include "../../utils/qv/StateLeafAndBallotTransformer.circom";
1212

1313
/**
14-
* Processes one message and updates the state accordingly.
15-
* This template involves complex interactions, including transformations based on message type,
16-
* validations against current states like voice credit balances or vote weights,
17-
* and updates to Merkle trees representing state and ballot information.
14+
* Processes one message and updates the state accordingly.
15+
* This template involves complex interactions, including transformations based on message type,
16+
* validations against current states like voice credit balances or vote weights,
17+
* and updates to Merkle trees representing state and ballot information.
1818
* This is a critical building block for ensuring the integrity and correctness of MACI state.
1919
* This template supports the Quadratic Voting (QV).
2020
*/
2121
template SingleMessageProcessorQv(stateTreeDepth, voteOptionTreeDepth) {
2222
// Constants defining the structure and size of state and ballots.
2323
var STATE_LEAF_LENGTH = 3;
2424
var BALLOT_LENGTH = 2;
25-
var MESSAGE_LENGTH = 10;
2625
var PACKED_COMMAND_LENGTH = 4;
2726
var VOTE_OPTION_TREE_ARITY = 5;
2827
var STATE_TREE_ARITY = 2;
@@ -36,7 +35,6 @@ template SingleMessageProcessorQv(stateTreeDepth, voteOptionTreeDepth) {
3635
var STATE_LEAF_PUBLIC_Y_INDEX = 1;
3736
// Voice Credit balance.
3837
var STATE_LEAF_VOICE_CREDIT_BALANCE_INDEX = 2;
39-
var NUMBER_BITS = 252;
4038

4139
// Number of users that have completed the sign up.
4240
signal input totalSignups;
@@ -125,7 +123,7 @@ template SingleMessageProcessorQv(stateTreeDepth, voteOptionTreeDepth) {
125123

126124
// 4. Verify that the original ballot exists in the given ballot root.
127125
var computedBallot = PoseidonHasher(2)([
128-
ballot[BALLOT_NONCE_INDEX],
126+
ballot[BALLOT_NONCE_INDEX],
129127
ballot[BALLOT_VOTE_OPTION_ROOT_INDEX]
130128
]);
131129
var computedStateLeafPathIndices[stateTreeDepth] = Num2Bits(stateTreeDepth)(stateIndexMux);
@@ -193,8 +191,8 @@ template SingleMessageProcessorQv(stateTreeDepth, voteOptionTreeDepth) {
193191
);
194192

195193
newStateRoot <== computedNewStateLeafQip;
196-
197-
// 7. Generate a new ballot root.
194+
195+
// 7. Generate a new ballot root.
198196
var computedNewBallot = PoseidonHasher(2)([computedNewBallotNonce, newBallotVoteOptionRoot]);
199197
var computedNewBallotQip = MerkleTreeInclusionProof(stateTreeDepth)(
200198
computedNewBallot,
@@ -204,4 +202,3 @@ template SingleMessageProcessorQv(stateTreeDepth, voteOptionTreeDepth) {
204202

205203
newBallotRoot <== computedNewBallotQip;
206204
}
207-

0 commit comments

Comments
 (0)