@maci-protocol/circuits 0.0.0-ci.a128a72 → 0.0.0-ci.a34075e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,13 +32,14 @@ include "../../utils/trees/incrementalQuinaryTree.circom";
32
32
  var STATE_TREE_ARITY = 2;
33
33
  var MSG_LENGTH = 10;
34
34
  var PACKED_CMD_LENGTH = 4;
35
- var STATE_LEAF_LENGTH = 3;
35
+ var STATE_LEAF_LENGTH = 4;
36
36
  var BALLOT_LENGTH = 2;
37
37
  var BALLOT_NONCE_IDX = 0;
38
38
  var BALLOT_VO_ROOT_IDX = 1;
39
39
  var STATE_LEAF_PUB_X_IDX = 0;
40
40
  var STATE_LEAF_PUB_Y_IDX = 1;
41
41
  var STATE_LEAF_VOICE_CREDIT_BALANCE_IDX = 2;
42
+ var STATE_LEAF_TIMESTAMP_IDX = 3;
42
43
  var msgTreeZeroValue = 8370432830353022751713833565135785980866757267633941821328460903436894336785;
43
44
  // Number of options for this poll.
44
45
  var maxVoteOptions = VOTE_OPTION_TREE_ARITY ** voteOptionTreeDepth;
@@ -265,7 +266,7 @@ include "../../utils/trees/incrementalQuinaryTree.circom";
265
266
  */
