@maci-protocol/circuits 0.0.0-ci.4c6d4e8 → 0.0.0-ci.52ce07e
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/LICENSE +1 -2
- package/build/ts/{genZkeys.d.ts → generateZkeys.d.ts} +1 -1
- package/build/ts/generateZkeys.d.ts.map +1 -0
- package/build/ts/{genZkeys.js → generateZkeys.js} +1 -1
- package/build/ts/generateZkeys.js.map +1 -0
- package/build/ts/types.d.ts +11 -11
- package/build/ts/types.d.ts.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/circom/circuits.json +23 -7
- package/circom/coordinator/full/MessageProcessor.circom +253 -0
- package/circom/coordinator/full/SingleMessageProcessor.circom +204 -0
- package/circom/coordinator/non-qv/processMessages.circom +110 -112
- package/circom/coordinator/non-qv/tallyVotes.circom +49 -46
- package/circom/coordinator/qv/processMessages.circom +111 -110
- package/circom/coordinator/qv/tallyVotes.circom +63 -63
- package/circom/utils/{calculateTotal.circom → CalculateTotal.circom} +8 -6
- package/circom/utils/{verifySignature.circom → EdDSAPoseidonVerifier.circom} +40 -66
- package/circom/utils/MessageHasher.circom +57 -0
- package/circom/utils/MessageToCommand.circom +107 -0
- package/circom/utils/PoseidonHasher.circom +29 -0
- package/circom/utils/{privToPubKey.circom → PrivateToPublicKey.circom} +12 -10
- package/circom/utils/VerifySignature.circom +39 -0
- package/circom/utils/full/MessageValidator.circom +91 -0
- package/circom/utils/full/StateLeafAndBallotTransformer.circom +122 -0
- package/circom/utils/non-qv/{messageValidator.circom → MessageValidator.circom} +17 -15
- package/circom/utils/non-qv/{stateLeafAndBallotTransformer.circom → StateLeafAndBallotTransformer.circom} +36 -36
- package/circom/utils/qv/{messageValidator.circom → MessageValidator.circom} +17 -15
- package/circom/utils/qv/{stateLeafAndBallotTransformer.circom → StateLeafAndBallotTransformer.circom} +36 -36
- package/circom/utils/trees/BinaryMerkleRoot.circom +11 -3
- package/circom/utils/trees/CheckRoot.circom +18 -14
- package/circom/utils/trees/LeafExists.circom +3 -3
- package/circom/utils/trees/{MerkleGeneratePathIndices.circom → MerklePathIndicesGenerator.circom} +11 -7
- package/circom/utils/trees/MerkleTreeInclusionProof.circom +10 -9
- package/circom/utils/trees/QuinaryCheckRoot.circom +54 -0
- package/circom/utils/trees/QuinaryGeneratePathIndices.circom +44 -0
- package/circom/utils/trees/QuinaryLeafExists.circom +30 -0
- package/circom/utils/trees/QuinarySelector.circom +42 -0
- package/circom/utils/trees/QuinaryTreeInclusionProof.circom +55 -0
- package/circom/utils/trees/Splicer.circom +76 -0
- package/circom/voter/PollJoined.circom +43 -0
- package/circom/voter/PollJoining.circom +54 -0
- package/package.json +15 -12
- package/build/ts/genZkeys.d.ts.map +0 -1
- package/build/ts/genZkeys.js.map +0 -1
- package/circom/utils/hashers.circom +0 -78
- package/circom/utils/messageToCommand.circom +0 -78
- package/circom/utils/trees/incrementalQuinaryTree.circom +0 -287
- package/circom/voter/poll.circom +0 -92
package/circom/voter/poll.circom
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
pragma circom 2.0.0;
|
|
2
|
-
|
|
3
|
-
// local imports
|
|
4
|
-
include "../utils/hashers.circom";
|
|
5
|
-
include "../utils/privToPubKey.circom";
|
|
6
|
-
include "../utils/trees/BinaryMerkleRoot.circom";
|
|
7
|
-
|
|
8
|
-
// Poll Joining Circuit
|
|
9
|
-
// Allows a user to prove knowledge of a private key that is signed up to
|
|
10
|
-
// a MACI contract.
|
|
11
|
-
template PollJoining(stateTreeDepth) {
|
|
12
|
-
// Constants defining the tree structure
|
|
13
|
-
var STATE_TREE_ARITY = 2;
|
|
14
|
-
|
|
15
|
-
// User's private key
|
|
16
|
-
signal input privKey;
|
|
17
|
-
// Poll's public key
|
|
18
|
-
signal input pollPubKey[2];
|
|
19
|
-
// Siblings
|
|
20
|
-
signal input siblings[stateTreeDepth][STATE_TREE_ARITY - 1];
|
|
21
|
-
// Indices
|
|
22
|
-
signal input indices[stateTreeDepth];
|
|
23
|
-
// User's hashed private key
|
|
24
|
-
signal input nullifier;
|
|
25
|
-
// MACI State tree root which proves the user is signed up
|
|
26
|
-
signal input stateRoot;
|
|
27
|
-
// The actual tree depth (might be <= stateTreeDepth) used in BinaryMerkleRoot
|
|
28
|
-
signal input actualStateTreeDepth;
|
|
29
|
-
// The poll id
|
|
30
|
-
signal input pollId;
|
|
31
|
-
|
|
32
|
-
// Compute the nullifier (hash of private key and poll id)
|
|
33
|
-
var computedNullifier = PoseidonHasher(2)([privKey, pollId]);
|
|
34
|
-
nullifier === computedNullifier;
|
|
35
|
-
|
|
36
|
-
// User private to public key
|
|
37
|
-
var derivedPubKey[2] = PrivToPubKey()(privKey);
|
|
38
|
-
// Hash the public key
|
|
39
|
-
var pubKeyHash = PoseidonHasher(2)([derivedPubKey[0], derivedPubKey[1]]);
|
|
40
|
-
|
|
41
|
-
// Ensure the poll public key is the same as the maci one (public input)
|
|
42
|
-
derivedPubKey[0] === pollPubKey[0];
|
|
43
|
-
derivedPubKey[1] === pollPubKey[1];
|
|
44
|
-
|
|
45
|
-
// Inclusion proof
|
|
46
|
-
var calculatedRoot = BinaryMerkleRoot(stateTreeDepth)(
|
|
47
|
-
pubKeyHash,
|
|
48
|
-
actualStateTreeDepth,
|
|
49
|
-
indices,
|
|
50
|
-
siblings
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
calculatedRoot === stateRoot;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Poll Joined Circuit
|
|
57
|
-
// Allows a user to prove that they have joined a MACI poll.
|
|
58
|
-
// This is to be used with the MACI offchain implementation to allow
|
|
59
|
-
// users to authenticate to the relayer service (to reduce spamming).
|
|
60
|
-
template PollJoined(stateTreeDepth) {
|
|
61
|
-
// Constants defining the tree structure
|
|
62
|
-
var STATE_TREE_ARITY = 2;
|
|
63
|
-
|
|
64
|
-
// User's private key
|
|
65
|
-
signal input privKey;
|
|
66
|
-
// User's voice credits balance
|
|
67
|
-
signal input voiceCreditsBalance;
|
|
68
|
-
// Path elements
|
|
69
|
-
signal input pathElements[stateTreeDepth][STATE_TREE_ARITY - 1];
|
|
70
|
-
// Path indices
|
|
71
|
-
signal input pathIndices[stateTreeDepth];
|
|
72
|
-
// Poll State tree root which proves the user is joined
|
|
73
|
-
signal input stateRoot;
|
|
74
|
-
// The actual tree depth (might be <= stateTreeDepth) Used in BinaryMerkleRoot
|
|
75
|
-
signal input actualStateTreeDepth;
|
|
76
|
-
|
|
77
|
-
// User private to public key
|
|
78
|
-
var derivedPubKey[2] = PrivToPubKey()(privKey);
|
|
79
|
-
|
|
80
|
-
var stateLeaf = PoseidonHasher(3)([derivedPubKey[0], derivedPubKey[1], voiceCreditsBalance]);
|
|
81
|
-
|
|
82
|
-
// Inclusion proof
|
|
83
|
-
var stateLeafQip = BinaryMerkleRoot(stateTreeDepth)(
|
|
84
|
-
stateLeaf,
|
|
85
|
-
actualStateTreeDepth,
|
|
86
|
-
pathIndices,
|
|
87
|
-
pathElements
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
stateLeafQip === stateRoot;
|
|
91
|
-
}
|
|
92
|
-
|