@maci-protocol/circuits 0.0.0-ci.4b8eeec → 0.0.0-ci.4bfa285
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.
- package/README.md +2 -2
- package/build/ts/types.d.ts +4 -4
- package/build/ts/types.d.ts.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/circom/circuits.json +12 -12
- package/circom/coordinator/full/MessageProcessor.circom +9 -9
- package/circom/coordinator/full/SingleMessageProcessor.circom +3 -4
- package/circom/coordinator/non-qv/{processMessages.circom → MessageProcessor.circom} +12 -207
- package/circom/coordinator/non-qv/SingleMessageProcessor.circom +199 -0
- package/circom/coordinator/non-qv/{tallyVotes.circom → VoteTally.circom} +16 -93
- package/circom/coordinator/qv/{processMessages.circom → MessageProcessor.circom} +13 -215
- package/circom/coordinator/qv/SingleMessageProcessor.circom +207 -0
- package/circom/coordinator/qv/{tallyVotes.circom → VoteTally.circom} +12 -112
- package/circom/coordinator/qv/VoteTallyWithIndividualCounts.circom +226 -0
- package/circom/utils/CalculateTotal.circom +6 -6
- package/circom/utils/non-qv/ResultCommitmentVerifier.circom +84 -0
- package/circom/utils/qv/ResultCommitmentVerifier.circom +107 -0
- package/circom/utils/trees/BinaryMerkleRoot.circom +6 -3
- package/circom/voter/PollJoined.circom +3 -3
- package/circom/voter/PollJoining.circom +3 -3
- package/package.json +14 -14
- package/circom/utils/trees/MerklePathIndicesGenerator.circom +0 -44
|
@@ -19,8 +19,8 @@ template PollJoined(stateTreeDepth) {
|
|
|
19
19
|
signal input voiceCreditsBalance;
|
|
20
20
|
// Path elements
|
|
21
21
|
signal input pathElements[stateTreeDepth][STATE_TREE_ARITY - 1];
|
|
22
|
-
//
|
|
23
|
-
signal input
|
|
22
|
+
// Index
|
|
23
|
+
signal input index;
|
|
24
24
|
// Poll State tree root which proves the user is joined
|
|
25
25
|
signal input stateRoot;
|
|
26
26
|
// The actual tree depth (might be <= stateTreeDepth) Used in BinaryMerkleRoot
|
|
@@ -35,7 +35,7 @@ template PollJoined(stateTreeDepth) {
|
|
|
35
35
|
var calculatedRoot = BinaryMerkleRoot(stateTreeDepth)(
|
|
36
36
|
stateLeaf,
|
|
37
37
|
actualStateTreeDepth,
|
|
38
|
-
|
|
38
|
+
index,
|
|
39
39
|
pathElements
|
|
40
40
|
);
|
|
41
41
|
|
|
@@ -18,8 +18,8 @@ template PollJoining(stateTreeDepth) {
|
|
|
18
18
|
signal input pollPublicKey[2];
|
|
19
19
|
// Siblings
|
|
20
20
|
signal input siblings[stateTreeDepth][STATE_TREE_ARITY - 1];
|
|
21
|
-
//
|
|
22
|
-
signal input
|
|
21
|
+
// Index
|
|
22
|
+
signal input index;
|
|
23
23
|
// User's hashed private key
|
|
24
24
|
signal input nullifier;
|
|
25
25
|
// MACI State tree root which proves the user is signed up
|
|
@@ -46,7 +46,7 @@ template PollJoining(stateTreeDepth) {
|
|
|
46
46
|
var calculatedRoot = BinaryMerkleRoot(stateTreeDepth)(
|
|
47
47
|
publicKeyHash,
|
|
48
48
|
actualStateTreeDepth,
|
|
49
|
-
|
|
49
|
+
index,
|
|
50
50
|
siblings
|
|
51
51
|
);
|
|
52
52
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maci-protocol/circuits",
|
|
3
|
-
"version": "0.0.0-ci.
|
|
3
|
+
"version": "0.0.0-ci.4bfa285",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "zk-SNARK circuits for MACI",
|
|
6
6
|
"main": "build/ts/index.js",
|
|
@@ -38,37 +38,37 @@
|
|
|
38
38
|
"test:verifySignature": "pnpm run mocha-test ts/__tests__/VerifySignature.test.ts",
|
|
39
39
|
"test:privateToPublicKey": "pnpm run mocha-test ts/__tests__/PrivateToPublicKey.test.ts",
|
|
40
40
|
"test:calculateTotal": "pnpm run mocha-test ts/__tests__/CalculateTotal.test.ts",
|
|
41
|
-
"test:
|
|
42
|
-
"test:
|
|
41
|
+
"test:messageProcessor": "pnpm run mocha-test ts/__tests__/MessageProcessor.test.ts",
|
|
42
|
+
"test:voteTally": "pnpm run mocha-test ts/__tests__/VoteTally.test.ts",
|
|
43
43
|
"test:ceremonyParams": "pnpm run mocha-test ts/__tests__/CeremonyParams.test.ts",
|
|
44
44
|
"test:incrementalQuinaryTree": "pnpm run mocha-test ts/__tests__/IncrementalQuinaryTree.test.ts",
|
|
45
45
|
"test:pollJoining": "pnpm run mocha-test ts/__tests__/PollJoining.test.ts",
|
|
46
46
|
"test:pollJoined": "pnpm run mocha-test ts/__tests__/PollJoined.test.ts"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@maci-protocol/core": "0.0.0-ci.
|
|
50
|
-
"@maci-protocol/crypto": "0.0.0-ci.
|
|
51
|
-
"@maci-protocol/domainobjs": "0.0.0-ci.
|
|
52
|
-
"@maci-protocol/sdk": "0.0.0-ci.
|
|
49
|
+
"@maci-protocol/core": "0.0.0-ci.4bfa285",
|
|
50
|
+
"@maci-protocol/crypto": "0.0.0-ci.4bfa285",
|
|
51
|
+
"@maci-protocol/domainobjs": "0.0.0-ci.4bfa285",
|
|
52
|
+
"@maci-protocol/sdk": "0.0.0-ci.4bfa285",
|
|
53
53
|
"@zk-kit/circuits": "^0.4.0",
|
|
54
|
-
"circomkit": "^0.3.
|
|
54
|
+
"circomkit": "^0.3.4",
|
|
55
55
|
"circomlib": "^2.0.5"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/chai": "^4.3.11",
|
|
59
59
|
"@types/chai-as-promised": "^7.1.8",
|
|
60
60
|
"@types/mocha": "^10.0.10",
|
|
61
|
-
"@types/node": "^
|
|
61
|
+
"@types/node": "^24.2.0",
|
|
62
62
|
"@types/snarkjs": "^0.7.9",
|
|
63
63
|
"@zk-kit/baby-jubjub": "^1.0.3",
|
|
64
64
|
"chai": "^4.3.10",
|
|
65
65
|
"chai-as-promised": "^7.1.2",
|
|
66
|
-
"fast-check": "^4.
|
|
67
|
-
"glob": "^11.0.
|
|
68
|
-
"mocha": "^11.1
|
|
66
|
+
"fast-check": "^4.2.0",
|
|
67
|
+
"glob": "^11.0.3",
|
|
68
|
+
"mocha": "^11.7.1",
|
|
69
69
|
"ts-mocha": "^11.1.0",
|
|
70
70
|
"ts-node": "^10.9.1",
|
|
71
|
-
"typescript": "^5.
|
|
71
|
+
"typescript": "^5.9.2"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "c97c6da0a22051816057484b29b494b20bbc1048"
|
|
74
74
|
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
pragma circom 2.0.0;
|
|
2
|
-
|
|
3
|
-
// zk-kit imports
|
|
4
|
-
include "./safe-comparators.circom";
|
|
5
|
-
// local import
|
|
6
|
-
include "../CalculateTotal.circom";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Calculates the path indices required for Merkle proof verifications.
|
|
10
|
-
* Given a node index within an IMT and the total tree levels, it outputs the path indices leading to that node.
|
|
11
|
-
* The template handles the modulo and division operations to break down the tree index into its constituent path indices.
|
|
12
|
-
*/
|
|
13
|
-
template MerklePathIndicesGenerator(levels) {
|
|
14
|
-
// The base used for the modulo and division operations, set to 2 for binary trees.
|
|
15
|
-
var BASE = 2;
|
|
16
|
-
|
|
17
|
-
// The total sum of the path indices.
|
|
18
|
-
signal input indices;
|
|
19
|
-
|
|
20
|
-
// The generated path indices.
|
|
21
|
-
signal output out[levels];
|
|
22
|
-
|
|
23
|
-
var computedIndices = indices;
|
|
24
|
-
var computedResults[levels];
|
|
25
|
-
|
|
26
|
-
for (var i = 0; i < levels; i++) {
|
|
27
|
-
// circom's best practices suggests to avoid using <-- unless you
|
|
28
|
-
// are aware of what's going on. This is the only way to do modulo operation.
|
|
29
|
-
out[i] <-- computedIndices % BASE;
|
|
30
|
-
computedIndices = computedIndices \ BASE;
|
|
31
|
-
|
|
32
|
-
// Check that each output element is less than the base.
|
|
33
|
-
var computedIsOutputElementLessThanBase = SafeLessThan(3)([out[i], BASE]);
|
|
34
|
-
computedIsOutputElementLessThanBase === 1;
|
|
35
|
-
|
|
36
|
-
// Re-compute the total sum.
|
|
37
|
-
computedResults[i] = out[i] * (BASE ** i);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Check that the total sum matches the index.
|
|
41
|
-
var computedCalculateTotal = CalculateTotal(levels)(computedResults);
|
|
42
|
-
|
|
43
|
-
computedCalculateTotal === indices;
|
|
44
|
-
}
|