266
267
  template ProcessOneNonQv(stateTreeDepth, voteOptionTreeDepth) {
267
268
  // Constants defining the structure and size of state and ballots.
268
- var STATE_LEAF_LENGTH = 3;
269
+ var STATE_LEAF_LENGTH = 4;
269
270
  var BALLOT_LENGTH = 2;
270
271
  var MSG_LENGTH = 10;
271
272
  var PACKED_CMD_LENGTH = 4;
@@ -281,6 +282,8 @@ template ProcessOneNonQv(stateTreeDepth, voteOptionTreeDepth) {
281
282
  var STATE_LEAF_PUB_Y_IDX = 1;
282
283
  // Voice Credit balance.
283
284
  var STATE_LEAF_VOICE_CREDIT_BALANCE_IDX = 2;
285
+ // Timestamp.
286
+ var STATE_LEAF_TIMESTAMP_IDX = 3;
284
287
  var N_BITS = 252;
285
288
 
286
289
  // Number of users that have completed the sign up.
@@ -354,7 +357,7 @@ template ProcessOneNonQv(stateTreeDepth, voteOptionTreeDepth) {
354
357
  var computedStateLeafPathIndices[stateTreeDepth] = MerkleGeneratePathIndices(stateTreeDepth)(stateIndexMux);
355
358
 
356
359
  // 3. Verify that the original state leaf exists in the given state root.
357
- var stateLeafHash = PoseidonHasher(3)(stateLeaf);
360
+ var stateLeafHash = PoseidonHasher(4)(stateLeaf);
358
361
  var stateLeafQip = BinaryMerkleRoot(stateTreeDepth)(
359
362
  stateLeafHash,
360
363
  actualStateTreeDepth,
@@ -416,10 +419,11 @@ template ProcessOneNonQv(stateTreeDepth, voteOptionTreeDepth) {
416
419
  newBallotVoRoot <== newBallotVoRootMux;
417
420
 
418
421
  // 6. Generate a new state root.
419
- var computedNewStateLeafhash = PoseidonHasher(3)([
422
+ var computedNewStateLeafhash = PoseidonHasher(4)([
420
423
  computedNewSlPubKey[STATE_LEAF_PUB_X_IDX],
421
424
  computedNewSlPubKey[STATE_LEAF_PUB_Y_IDX],
422
- voiceCreditBalanceMux
425
+ voiceCreditBalanceMux,
426
+ stateLeaf[STATE_LEAF_TIMESTAMP_IDX]
423
427
  ]);
424
428
 
425
429
  var computedNewStateLeafQip = BinaryMerkleRoot(stateTreeDepth)(
@@ -32,13 +32,14 @@ template ProcessMessages(
32
32
  var STATE_TREE_ARITY = 2;
33
33
  var MSG_LENGTH = 10;
34
34
  var PACKED_CMD_LENGTH = 4;
35
- var STATE_LEAF_LENGTH = 3;
35
+ var STATE_LEAF_LENGTH = 4;
36
36
  var BALLOT_LENGTH = 2;
37
37
  var BALLOT_NONCE_IDX = 0;
38
38
  var BALLOT_VO_ROOT_IDX = 1;
39
39
  var STATE_LEAF_PUB_X_IDX = 0;
40
40
  var STATE_LEAF_PUB_Y_IDX = 1;
41
41
  var STATE_LEAF_VOICE_CREDIT_BALANCE_IDX = 2;
42
+ var STATE_LEAF_TIMESTAMP_IDX = 3;
42
43
  var msgTreeZeroValue = 8370432830353022751713833565135785980866757267633941821328460903436894336785;
43
44
  // Number of options for this poll.
44
45
  var maxVoteOptions = VOTE_OPTION_TREE_ARITY ** voteOptionTreeDepth;
@@ -259,7 +260,7 @@ template ProcessMessages(
259
260
  */
260
261
  template ProcessOne(stateTreeDepth, voteOptionTreeDepth) {
261
262
  // Constants defining the structure and size of state and ballots.
262
- var STATE_LEAF_LENGTH = 3;
263
+ var STATE_LEAF_LENGTH = 4;
263
264
  var BALLOT_LENGTH = 2;
264
265
  var MSG_LENGTH = 10;
265
266
  var PACKED_CMD_LENGTH = 4;
@@ -275,6 +276,8 @@ template ProcessOne(stateTreeDepth, voteOptionTreeDepth) {
275
276
  var STATE_LEAF_PUB_Y_IDX = 1;
276
277
  // Voice Credit balance.
277
278
  var STATE_LEAF_VOICE_CREDIT_BALANCE_IDX = 2;
279
+ // Timestamp.
280
+ var STATE_LEAF_TIMESTAMP_IDX = 3;
278
281
  var N_BITS = 252;
279
282
 
280
283
  // Number of users that have completed the sign up.
@@ -353,7 +356,7 @@ template ProcessOne(stateTreeDepth, voteOptionTreeDepth) {
353
356
  var computedStateLeafPathIndices[stateTreeDepth] = MerkleGeneratePathIndices(stateTreeDepth)(stateIndexMux);
354
357
 
355
358
  // 3. Verify that the original state leaf exists in the given state root.
356
- var stateLeafHash = PoseidonHasher(3)(stateLeaf);
359
+ var stateLeafHash = PoseidonHasher(4)(stateLeaf);
357
360
  var stateLeafQip = BinaryMerkleRoot(stateTreeDepth)(
358
361
  stateLeafHash,
359
362
  actualStateTreeDepth,
@@ -418,10 +421,11 @@ template ProcessOne(stateTreeDepth, voteOptionTreeDepth) {
418
421
  newBallotVoRoot <== newBallotVoRootMux;
419
422
 
420
423
  // 6. Generate a new state root.
421
- var computedNewStateLeafhash = PoseidonHasher(3)([
424
+ var computedNewStateLeafhash = PoseidonHasher(4)([
422
425
  computedNewSlPubKey[STATE_LEAF_PUB_X_IDX],
423
426
  computedNewSlPubKey[STATE_LEAF_PUB_Y_IDX],
424
- voiceCreditBalanceMux
427
+ voiceCreditBalanceMux,
428
+ stateLeaf[STATE_LEAF_TIMESTAMP_IDX]
425
429
  ]);
426
430
 
427
431
  var computedNewStateLeafQip = BinaryMerkleRoot(stateTreeDepth)(
@@ -65,6 +65,8 @@ template PollJoined(stateTreeDepth) {
65
65
  signal input privKey;
66
66
  // User's voice credits balance
67
67
  signal input voiceCreditsBalance;
68
+ // Poll's joined timestamp
69
+ signal input joinTimestamp;
68
70
  // Path elements
69
71
  signal input pathElements[stateTreeDepth][STATE_TREE_ARITY - 1];
70
72
  // Path indices
@@ -77,7 +79,7 @@ template PollJoined(stateTreeDepth) {
77
79
  // User private to public key
78
80
  var derivedPubKey[2] = PrivToPubKey()(privKey);
79
81
 
80
- var stateLeaf = PoseidonHasher(3)([derivedPubKey[0], derivedPubKey[1], voiceCreditsBalance]);
82
+ var stateLeaf = PoseidonHasher(4)([derivedPubKey[0], derivedPubKey[1], voiceCreditsBalance, joinTimestamp]);
81
83
 
82
84
  // Inclusion proof
83
85
  var stateLeafQip = BinaryMerkleRoot(stateTreeDepth)(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maci-protocol/circuits",
3
- "version": "0.0.0-ci.a128a72",
3
+ "version": "0.0.0-ci.a34075e",
4
4
  "private": false,
5
5
  "description": "zk-SNARK circuits for MACI",
6
6
  "main": "build/ts/index.js",
@@ -43,10 +43,10 @@
43
43
  "test:pollJoined": "pnpm run mocha-test ts/__tests__/PollJoined.test.ts"
44
44
  },
45
45
  "dependencies": {
46
- "@maci-protocol/core": "0.0.0-ci.a128a72",
47
- "@maci-protocol/crypto": "0.0.0-ci.a128a72",
48
- "@maci-protocol/domainobjs": "0.0.0-ci.a128a72",
49
- "@maci-protocol/sdk": "0.0.0-ci.a128a72",
46
+ "@maci-protocol/core": "0.0.0-ci.a34075e",
47
+ "@maci-protocol/crypto": "0.0.0-ci.a34075e",
48
+ "@maci-protocol/domainobjs": "0.0.0-ci.a34075e",
49
+ "@maci-protocol/sdk": "0.0.0-ci.a34075e",
50
50
  "@zk-kit/circuits": "^0.4.0",
51
51
  "circomkit": "^0.3.2",
52
52
  "circomlib": "^2.0.5"
@@ -67,5 +67,5 @@
67
67
  "ts-node": "^10.9.1",
68
68
  "typescript": "^5.8.3"
69
69
  },
70
- "gitHead": "45c2c0f83bf3646e41632e7ab3cd283af898cc85"
70
+ "gitHead": "bb20fd11992d189dc5a99de39bb2fb52558d6876"
71
71
  }