@maci-protocol/sdk 0.0.0-ci.98aa65d → 0.0.0-ci.991fa14
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/package.json +18 -9
- package/build/ts/browser/index.d.ts +8 -8
- package/build/ts/browser/index.d.ts.map +1 -1
- package/build/ts/browser/index.js +17 -20
- package/build/ts/browser/index.js.map +1 -1
- package/build/ts/browser/joinPoll.d.ts +10 -0
- package/build/ts/browser/joinPoll.d.ts.map +1 -0
- package/build/ts/browser/joinPoll.js +88 -0
- package/build/ts/browser/joinPoll.js.map +1 -0
- package/build/ts/browser/utils.d.ts +18 -0
- package/build/ts/browser/utils.d.ts.map +1 -0
- package/build/ts/browser/utils.js +37 -0
- package/build/ts/browser/utils.js.map +1 -0
- package/build/ts/deploy/index.d.ts +2 -2
- package/build/ts/deploy/index.d.ts.map +1 -1
- package/build/ts/deploy/index.js +3 -3
- package/build/ts/deploy/index.js.map +1 -1
- package/build/ts/deploy/maci.d.ts +1 -1
- package/build/ts/deploy/maci.d.ts.map +1 -1
- package/build/ts/deploy/maci.js +18 -8
- package/build/ts/deploy/maci.js.map +1 -1
- package/build/ts/deploy/poll.d.ts +1 -1
- package/build/ts/deploy/poll.d.ts.map +1 -1
- package/build/ts/deploy/poll.js +20 -15
- package/build/ts/deploy/poll.js.map +1 -1
- package/build/ts/deploy/types.d.ts +34 -13
- package/build/ts/deploy/types.d.ts.map +1 -1
- package/build/ts/deploy/utils.js +1 -1
- package/build/ts/deploy/utils.js.map +1 -1
- package/build/ts/deploy/verifyingKeysRegistry.d.ts +7 -0
- package/build/ts/deploy/verifyingKeysRegistry.d.ts.map +1 -0
- package/build/ts/deploy/verifyingKeysRegistry.js +14 -0
- package/build/ts/deploy/verifyingKeysRegistry.js.map +1 -0
- package/build/ts/index.d.ts +3 -2
- package/build/ts/index.d.ts.map +1 -1
- package/build/ts/index.js +16 -9
- package/build/ts/index.js.map +1 -1
- package/build/ts/maci/policy.d.ts +13 -1
- package/build/ts/maci/policy.d.ts.map +1 -1
- package/build/ts/maci/policy.js +41 -2
- package/build/ts/maci/policy.js.map +1 -1
- package/build/ts/maci/state.d.ts +1 -1
- package/build/ts/maci/state.js +11 -11
- package/build/ts/maci/state.js.map +1 -1
- package/build/ts/maci/types.d.ts +34 -2
- package/build/ts/maci/types.d.ts.map +1 -1
- package/build/ts/maci/types.js +2 -0
- package/build/ts/maci/types.js.map +1 -1
- package/build/ts/maciKeys/__tests__/keypair.test.js +7 -7
- package/build/ts/maciKeys/__tests__/keypair.test.js.map +1 -1
- package/build/ts/maciKeys/__tests__/publicKeys.test.js +7 -7
- package/build/ts/maciKeys/__tests__/publicKeys.test.js.map +1 -1
- package/build/ts/maciKeys/keypair.d.ts.map +1 -1
- package/build/ts/maciKeys/keypair.js +4 -3
- package/build/ts/maciKeys/keypair.js.map +1 -1
- package/build/ts/maciKeys/publicKeys.d.ts +2 -2
- package/build/ts/maciKeys/publicKeys.d.ts.map +1 -1
- package/build/ts/maciKeys/publicKeys.js +6 -6
- package/build/ts/maciKeys/publicKeys.js.map +1 -1
- package/build/ts/maciKeys/types.d.ts +5 -0
- package/build/ts/maciKeys/types.d.ts.map +1 -1
- package/build/ts/poll/poll.d.ts.map +1 -1
- package/build/ts/poll/poll.js +9 -9
- package/build/ts/poll/poll.js.map +1 -1
- package/build/ts/poll/types.d.ts +6 -7
- package/build/ts/poll/types.d.ts.map +1 -1
- package/build/ts/poll/utils.js +3 -3
- package/build/ts/poll/utils.js.map +1 -1
- package/build/ts/proof/__tests__/download.test.js +8 -5
- package/build/ts/proof/__tests__/download.test.js.map +1 -1
- package/build/ts/proof/download.d.ts +3 -3
- package/build/ts/proof/download.d.ts.map +1 -1
- package/build/ts/proof/download.js +5 -7
- package/build/ts/proof/download.js.map +1 -1
- package/build/ts/proof/generate.d.ts +2 -2
- package/build/ts/proof/generate.d.ts.map +1 -1
- package/build/ts/proof/generate.js +31 -25
- package/build/ts/proof/generate.js.map +1 -1
- package/build/ts/proof/prove.d.ts +1 -1
- package/build/ts/proof/prove.d.ts.map +1 -1
- package/build/ts/proof/prove.js +29 -19
- package/build/ts/proof/prove.js.map +1 -1
- package/build/ts/proof/types.d.ts +45 -15
- package/build/ts/proof/types.d.ts.map +1 -1
- package/build/ts/proof/utils.d.ts +10 -0
- package/build/ts/proof/utils.d.ts.map +1 -0
- package/build/ts/proof/utils.js +24 -0
- package/build/ts/proof/utils.js.map +1 -0
- package/build/ts/relayer/__tests__/messages.test.js +1 -1
- package/build/ts/relayer/__tests__/messages.test.js.map +1 -1
- package/build/ts/relayer/__tests__/utils.test.js +3 -3
- package/build/ts/relayer/__tests__/utils.test.js.map +1 -1
- package/build/ts/relayer/messages.js +1 -1
- package/build/ts/relayer/utils.js +4 -4
- package/build/ts/relayer/utils.js.map +1 -1
- package/build/ts/subgraph/index.d.ts +3 -0
- package/build/ts/subgraph/index.d.ts.map +1 -0
- package/build/ts/subgraph/index.js +18 -0
- package/build/ts/subgraph/index.js.map +1 -0
- package/build/ts/subgraph/maciSubgraph.d.ts +28 -0
- package/build/ts/subgraph/maciSubgraph.d.ts.map +1 -0
- package/build/ts/subgraph/maciSubgraph.js +64 -0
- package/build/ts/subgraph/maciSubgraph.js.map +1 -0
- package/build/ts/subgraph/types.d.ts +20 -0
- package/build/ts/subgraph/types.d.ts.map +1 -0
- package/build/ts/subgraph/types.js +3 -0
- package/build/ts/subgraph/types.js.map +1 -0
- package/build/ts/tally/commitments.d.ts.map +1 -1
- package/build/ts/tally/commitments.js +8 -7
- package/build/ts/tally/commitments.js.map +1 -1
- package/build/ts/tally/index.d.ts +2 -1
- package/build/ts/tally/index.d.ts.map +1 -1
- package/build/ts/tally/index.js +5 -1
- package/build/ts/tally/index.js.map +1 -1
- package/build/ts/tally/results.d.ts +20 -0
- package/build/ts/tally/results.d.ts.map +1 -0
- package/build/ts/tally/results.js +49 -0
- package/build/ts/tally/results.js.map +1 -0
- package/build/ts/tally/types.d.ts +55 -15
- package/build/ts/tally/types.d.ts.map +1 -1
- package/build/ts/tally/utils.d.ts +3 -3
- package/build/ts/tally/utils.d.ts.map +1 -1
- package/build/ts/tally/utils.js +10 -10
- package/build/ts/tally/utils.js.map +1 -1
- package/build/ts/tally/verification.d.ts +1 -1
- package/build/ts/tally/verification.d.ts.map +1 -1
- package/build/ts/tally/verification.js +10 -10
- package/build/ts/tally/verification.js.map +1 -1
- package/build/ts/trees/index.d.ts +2 -2
- package/build/ts/trees/index.d.ts.map +1 -1
- package/build/ts/trees/index.js +3 -1
- package/build/ts/trees/index.js.map +1 -1
- package/build/ts/trees/stateTree.d.ts +23 -1
- package/build/ts/trees/stateTree.d.ts.map +1 -1
- package/build/ts/trees/stateTree.js +76 -12
- package/build/ts/trees/stateTree.js.map +1 -1
- package/build/ts/trees/types.d.ts +11 -2
- package/build/ts/trees/types.d.ts.map +1 -1
- package/build/ts/user/index.d.ts +4 -2
- package/build/ts/user/index.d.ts.map +1 -1
- package/build/ts/user/index.js +14 -8
- package/build/ts/user/index.js.map +1 -1
- package/build/ts/user/joinPoll.d.ts +8 -0
- package/build/ts/user/joinPoll.d.ts.map +1 -0
- package/build/ts/user/joinPoll.js +84 -0
- package/build/ts/user/joinPoll.js.map +1 -0
- package/build/ts/user/signup.d.ts +20 -0
- package/build/ts/user/signup.d.ts.map +1 -0
- package/build/ts/user/signup.js +84 -0
- package/build/ts/user/signup.js.map +1 -0
- package/build/ts/user/types.d.ts +65 -29
- package/build/ts/user/types.d.ts.map +1 -1
- package/build/ts/user/utils.d.ts +50 -14
- package/build/ts/user/utils.d.ts.map +1 -1
- package/build/ts/user/utils.js +129 -57
- package/build/ts/user/utils.js.map +1 -1
- package/build/ts/utils/index.d.ts +1 -1
- package/build/ts/utils/index.d.ts.map +1 -1
- package/build/ts/utils/index.js +2 -1
- package/build/ts/utils/index.js.map +1 -1
- package/build/ts/utils/params.d.ts +1 -1
- package/build/ts/utils/params.d.ts.map +1 -1
- package/build/ts/utils/params.js +3 -3
- package/build/ts/utils/params.js.map +1 -1
- package/build/ts/utils/proofs.d.ts +2 -2
- package/build/ts/utils/proofs.d.ts.map +1 -1
- package/build/ts/utils/proofs.js +4 -4
- package/build/ts/utils/proofs.js.map +1 -1
- package/build/ts/utils/types.d.ts +2 -2
- package/build/ts/utils/types.d.ts.map +1 -1
- package/build/ts/utils/utils.d.ts +13 -0
- package/build/ts/utils/utils.d.ts.map +1 -1
- package/build/ts/utils/utils.js +26 -1
- package/build/ts/utils/utils.js.map +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.d.ts.map +1 -1
- package/build/ts/verifyingKeys/checkVerifyingKeys.js +18 -19
- package/build/ts/verifyingKeys/checkVerifyingKeys.js.map +1 -1
- package/build/ts/verifyingKeys/index.d.ts +2 -2
- package/build/ts/verifyingKeys/index.d.ts.map +1 -1
- package/build/ts/verifyingKeys/index.js +5 -5
- package/build/ts/verifyingKeys/index.js.map +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.d.ts.map +1 -1
- package/build/ts/verifyingKeys/setVerifyingKeys.js +76 -41
- package/build/ts/verifyingKeys/setVerifyingKeys.js.map +1 -1
- package/build/ts/verifyingKeys/types.d.ts +56 -48
- package/build/ts/verifyingKeys/types.d.ts.map +1 -1
- package/build/ts/verifyingKeys/utils.d.ts +10 -10
- package/build/ts/verifyingKeys/utils.d.ts.map +1 -1
- package/build/ts/verifyingKeys/utils.js +76 -60
- package/build/ts/verifyingKeys/utils.js.map +1 -1
- package/build/ts/vote/generate.d.ts +1 -1
- package/build/ts/vote/generate.d.ts.map +1 -1
- package/build/ts/vote/generate.js +4 -4
- package/build/ts/vote/generate.js.map +1 -1
- package/build/ts/vote/index.d.ts +2 -1
- package/build/ts/vote/index.d.ts.map +1 -1
- package/build/ts/vote/index.js +4 -2
- package/build/ts/vote/index.js.map +1 -1
- package/build/ts/vote/invalidate.js +4 -4
- package/build/ts/vote/invalidate.js.map +1 -1
- package/build/ts/vote/publish.d.ts +1 -1
- package/build/ts/vote/publish.d.ts.map +1 -1
- package/build/ts/vote/publish.js +19 -19
- package/build/ts/vote/publish.js.map +1 -1
- package/build/ts/vote/submit.js +5 -5
- package/build/ts/vote/submit.js.map +1 -1
- package/build/ts/vote/types.d.ts +6 -6
- package/build/ts/vote/types.d.ts.map +1 -1
- package/build/ts/vote/utils.d.ts +2 -2
- package/build/ts/vote/utils.d.ts.map +1 -1
- package/build/ts/vote/utils.js +7 -7
- package/build/ts/vote/utils.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +24 -15
- package/build/ts/deploy/vkRegistry.d.ts +0 -7
- package/build/ts/deploy/vkRegistry.d.ts.map +0 -1
- package/build/ts/deploy/vkRegistry.js +0 -14
- package/build/ts/deploy/vkRegistry.js.map +0 -1
- package/build/ts/proof/constants.d.ts +0 -17
- package/build/ts/proof/constants.d.ts.map +0 -1
- package/build/ts/proof/constants.js +0 -20
- package/build/ts/proof/constants.js.map +0 -1
- package/build/ts/user/user.d.ts +0 -42
- package/build/ts/user/user.d.ts.map +0 -1
- package/build/ts/user/user.js +0 -192
- package/build/ts/user/user.js.map +0 -1
package/build/ts/user/utils.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { type MACI } from "@maci-protocol/contracts/typechain-types";
|
|
2
|
+
import { type PrivateKey, PublicKey } from "@maci-protocol/domainobjs";
|
|
3
|
+
import type { IGetPollJoiningCircuitEventsArgs, IGetPollJoiningCircuitInputsFromStateFileArgs, IParsePollJoinEventsArgs, IParseSignupEventsArgs, IJoinedUserArgs, IIsNullifierOnChainArgs, IGenerateMaciStateTreeArgs, IGenerateMaciStateTreeWithEndKeyArgs } from "./types";
|
|
4
|
+
import type { IGenerateSignUpTree } from "../trees/types";
|
|
5
|
+
import type { TCircuitInputs } from "../utils/types";
|
|
6
|
+
import type { LeanIMTMerkleProof } from "@zk-kit/lean-imt";
|
|
5
7
|
/**
|
|
6
8
|
* Parse the poll joining events from the Poll contract
|
|
7
9
|
*/
|
|
@@ -9,6 +11,22 @@ export declare const parsePollJoinEvents: ({ pollContract, startBlock, currentBl
|
|
|
9
11
|
pollStateIndex?: string;
|
|
10
12
|
voiceCredits?: string;
|
|
11
13
|
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if user is joined to a poll with their public key and get its data
|
|
16
|
+
* @param {IJoinedUserArgs} - The arguments for the join check command
|
|
17
|
+
* @returns user joined or not and poll state index, voice credit balance
|
|
18
|
+
*/
|
|
19
|
+
export declare const getJoinedUserData: ({ maciAddress, pollId, pollPublicKey: serializedPollPublicKey, signer, startBlock, }: IJoinedUserArgs) => Promise<{
|
|
20
|
+
isJoined: boolean;
|
|
21
|
+
pollStateIndex?: string;
|
|
22
|
+
voiceCredits?: string;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a user joined a poll with a given nullifier
|
|
26
|
+
* @param {IIsNullifierOnChainArgs} args - The arguments for the is nullifier on chain command
|
|
27
|
+
* @returns whether the nullifier is on chain or not
|
|
28
|
+
*/
|
|
29
|
+
export declare const hasUserJoinedPoll: ({ maciAddress, pollId, nullifier, signer, }: IIsNullifierOnChainArgs) => Promise<boolean>;
|
|
12
30
|
/**
|
|
13
31
|
* Parse the signup events from the MACI contract
|
|
14
32
|
*/
|
|
@@ -17,30 +35,48 @@ export declare const parseSignupEvents: ({ maciContract, startBlock, currentBloc
|
|
|
17
35
|
}>;
|
|
18
36
|
/**
|
|
19
37
|
* Get state index from maci state leaves or from sign up leaves
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
38
|
+
* @param publicKeys Public keys from maci state or sign up tree
|
|
39
|
+
* @param userMaciPublicKey Public key of the maci user
|
|
22
40
|
* @param stateIndex State index from the command
|
|
23
41
|
* @returns State index
|
|
24
42
|
*/
|
|
25
|
-
export declare const getStateIndex: (
|
|
43
|
+
export declare const getStateIndex: (publicKeys: PublicKey[], userMaciPublicKey: PublicKey, stateIndex?: bigint) => bigint | undefined;
|
|
26
44
|
/**
|
|
27
45
|
* Create circuit input for pollJoining
|
|
28
46
|
* @param signUpData Sign up tree and state leaves
|
|
29
47
|
* @param stateTreeDepth Maci state tree depth
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @param pollPubKey Poll's public key for the poll joining
|
|
48
|
+
* @param maciPrivateKey User's private key for signing up
|
|
49
|
+
* @param pollPrivateKey Poll's private key for the poll joining
|
|
50
|
+
* @param pollPublicKey Poll's public key for the poll joining
|
|
34
51
|
* @param pollId Poll's id
|
|
35
52
|
* @returns stringified circuit inputs
|
|
36
53
|
*/
|
|
37
|
-
export declare const joiningCircuitInputs: (
|
|
54
|
+
export declare const joiningCircuitInputs: (inclusionProof: LeanIMTMerkleProof, stateTreeDepth: bigint, maciPrivateKey: PrivateKey, pollPublicKey: PublicKey, pollId: bigint) => TCircuitInputs;
|
|
38
55
|
/**
|
|
39
56
|
* Get the poll joining circuit inputs from a state file
|
|
40
57
|
* @param stateFile - The path to the state file
|
|
41
58
|
* @returns The poll joining circuit inputs
|
|
42
59
|
*/
|
|
43
|
-
export declare const getPollJoiningCircuitInputsFromStateFile: ({ stateFile, pollId, stateIndex,
|
|
60
|
+
export declare const getPollJoiningCircuitInputsFromStateFile: ({ stateFile, pollId, stateIndex, userMaciPrivateKey, }: IGetPollJoiningCircuitInputsFromStateFileArgs) => Promise<TCircuitInputs>;
|
|
61
|
+
/**
|
|
62
|
+
* Get the block number when the first SignUp event was emitted
|
|
63
|
+
* @param maciContract - The MACI contract to fetch events from
|
|
64
|
+
* @param startBlock - The block number to start searching from (optional)
|
|
65
|
+
* @returns The block number when the first SignUp event was emitted
|
|
66
|
+
*/
|
|
67
|
+
export declare const getFirstSignUpBlockNumber: (maciContract: MACI, startBlock?: number) => Promise<number>;
|
|
68
|
+
/**
|
|
69
|
+
* Generate MACI's state tree from the MACI contract
|
|
70
|
+
* @param {IGenerateMaciStateTreeArgs} args - The arguments for the generate maci state tree command
|
|
71
|
+
* @returns The MACI's state tree
|
|
72
|
+
*/
|
|
73
|
+
export declare const generateMaciStateTree: ({ maciContractAddress, signer, startBlock, endBlock, blocksPerBatch, }: IGenerateMaciStateTreeArgs) => Promise<IGenerateSignUpTree>;
|
|
74
|
+
/**
|
|
75
|
+
* Generate MACI's state tree from the MACI contract with a given end key
|
|
76
|
+
* @param {IGenerateMaciStateTreeWithEndKeyArgs} args - The arguments for the generate maci state tree command
|
|
77
|
+
* @returns The MACI's state tree
|
|
78
|
+
*/
|
|
79
|
+
export declare const generateMaciStateTreeWithEndKey: ({ maciContractAddress, signer, startBlock, endBlock, blocksPerBatch, userPublicKey, }: IGenerateMaciStateTreeWithEndKeyArgs) => Promise<IGenerateSignUpTree>;
|
|
44
80
|
/**
|
|
45
81
|
* Get the poll joining circuit events from a state file
|
|
46
82
|
* @param maciContract - The MACI contract
|
|
@@ -48,5 +84,5 @@ export declare const getPollJoiningCircuitInputsFromStateFile: ({ stateFile, pol
|
|
|
48
84
|
* @param signer - The signer
|
|
49
85
|
* @returns The poll joining circuit events
|
|
50
86
|
*/
|
|
51
|
-
export declare const getPollJoiningCircuitEvents: ({ maciContract, stateIndex, pollId,
|
|
87
|
+
export declare const getPollJoiningCircuitEvents: ({ maciContract, stateIndex, pollId, userMaciPrivateKey, signer, startBlock, endBlock, blocksPerBatch, }: IGetPollJoiningCircuitEventsArgs) => Promise<TCircuitInputs>;
|
|
52
88
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/user/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../ts/user/utils.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;;;;GASG;AACH,eAAO,MAAM,oBAAoB,GAC/B,gBAAgB,kBAAkB,EAClC,gBAAgB,MAAM,EACtB,gBAAgB,UAAU,EAC1B,eAAe,SAAS,EACxB,QAAQ,MAAM,KACb,cAiCF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wCAAwC,GAAU,wDAK5D,6CAA6C,KAAG,OAAO,CAAC,cAAc,CAwBxE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAU,cAAc,IAAI,EAAE,aAAa,MAAM,KAAG,OAAO,CAAC,MAAM,CAMvG,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAU,wEAMzC,0BAA0B,KAAG,OAAO,CAAC,mBAAmB,CAc1D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,GAAU,uFAOnD,oCAAoC,KAAG,OAAO,CAAC,mBAAmB,CAcpE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GAAU,yGAS/C,gCAAgC,KAAG,OAAO,CAAC,cAAc,CAkC3D,CAAC"}
|
package/build/ts/user/utils.js
CHANGED
|
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPollJoiningCircuitEvents = exports.getPollJoiningCircuitInputsFromStateFile = exports.joiningCircuitInputs = exports.getStateIndex = exports.parseSignupEvents = exports.parsePollJoinEvents = void 0;
|
|
6
|
+
exports.getPollJoiningCircuitEvents = exports.generateMaciStateTreeWithEndKey = exports.generateMaciStateTree = exports.getFirstSignUpBlockNumber = exports.getPollJoiningCircuitInputsFromStateFile = exports.joiningCircuitInputs = exports.getStateIndex = exports.parseSignupEvents = exports.hasUserJoinedPoll = exports.getJoinedUserData = exports.parsePollJoinEvents = void 0;
|
|
7
|
+
const typechain_types_1 = require("@maci-protocol/contracts/typechain-types");
|
|
7
8
|
const core_1 = require("@maci-protocol/core");
|
|
8
9
|
const crypto_1 = require("@maci-protocol/crypto");
|
|
9
10
|
const domainobjs_1 = require("@maci-protocol/domainobjs");
|
|
10
11
|
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
const
|
|
12
|
+
const stateTree_1 = require("../trees/stateTree");
|
|
12
13
|
const constants_1 = require("../utils/constants");
|
|
13
14
|
/**
|
|
14
15
|
* Parse the poll joining events from the Poll contract
|
|
@@ -16,13 +17,13 @@ const constants_1 = require("../utils/constants");
|
|
|
16
17
|
const parsePollJoinEvents = async ({ pollContract, startBlock, currentBlock, pollPublicKey, }) => {
|
|
17
18
|
for (let block = startBlock; block <= currentBlock; block += constants_1.BLOCKS_STEP) {
|
|
18
19
|
const toBlock = Math.min(block + constants_1.BLOCKS_STEP - 1, currentBlock);
|
|
19
|
-
const
|
|
20
|
+
const publicKey = pollPublicKey.asArray();
|
|
20
21
|
// eslint-disable-next-line no-await-in-loop
|
|
21
|
-
const newEvents = await pollContract.queryFilter(pollContract.filters.PollJoined(
|
|
22
|
+
const newEvents = await pollContract.queryFilter(pollContract.filters.PollJoined(publicKey[0], publicKey[1], undefined, undefined, undefined), block, toBlock);
|
|
22
23
|
if (newEvents.length > 0) {
|
|
23
24
|
const [event] = newEvents;
|
|
24
25
|
return {
|
|
25
|
-
pollStateIndex: event.args[
|
|
26
|
+
pollStateIndex: event.args[4].toString(),
|
|
26
27
|
voiceCredits: event.args[2].toString(),
|
|
27
28
|
};
|
|
28
29
|
}
|
|
@@ -33,6 +34,43 @@ const parsePollJoinEvents = async ({ pollContract, startBlock, currentBlock, pol
|
|
|
33
34
|
};
|
|
34
35
|
};
|
|
35
36
|
exports.parsePollJoinEvents = parsePollJoinEvents;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if user is joined to a poll with their public key and get its data
|
|
39
|
+
* @param {IJoinedUserArgs} - The arguments for the join check command
|
|
40
|
+
* @returns user joined or not and poll state index, voice credit balance
|
|
41
|
+
*/
|
|
42
|
+
const getJoinedUserData = async ({ maciAddress, pollId, pollPublicKey: serializedPollPublicKey, signer, startBlock, }) => {
|
|
43
|
+
const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
|
|
44
|
+
const pollContracts = await maciContract.getPoll(pollId);
|
|
45
|
+
const pollContract = typechain_types_1.Poll__factory.connect(pollContracts.poll, signer);
|
|
46
|
+
const pollPublicKey = domainobjs_1.PublicKey.deserialize(serializedPollPublicKey);
|
|
47
|
+
const startBlockNumber = startBlock || 0;
|
|
48
|
+
const currentBlock = await signer.provider.getBlockNumber();
|
|
49
|
+
const { pollStateIndex, voiceCredits } = await (0, exports.parsePollJoinEvents)({
|
|
50
|
+
pollContract,
|
|
51
|
+
startBlock: startBlockNumber,
|
|
52
|
+
currentBlock,
|
|
53
|
+
pollPublicKey,
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
isJoined: pollStateIndex !== undefined,
|
|
57
|
+
pollStateIndex,
|
|
58
|
+
voiceCredits,
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
exports.getJoinedUserData = getJoinedUserData;
|
|
62
|
+
/**
|
|
63
|
+
* Checks if a user joined a poll with a given nullifier
|
|
64
|
+
* @param {IIsNullifierOnChainArgs} args - The arguments for the is nullifier on chain command
|
|
65
|
+
* @returns whether the nullifier is on chain or not
|
|
66
|
+
*/
|
|
67
|
+
const hasUserJoinedPoll = async ({ maciAddress, pollId, nullifier, signer, }) => {
|
|
68
|
+
const maciContract = typechain_types_1.MACI__factory.connect(maciAddress, signer);
|
|
69
|
+
const pollContracts = await maciContract.getPoll(pollId);
|
|
70
|
+
const pollContract = typechain_types_1.Poll__factory.connect(pollContracts.poll, signer);
|
|
71
|
+
return pollContract.pollNullifiers(nullifier);
|
|
72
|
+
};
|
|
73
|
+
exports.hasUserJoinedPoll = hasUserJoinedPoll;
|
|
36
74
|
/**
|
|
37
75
|
* Parse the signup events from the MACI contract
|
|
38
76
|
*/
|
|
@@ -40,7 +78,7 @@ const parseSignupEvents = async ({ maciContract, startBlock, currentBlock, publi
|
|
|
40
78
|
for (let block = startBlock; block <= currentBlock; block += constants_1.BLOCKS_STEP) {
|
|
41
79
|
const toBlock = Math.min(block + constants_1.BLOCKS_STEP - 1, currentBlock);
|
|
42
80
|
// eslint-disable-next-line no-await-in-loop
|
|
43
|
-
const newEvents = await maciContract.queryFilter(maciContract.filters.SignUp(undefined, undefined, publicKey.
|
|
81
|
+
const newEvents = await maciContract.queryFilter(maciContract.filters.SignUp(undefined, undefined, publicKey.raw[0], publicKey.raw[1]), block, toBlock);
|
|
44
82
|
if (newEvents.length > 0) {
|
|
45
83
|
const [event] = newEvents;
|
|
46
84
|
return {
|
|
@@ -55,14 +93,14 @@ const parseSignupEvents = async ({ maciContract, startBlock, currentBlock, publi
|
|
|
55
93
|
exports.parseSignupEvents = parseSignupEvents;
|
|
56
94
|
/**
|
|
57
95
|
* Get state index from maci state leaves or from sign up leaves
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
96
|
+
* @param publicKeys Public keys from maci state or sign up tree
|
|
97
|
+
* @param userMaciPublicKey Public key of the maci user
|
|
60
98
|
* @param stateIndex State index from the command
|
|
61
99
|
* @returns State index
|
|
62
100
|
*/
|
|
63
|
-
const getStateIndex = (
|
|
101
|
+
const getStateIndex = (publicKeys, userMaciPublicKey, stateIndex) => {
|
|
64
102
|
if (!stateIndex) {
|
|
65
|
-
const index =
|
|
103
|
+
const index = publicKeys.findIndex((key) => key.equals(userMaciPublicKey));
|
|
66
104
|
if (index > 0) {
|
|
67
105
|
return BigInt(index);
|
|
68
106
|
}
|
|
@@ -75,45 +113,33 @@ exports.getStateIndex = getStateIndex;
|
|
|
75
113
|
* Create circuit input for pollJoining
|
|
76
114
|
* @param signUpData Sign up tree and state leaves
|
|
77
115
|
* @param stateTreeDepth Maci state tree depth
|
|
78
|
-
* @param
|
|
79
|
-
* @param
|
|
80
|
-
* @param
|
|
81
|
-
* @param pollPubKey Poll's public key for the poll joining
|
|
116
|
+
* @param maciPrivateKey User's private key for signing up
|
|
117
|
+
* @param pollPrivateKey Poll's private key for the poll joining
|
|
118
|
+
* @param pollPublicKey Poll's public key for the poll joining
|
|
82
119
|
* @param pollId Poll's id
|
|
83
120
|
* @returns stringified circuit inputs
|
|
84
121
|
*/
|
|
85
|
-
const joiningCircuitInputs = (
|
|
86
|
-
// Get the state leaf on the index position
|
|
87
|
-
const { signUpTree: stateTree } = signUpData;
|
|
122
|
+
const joiningCircuitInputs = (inclusionProof, stateTreeDepth, maciPrivateKey, pollPublicKey, pollId) => {
|
|
88
123
|
// calculate the path elements for the state tree given the original state tree
|
|
89
|
-
const { siblings, index } =
|
|
124
|
+
const { siblings, index, root: stateRoot } = inclusionProof;
|
|
90
125
|
const siblingsLength = siblings.length;
|
|
91
|
-
// The index must be converted to a list of indices, 1 for each tree level.
|
|
92
|
-
// The circuit tree depth is this.stateTreeDepth, so the number of siblings must be this.stateTreeDepth,
|
|
93
|
-
// even if the tree depth is actually 3. The missing siblings can be set to 0, as they
|
|
94
|
-
// won't be used to calculate the root in the circuit.
|
|
95
|
-
const indices = [];
|
|
96
126
|
for (let i = 0; i < stateTreeDepth; i += 1) {
|
|
97
|
-
// eslint-disable-next-line no-bitwise
|
|
98
|
-
indices.push(BigInt((index >> i) & 1));
|
|
99
127
|
if (i >= siblingsLength) {
|
|
100
128
|
siblings[i] = BigInt(0);
|
|
101
129
|
}
|
|
102
130
|
}
|
|
103
131
|
const siblingsArray = siblings.map((sibling) => [sibling]);
|
|
104
132
|
// Create nullifier from private key
|
|
105
|
-
const inputNullifier = BigInt(
|
|
133
|
+
const inputNullifier = BigInt(maciPrivateKey.asCircuitInputs());
|
|
106
134
|
const nullifier = (0, crypto_1.poseidon)([inputNullifier, pollId]);
|
|
107
|
-
// Get pll state tree's root
|
|
108
|
-
const stateRoot = stateTree.root;
|
|
109
135
|
// Set actualStateTreeDepth as number of initial siblings length
|
|
110
136
|
const actualStateTreeDepth = BigInt(siblingsLength);
|
|
111
137
|
// Calculate public input hash from nullifier, credits and current root
|
|
112
138
|
const circuitInputs = {
|
|
113
|
-
|
|
114
|
-
|
|
139
|
+
privateKey: maciPrivateKey.asCircuitInputs(),
|
|
140
|
+
pollPublicKey: pollPublicKey.asCircuitInputs(),
|
|
115
141
|
siblings: siblingsArray,
|
|
116
|
-
|
|
142
|
+
index: BigInt(index),
|
|
117
143
|
nullifier,
|
|
118
144
|
stateRoot,
|
|
119
145
|
actualStateTreeDepth,
|
|
@@ -127,26 +153,77 @@ exports.joiningCircuitInputs = joiningCircuitInputs;
|
|
|
127
153
|
* @param stateFile - The path to the state file
|
|
128
154
|
* @returns The poll joining circuit inputs
|
|
129
155
|
*/
|
|
130
|
-
const getPollJoiningCircuitInputsFromStateFile = async ({ stateFile, pollId, stateIndex,
|
|
156
|
+
const getPollJoiningCircuitInputsFromStateFile = async ({ stateFile, pollId, stateIndex, userMaciPrivateKey, }) => {
|
|
131
157
|
const file = await fs_1.default.promises.readFile(stateFile);
|
|
132
158
|
const content = JSON.parse(file.toString());
|
|
133
159
|
const maciState = core_1.MaciState.fromJSON(content);
|
|
134
160
|
const poll = maciState.polls.get(pollId);
|
|
135
|
-
const {
|
|
136
|
-
const loadedStateIndex = (0, exports.getStateIndex)(maciState.
|
|
161
|
+
const { publicKey: userPublicKey } = new domainobjs_1.Keypair(userMaciPrivateKey);
|
|
162
|
+
const loadedStateIndex = (0, exports.getStateIndex)(maciState.publicKeys, userPublicKey, stateIndex);
|
|
137
163
|
// check < 1 cause index zero is a blank state leaf
|
|
138
164
|
if (loadedStateIndex < 1) {
|
|
139
165
|
throw new Error("Invalid state index");
|
|
140
166
|
}
|
|
141
|
-
poll.updatePoll(BigInt(maciState.
|
|
167
|
+
poll.updatePoll(BigInt(maciState.publicKeys.length));
|
|
142
168
|
const circuitInputs = poll.joiningCircuitInputs({
|
|
143
|
-
|
|
169
|
+
maciPrivateKey: userMaciPrivateKey,
|
|
144
170
|
stateLeafIndex: stateIndex,
|
|
145
|
-
|
|
171
|
+
pollPublicKey: userPublicKey,
|
|
146
172
|
});
|
|
147
173
|
return circuitInputs;
|
|
148
174
|
};
|
|
149
175
|
exports.getPollJoiningCircuitInputsFromStateFile = getPollJoiningCircuitInputsFromStateFile;
|
|
176
|
+
/**
|
|
177
|
+
* Get the block number when the first SignUp event was emitted
|
|
178
|
+
* @param maciContract - The MACI contract to fetch events from
|
|
179
|
+
* @param startBlock - The block number to start searching from (optional)
|
|
180
|
+
* @returns The block number when the first SignUp event was emitted
|
|
181
|
+
*/
|
|
182
|
+
const getFirstSignUpBlockNumber = async (maciContract, startBlock) => {
|
|
183
|
+
if (startBlock) {
|
|
184
|
+
return startBlock;
|
|
185
|
+
}
|
|
186
|
+
return maciContract.queryFilter(maciContract.filters.SignUp(), 0).then((events) => events[0]?.blockNumber ?? 0);
|
|
187
|
+
};
|
|
188
|
+
exports.getFirstSignUpBlockNumber = getFirstSignUpBlockNumber;
|
|
189
|
+
/**
|
|
190
|
+
* Generate MACI's state tree from the MACI contract
|
|
191
|
+
* @param {IGenerateMaciStateTreeArgs} args - The arguments for the generate maci state tree command
|
|
192
|
+
* @returns The MACI's state tree
|
|
193
|
+
*/
|
|
194
|
+
const generateMaciStateTree = async ({ maciContractAddress, signer, startBlock, endBlock, blocksPerBatch, }) => {
|
|
195
|
+
const maciContract = typechain_types_1.MACI__factory.connect(maciContractAddress, signer);
|
|
196
|
+
// build an off-chain representation of the MACI contract using data in the contract storage
|
|
197
|
+
const fromBlock = await (0, exports.getFirstSignUpBlockNumber)(maciContract, startBlock);
|
|
198
|
+
return (0, stateTree_1.generateSignUpTree)({
|
|
199
|
+
provider: signer.provider,
|
|
200
|
+
address: await maciContract.getAddress(),
|
|
201
|
+
blocksPerRequest: blocksPerBatch || 50,
|
|
202
|
+
fromBlock,
|
|
203
|
+
endBlock,
|
|
204
|
+
sleepAmount: 0,
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
exports.generateMaciStateTree = generateMaciStateTree;
|
|
208
|
+
/**
|
|
209
|
+
* Generate MACI's state tree from the MACI contract with a given end key
|
|
210
|
+
* @param {IGenerateMaciStateTreeWithEndKeyArgs} args - The arguments for the generate maci state tree command
|
|
211
|
+
* @returns The MACI's state tree
|
|
212
|
+
*/
|
|
213
|
+
const generateMaciStateTreeWithEndKey = async ({ maciContractAddress, signer, startBlock, endBlock, blocksPerBatch, userPublicKey, }) => {
|
|
214
|
+
const maciContract = typechain_types_1.MACI__factory.connect(maciContractAddress, signer);
|
|
215
|
+
// build an off-chain representation of the MACI contract using data in the contract storage
|
|
216
|
+
const fromBlock = await (0, exports.getFirstSignUpBlockNumber)(maciContract, startBlock);
|
|
217
|
+
return (0, stateTree_1.generateSignUpTreeWithEndKey)({
|
|
218
|
+
provider: signer.provider,
|
|
219
|
+
address: await maciContract.getAddress(),
|
|
220
|
+
blocksPerRequest: blocksPerBatch || 50,
|
|
221
|
+
fromBlock,
|
|
222
|
+
endBlock,
|
|
223
|
+
userPublicKey,
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
exports.generateMaciStateTreeWithEndKey = generateMaciStateTreeWithEndKey;
|
|
150
227
|
/**
|
|
151
228
|
* Get the poll joining circuit events from a state file
|
|
152
229
|
* @param maciContract - The MACI contract
|
|
@@ -154,33 +231,28 @@ exports.getPollJoiningCircuitInputsFromStateFile = getPollJoiningCircuitInputsFr
|
|
|
154
231
|
* @param signer - The signer
|
|
155
232
|
* @returns The poll joining circuit events
|
|
156
233
|
*/
|
|
157
|
-
const getPollJoiningCircuitEvents = async ({ maciContract, stateIndex, pollId,
|
|
158
|
-
|
|
159
|
-
const [defaultStartBlockSignup, defaultStartBlockPoll, stateTreeDepth] = await Promise.all([
|
|
160
|
-
maciContract
|
|
161
|
-
.queryFilter(maciContract.filters.SignUp(), startBlock ?? 0)
|
|
162
|
-
.then((events) => events[0]?.blockNumber ?? 0),
|
|
163
|
-
maciContract
|
|
164
|
-
.queryFilter(maciContract.filters.DeployPoll(), startBlock ?? 0)
|
|
165
|
-
.then((events) => events[0]?.blockNumber ?? 0),
|
|
234
|
+
const getPollJoiningCircuitEvents = async ({ maciContract, stateIndex, pollId, userMaciPrivateKey, signer, startBlock, endBlock, blocksPerBatch, }) => {
|
|
235
|
+
const [stateTreeDepth, maciContractAddress] = await Promise.all([
|
|
166
236
|
maciContract.stateTreeDepth(),
|
|
237
|
+
maciContract.getAddress(),
|
|
167
238
|
]);
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
address: await maciContract.getAddress(),
|
|
173
|
-
blocksPerRequest: blocksPerBatch || 50,
|
|
174
|
-
fromBlock,
|
|
239
|
+
const signUpData = await (0, exports.generateMaciStateTree)({
|
|
240
|
+
maciContractAddress,
|
|
241
|
+
signer,
|
|
242
|
+
startBlock,
|
|
175
243
|
endBlock,
|
|
176
|
-
|
|
244
|
+
blocksPerBatch,
|
|
177
245
|
});
|
|
178
|
-
const {
|
|
179
|
-
const loadedStateIndex = (0, exports.getStateIndex)(signUpData.
|
|
246
|
+
const { publicKey: userPublicKey } = new domainobjs_1.Keypair(userMaciPrivateKey);
|
|
247
|
+
const loadedStateIndex = (0, exports.getStateIndex)(signUpData.publicKeys, userPublicKey, stateIndex);
|
|
180
248
|
if (loadedStateIndex < 1) {
|
|
181
249
|
throw new Error("Invalid state index");
|
|
182
250
|
}
|
|
183
|
-
|
|
251
|
+
// Get the state leaf on the index position
|
|
252
|
+
const { signUpTree: stateTree } = signUpData;
|
|
253
|
+
// calculate the path elements for the state tree given the original state tree
|
|
254
|
+
const inclusionProof = stateTree.generateProof(Number(loadedStateIndex));
|
|
255
|
+
return (0, exports.joiningCircuitInputs)(inclusionProof, stateTreeDepth, userMaciPrivateKey, userPublicKey, pollId);
|
|
184
256
|
};
|
|
185
257
|
exports.getPollJoiningCircuitEvents = getPollJoiningCircuitEvents;
|
|
186
258
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/user/utils.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../ts/user/utils.ts"],"names":[],"mappings":";;;;;;AAAA,8EAIkD;AAClD,8CAAqE;AACrE,kDAAmE;AACnE,0DAAgF;AAEhF,4CAAoB;AAgBpB,kDAAsF;AACtF,kDAAiD;AAEjD;;GAEG;AACI,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,aAAa,GACY,EAGxB,EAAE;IACH,KAAK,IAAI,KAAK,GAAG,UAAU,EAAE,KAAK,IAAI,YAAY,EAAE,KAAK,IAAI,uBAAW,EAAE,CAAC;QACzE,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,uBAAW,GAAG,CAAC,EAAE,YAAY,CAAC,CAAC;QAChE,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,EAAE,CAAC;QAC1C,4CAA4C;QAC5C,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,WAAW,CAC9C,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,EAC5F,KAAK,EACL,OAAO,CACR,CAAC;QAEF,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;YAE1B,OAAO;gBACL,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;gBACxC,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;aACvC,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,cAAc,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C,CAAC;IAED,2CAA2C;IAC3C,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC;IAE7C,+EAA+E;IAC/E,MAAM,cAAc,GAAG,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEzE,OAAO,IAAA,4BAAoB,EACzB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,MAAM,CACsB,CAAC;AACjC,CAAC,CAAC;AA3CW,QAAA,2BAA2B,+BA2CtC"}
|
|
@@ -6,7 +6,7 @@ export { fundWallet } from "./fundWallet";
|
|
|
6
6
|
export { validateParams } from "./params";
|
|
7
7
|
export { timeTravel } from "./timeTravel";
|
|
8
8
|
export { calculateBinaryTreeDepthFromMaxLeaves, calculateQuinTreeDepthFromMaxLeaves } from "./trees";
|
|
9
|
-
export { isArm, sleep } from "./utils";
|
|
9
|
+
export { isArm, sleep, sleepUntil } from "./utils";
|
|
10
10
|
export { generateAndVerifyProof } from "./proofs";
|
|
11
11
|
export type { ICircuitParams, ISnarkJSVerificationKey, ITimeTravelArgs, IFundWalletArgs } from "./types";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,qCAAqC,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AACrG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../ts/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,qCAAqC,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AACrG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,YAAY,EAAE,cAAc,EAAE,uBAAuB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
|
package/build/ts/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateAndVerifyProof = exports.sleep = exports.isArm = exports.calculateQuinTreeDepthFromMaxLeaves = exports.calculateBinaryTreeDepthFromMaxLeaves = exports.timeTravel = exports.validateParams = exports.fundWallet = exports.asHex = exports.currentBlockTimestamp = exports.contractExists = exports.BLOCKS_STEP = exports.createCidFromObject = exports.cidToBytes32 = void 0;
|
|
3
|
+
exports.generateAndVerifyProof = exports.sleepUntil = exports.sleep = exports.isArm = exports.calculateQuinTreeDepthFromMaxLeaves = exports.calculateBinaryTreeDepthFromMaxLeaves = exports.timeTravel = exports.validateParams = exports.fundWallet = exports.asHex = exports.currentBlockTimestamp = exports.contractExists = exports.BLOCKS_STEP = exports.createCidFromObject = exports.cidToBytes32 = void 0;
|
|
4
4
|
var cid_1 = require("./cid");
|
|
5
5
|
Object.defineProperty(exports, "cidToBytes32", { enumerable: true, get: function () { return cid_1.cidToBytes32; } });
|
|
6
6
|
Object.defineProperty(exports, "createCidFromObject", { enumerable: true, get: function () { return cid_1.createCidFromObject; } });
|
|
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "calculateQuinTreeDepthFromMaxLeaves", { enumerab
|
|
|
23
23
|
var utils_1 = require("./utils");
|
|
24
24
|
Object.defineProperty(exports, "isArm", { enumerable: true, get: function () { return utils_1.isArm; } });
|
|
25
25
|
Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return utils_1.sleep; } });
|
|
26
|
+
Object.defineProperty(exports, "sleepUntil", { enumerable: true, get: function () { return utils_1.sleepUntil; } });
|
|
26
27
|
var proofs_1 = require("./proofs");
|
|
27
28
|
Object.defineProperty(exports, "generateAndVerifyProof", { enumerable: true, get: function () { return proofs_1.generateAndVerifyProof; } });
|
|
28
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/utils/index.ts"],"names":[],"mappings":";;;AAAA,6BAA0D;AAAjD,mGAAA,YAAY,OAAA;AAAE,0GAAA,mBAAmB,OAAA;AAC1C,yCAA0C;AAAjC,wGAAA,WAAW,OAAA;AACpB,yCAAoE;AAA3D,2GAAA,cAAc,OAAA;AAAE,kHAAA,qBAAqB,OAAA;AAC9C,2CAAqC;AAA5B,mGAAA,KAAK,OAAA;AACd,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AACvB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,iCAAqG;AAA5F,8HAAA,qCAAqC,OAAA;AAAE,4HAAA,mCAAmC,OAAA;AACnF,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/utils/index.ts"],"names":[],"mappings":";;;AAAA,6BAA0D;AAAjD,mGAAA,YAAY,OAAA;AAAE,0GAAA,mBAAmB,OAAA;AAC1C,yCAA0C;AAAjC,wGAAA,WAAW,OAAA;AACpB,yCAAoE;AAA3D,2GAAA,cAAc,OAAA;AAAE,kHAAA,qBAAqB,OAAA;AAC9C,2CAAqC;AAA5B,mGAAA,KAAK,OAAA;AACd,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AACvB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,iCAAqG;AAA5F,8HAAA,qCAAqC,OAAA;AAAE,4HAAA,mCAAmC,OAAA;AACnF,iCAAmD;AAA1C,8FAAA,KAAK,OAAA;AAAE,8FAAA,KAAK,OAAA;AAAE,mGAAA,UAAU,OAAA;AACjC,mCAAkD;AAAzC,gHAAA,sBAAsB,OAAA"}
|
|
@@ -3,5 +3,5 @@ import type { ICircuitParams } from "./types";
|
|
|
3
3
|
* Validate the circuit parameters
|
|
4
4
|
* @param params - The circuit parameters
|
|
5
5
|
*/
|
|
6
|
-
export declare const validateParams: ({ stateTreeDepth,
|
|
6
|
+
export declare const validateParams: ({ stateTreeDepth, tallyProcessingStateTreeDepth, voteOptionTreeDepth, messageBatchSize, }: ICircuitParams) => boolean;
|
|
7
7
|
//# sourceMappingURL=params.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../ts/utils/params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../ts/utils/params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,2FAK5B,cAAc,KAAG,OAWnB,CAAC"}
|
package/build/ts/utils/params.js
CHANGED
|
@@ -5,12 +5,12 @@ exports.validateParams = void 0;
|
|
|
5
5
|
* Validate the circuit parameters
|
|
6
6
|
* @param params - The circuit parameters
|
|
7
7
|
*/
|
|
8
|
-
const validateParams = ({ stateTreeDepth,
|
|
8
|
+
const validateParams = ({ stateTreeDepth, tallyProcessingStateTreeDepth, voteOptionTreeDepth, messageBatchSize, }) => {
|
|
9
9
|
// validate args
|
|
10
|
-
if (stateTreeDepth < 1 ||
|
|
10
|
+
if (stateTreeDepth < 1 || tallyProcessingStateTreeDepth < 1 || voteOptionTreeDepth < 1 || messageBatchSize < 1) {
|
|
11
11
|
throw new Error("Invalid depth or batch size parameters");
|
|
12
12
|
}
|
|
13
|
-
if (stateTreeDepth <
|
|
13
|
+
if (stateTreeDepth < tallyProcessingStateTreeDepth) {
|
|
14
14
|
throw new Error("Invalid state tree depth or intermediate state tree depth");
|
|
15
15
|
}
|
|
16
16
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.js","sourceRoot":"","sources":["../../../ts/utils/params.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACI,MAAM,cAAc,GAAG,CAAC,EAC7B,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"params.js","sourceRoot":"","sources":["../../../ts/utils/params.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACI,MAAM,cAAc,GAAG,CAAC,EAC7B,cAAc,EACd,6BAA6B,EAC7B,mBAAmB,EACnB,gBAAgB,GACD,EAAW,EAAE;IAC5B,gBAAgB;IAChB,IAAI,cAAc,GAAG,CAAC,IAAI,6BAA6B,GAAG,CAAC,IAAI,mBAAmB,GAAG,CAAC,IAAI,gBAAgB,GAAG,CAAC,EAAE,CAAC;QAC/G,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,cAAc,GAAG,6BAA6B,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAhBW,QAAA,cAAc,kBAgBzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TCircuitInputs } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Generate and verify poll proof
|
|
4
4
|
* @param inputs - the inputs to the circuit
|
|
@@ -9,5 +9,5 @@ import type { CircuitInputs } from "./types";
|
|
|
9
9
|
* @param wasmPath - the path to the wasm witness
|
|
10
10
|
* @returns proof - an array of strings
|
|
11
11
|
*/
|
|
12
|
-
export declare const generateAndVerifyProof: (inputs:
|
|
12
|
+
export declare const generateAndVerifyProof: (inputs: TCircuitInputs, zkeyPath: string, useWasm: boolean | undefined, rapidsnarkExePath: string | undefined, witnessExePath: string | undefined, wasmPath: string | undefined) => Promise<string[]>;
|
|
13
13
|
//# sourceMappingURL=proofs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proofs.d.ts","sourceRoot":"","sources":["../../../ts/utils/proofs.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"proofs.d.ts","sourceRoot":"","sources":["../../../ts/utils/proofs.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,cAAc,EACtB,UAAU,MAAM,EAChB,SAAS,OAAO,GAAG,SAAS,EAC5B,mBAAmB,MAAM,GAAG,SAAS,EACrC,gBAAgB,MAAM,GAAG,SAAS,EAClC,UAAU,MAAM,GAAG,SAAS,KAC3B,OAAO,CAAC,MAAM,EAAE,CA4BlB,CAAC"}
|
package/build/ts/utils/proofs.js
CHANGED
|
@@ -14,16 +14,16 @@ const contracts_1 = require("@maci-protocol/contracts");
|
|
|
14
14
|
*/
|
|
15
15
|
const generateAndVerifyProof = async (inputs, zkeyPath, useWasm, rapidsnarkExePath, witnessExePath, wasmPath) => {
|
|
16
16
|
let r;
|
|
17
|
-
const
|
|
17
|
+
const verifyingKey = await (0, contracts_1.extractVerifyingKey)(zkeyPath);
|
|
18
18
|
if (useWasm === true || useWasm === undefined) {
|
|
19
|
-
r = await (0, contracts_1.
|
|
19
|
+
r = await (0, contracts_1.generateProofSnarkjs)({
|
|
20
20
|
inputs,
|
|
21
21
|
zkeyPath,
|
|
22
22
|
wasmPath,
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
|
-
r = await (0, contracts_1.
|
|
26
|
+
r = await (0, contracts_1.generateProofRapidSnark)({
|
|
27
27
|
inputs,
|
|
28
28
|
zkeyPath,
|
|
29
29
|
rapidsnarkExePath,
|
|
@@ -31,7 +31,7 @@ const generateAndVerifyProof = async (inputs, zkeyPath, useWasm, rapidsnarkExePa
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
// verify it
|
|
34
|
-
const isValid = await (0, contracts_1.verifyProof)(r.publicSignals, r.proof,
|
|
34
|
+
const isValid = await (0, contracts_1.verifyProof)(r.publicSignals, r.proof, verifyingKey);
|
|
35
35
|
if (!isValid) {
|
|
36
36
|
throw new Error("Generated an invalid proof");
|
|
37
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proofs.js","sourceRoot":"","sources":["../../../ts/utils/proofs.ts"],"names":[],"mappings":";;;AAAA,wDAOkC;AAIlC;;;;;;;;;GASG;AACI,MAAM,sBAAsB,GAAG,KAAK,EACzC,
|
|
1
|
+
{"version":3,"file":"proofs.js","sourceRoot":"","sources":["../../../ts/utils/proofs.ts"],"names":[],"mappings":";;;AAAA,wDAOkC;AAIlC;;;;;;;;;GASG;AACI,MAAM,sBAAsB,GAAG,KAAK,EACzC,MAAsB,EACtB,QAAgB,EAChB,OAA4B,EAC5B,iBAAqC,EACrC,cAAkC,EAClC,QAA4B,EACT,EAAE;IACrB,IAAI,CAAkB,CAAC;IAEvB,MAAM,YAAY,GAAG,MAAM,IAAA,+BAAmB,EAAC,QAAQ,CAAC,CAAC;IAEzD,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC9C,CAAC,GAAG,MAAM,IAAA,gCAAoB,EAAC;YAC7B,MAAM;YACN,QAAQ;YACR,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,CAAC,GAAG,MAAM,IAAA,mCAAuB,EAAC;YAChC,MAAM;YACN,QAAQ;YACR,iBAAiB;YACjB,cAAc;SACf,CAAC,CAAC;IACL,CAAC;IAED,YAAY;IACZ,MAAM,OAAO,GAAG,MAAM,IAAA,uBAAW,EAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAE1E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,IAAA,0CAA8B,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC,CAAC;AAnCW,QAAA,sBAAsB,0BAmCjC"}
|
|
@@ -2,7 +2,7 @@ import type { BigNumberish, Signer } from "ethers";
|
|
|
2
2
|
/**
|
|
3
3
|
* A circuit inputs for the circom circuit
|
|
4
4
|
*/
|
|
5
|
-
export type
|
|
5
|
+
export type TCircuitInputs = Record<string, string | bigint | bigint[] | bigint[][] | string[] | bigint[][][]>;
|
|
6
6
|
/**
|
|
7
7
|
* Circuit parameters
|
|
8
8
|
*/
|
|
@@ -14,7 +14,7 @@ export interface ICircuitParams {
|
|
|
14
14
|
/**
|
|
15
15
|
* The intermediate state tree depth (ballot tree)
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
tallyProcessingStateTreeDepth: number;
|
|
18
18
|
/**
|
|
19
19
|
* The vote option tree depth
|
|
20
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../ts/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;AAE/G;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,6BAA6B,EAAE,MAAM,CAAC;IACtC;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,SAAS,EAAE,YAAY,EAAE,EAAE,CAAC;IAC5B,UAAU,EAAE,YAAY,EAAE,EAAE,CAAC;IAC7B,UAAU,EAAE,YAAY,EAAE,EAAE,CAAC;IAC7B,eAAe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