@maci-protocol/core 0.0.0-ci.bab2f09 → 0.0.0-ci.c495700

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.
@@ -1,5 +1,5 @@
1
1
  import { IncrementalQuinTree } from "@maci-protocol/crypto";
2
- import { PubKey, type Keypair } from "@maci-protocol/domainobjs";
2
+ import { PublicKey, type Keypair } from "@maci-protocol/domainobjs";
3
3
  import type { IJsonMaciState, IMaciState, TreeDepths } from "./utils/types";
4
4
  import { Poll } from "./Poll";
5
5
  /**
@@ -7,7 +7,7 @@ import { Poll } from "./Poll";
7
7
  */
8
8
  export declare class MaciState implements IMaciState {
9
9
  polls: Map<bigint, Poll>;
10
- pubKeys: PubKey[];
10
+ pubKeys: PublicKey[];
11
11
  stateTreeDepth: number;
12
12
  stateTree?: IncrementalQuinTree;
13
13
  numSignUps: number;
@@ -20,10 +20,10 @@ export declare class MaciState implements IMaciState {
20
20
  constructor(stateTreeDepth: number);
21
21
  /**
22
22
  * Sign up a user with the given public key.
23
- * @param pubKey - The public key of the user.
23
+ * @param publicKey - The public key of the user.
24
24
  * @returns The index of the newly signed-up user in the state tree.
25
25
  */
26
- signUp(pubKey: PubKey): number;
26
+ signUp(publicKey: PublicKey): number;
27
27
  /**
28
28
  * Deploy a new poll with the given parameters.
29
29
  * @param pollEndTimestamp - The Unix timestamp at which the poll ends.
@@ -1 +1 @@
1
- {"version":3,"file":"MaciState.d.ts","sourceRoot":"","sources":["../../ts/MaciState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,KAAK,OAAO,EAAU,MAAM,2BAA2B,CAAC;AAEzE,OAAO,KAAK,EAAE,cAAc,EAAa,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEvF,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B;;GAEG;AACH,qBAA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,CAAC,MAAM,EAAE,IAAI,CAAC,CAA2B;IAGnD,OAAO,EAAE,SAAS,EAAE,CAAM;IAG1B,cAAc,EAAE,MAAM,CAAC;IAGvB,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAEhC,UAAU,SAAK;IAGf,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC;;;OAGG;gBACS,cAAc,EAAE,MAAM;IAUlC;;;;OAIG;IACH,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM;IAOpC;;;;;;;;OAQG;IACH,UAAU,CACR,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,MAAM,EACxB,kBAAkB,EAAE,OAAO,EAC3B,WAAW,EAAE,MAAM,GAClB,MAAM;IAiBT;;OAEG;IACH,cAAc,IAAI,IAAI;IAItB;;;OAGG;IACH,IAAI,QAAO,SAAS,CAQlB;IAEF;;;;OAIG;IACH,MAAM,GAAI,GAAG,SAAS,KAAG,OAAO,CAsB9B;IAEF;;;OAGG;IACH,MAAM,IAAI,cAAc;IAWxB;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS;CAgBjD"}
@@ -61,13 +61,13 @@ class MaciState {
61
61
  }
62
62
  /**
63
63
  * Sign up a user with the given public key.
64
- * @param pubKey - The public key of the user.
64
+ * @param publicKey - The public key of the user.
65
65
  * @returns The index of the newly signed-up user in the state tree.
66
66
  */
67
- signUp(pubKey) {
67
+ signUp(publicKey) {
68
68
  this.numSignUps += 1;
69
- this.stateTree?.insert(pubKey.hash());
70
- return this.pubKeys.push(pubKey.copy()) - 1;
69
+ this.stateTree?.insert(publicKey.hash());
70
+ return this.pubKeys.push(publicKey.copy()) - 1;
71
71
  }
72
72
  /**
73
73
  * Deploy a new poll with the given parameters.
@@ -100,7 +100,7 @@ class MaciState {
100
100
  return {
101
101
  stateTreeDepth: this.stateTreeDepth,
102
102
  polls: Array.from(this.polls.values()).map((poll) => poll.toJSON()),
103
- pubKeys: this.pubKeys.map((pubKey) => pubKey.toJSON()),
103
+ pubKeys: this.pubKeys.map((publicKey) => publicKey.toJSON()),
104
104
  pollBeingProcessed: Boolean(this.pollBeingProcessed),
105
105
  currentPollBeingProcessed: this.currentPollBeingProcessed ? this.currentPollBeingProcessed.toString() : "",
106
106
  numSignUps: this.numSignUps,
@@ -114,7 +114,7 @@ class MaciState {
114
114
  static fromJSON(json) {
115
115
  const maciState = new MaciState(json.stateTreeDepth);
116
116
  // assign the json values to the new instance
117
- maciState.pubKeys = json.pubKeys.map((pubKey) => domainobjs_1.PubKey.fromJSON(pubKey));
117
+ maciState.pubKeys = json.pubKeys.map((publicKey) => domainobjs_1.PublicKey.fromJSON(publicKey));
118
118
  maciState.pollBeingProcessed = json.pollBeingProcessed;
119
119
  maciState.currentPollBeingProcessed = BigInt(json.currentPollBeingProcessed);
120
120
  maciState.numSignUps = json.numSignUps;
@@ -1 +1 @@
1
- {"version":3,"file":"MaciState.js","sourceRoot":"","sources":["../../ts/MaciState.ts"],"names":[],"mappings":";;;AACA,0DAAyE;AAIzE,iCAA8B;AAC9B,iDAAqD;AAErD;;GAEG;AACH,MAAa,SAAS;IAoBpB;;;OAGG;IACH,YAAY,cAAsB;QAvBlC,sCAAsC;QACtC,UAAK,GAAsB,IAAI,GAAG,EAAgB,CAAC;QAEnD,+BAA+B;QAC/B,YAAO,GAAa,EAAE,CAAC;QAQvB,eAAU,GAAG,CAAC,CAAC;QAwEf;;;WAGG;QACH,SAAI,GAAG,GAAc,EAAE;YACrB,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAElD,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAE3D,MAAM,CAAC,KAAK,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QAAQ,CAAC,IAAoB;QAClC,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAErD,6CAA6C;QAC7C,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,sBAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;QACnF,SAAS,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC;QACvD,SAAS,CAAC,yBAAyB,GAAG,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QAC7E,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAEvC,yDAAyD;QACzD,SAAS,CAAC,KAAK,GAAG,IAAI,GAAG,CACvB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAmB,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,WAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CACpG,CAAC;QAEF,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AApKD,8BAoKC"}
@@ -1,5 +1,5 @@
1
1
  import { IncrementalQuinTree } from "@maci-protocol/crypto";
2
- import { PCommand, Keypair, Ballot, PubKey, Message, StateLeaf } from "@maci-protocol/domainobjs";
2
+ import { PCommand, Keypair, Ballot, PublicKey, Message, StateLeaf } from "@maci-protocol/domainobjs";
3
3
  import { LeanIMT } from "@zk-kit/lean-imt";
4
4
  import type { TreeDepths, BatchSizes, IPoll, IJsonPoll, IProcessMessagesOutput, ITallyCircuitInputs, IProcessMessagesCircuitInputs, IPollJoiningCircuitInputs, IJoiningCircuitArgs } from "./index";
5
5
  import type { MaciState } from "./MaciState";
@@ -13,16 +13,15 @@ export declare class Poll implements IPoll {
13
13
  batchSizes: BatchSizes;
14
14
  voteOptions: bigint;
15
15
  maxVoteOptions: number;
16
- stateTreeDepth: number;
17
16
  actualStateTreeDepth: number;
18
17
  pollEndTimestamp: bigint;
19
18
  ballots: Ballot[];
20
19
  ballotTree?: IncrementalQuinTree;
21
20
  messages: Message[];
22
21
  commands: PCommand[];
23
- encPubKeys: PubKey[];
22
+ encryptionPublicKeys: PublicKey[];
24
23
  stateCopied: boolean;
25
- pubKeys: PubKey[];
24
+ pubKeys: PublicKey[];
26
25
  stateTree?: LeanIMT;
27
26
  numBatchesProcessed: number;
28
27
  currentMessageBatchIndex: number;
@@ -61,12 +60,11 @@ export declare class Poll implements IPoll {
61
60
  /**
62
61
  * Join the anonymous user to the Poll (to the tree)
63
62
  * @param nullifier - Hashed private key used as nullifier
64
- * @param pubKey - The poll public key.
63
+ * @param publicKey - The poll public key.
65
64
  * @param newVoiceCreditBalance - New voice credit balance of the user.
66
- * @param timestamp - The timestamp of the sign-up.
67
65
  * @returns The index of added state leaf
68
66
  */
69
- joinPoll: (nullifier: bigint, pubKey: PubKey, newVoiceCreditBalance: bigint, timestamp: bigint) => number;
67
+ joinPoll: (nullifier: bigint, publicKey: PublicKey, newVoiceCreditBalance: bigint) => number;
70
68
  /**
71
69
  * Update a Poll with data from MaciState.
72
70
  * This is the step where we copy the state from the MaciState instance,
@@ -79,20 +77,20 @@ export declare class Poll implements IPoll {
79
77
  /**
80
78
  * Process one message.
81
79
  * @param message - The message to process.
82
- * @param encPubKey - The public key associated with the encryption private key.
80
+ * @param encryptionPublicKey - The public key associated with the encryption private key.
83
81
  * @returns A number of variables which will be used in the zk-SNARK circuit.
84
82
  */
85
- processMessage: (message: Message, encPubKey: PubKey, qv?: boolean) => IProcessMessagesOutput;
83
+ processMessage: (message: Message, encryptionPublicKey: PublicKey, qv?: boolean) => IProcessMessagesOutput;
86
84
  /**
87
85
  * Inserts a Message and the corresponding public key used to generate the
88
86
  * ECDH shared key which was used to encrypt said message.
89
87
  * @param message - The message to insert
90
- * @param encPubKey - The public key used to encrypt the message
88
+ * @param encryptionPublicKey - The public key used to encrypt the message
91
89
  */
92
- publishMessage: (message: Message, encPubKey: PubKey) => void;
90
+ publishMessage: (message: Message, encryptionPublicKey: PublicKey) => void;
93
91
  /**
94
92
  * Updates message chain hash
95
- * @param messageHash hash of message with encPubKey
93
+ * @param messageHash hash of message with encryptionPublicKey
96
94
  */
97
95
  updateChainHash: (messageHash: bigint) => void;
98
96
  /**
@@ -100,13 +98,13 @@ export declare class Poll implements IPoll {
100
98
  * @param args Poll joining circuit inputs
101
99
  * @returns stringified circuit inputs
102
100
  */
103
- joiningCircuitInputs: ({ maciPrivKey, stateLeafIndex, pollPubKey, }: IJoiningCircuitArgs) => IPollJoiningCircuitInputs;
101
+ joiningCircuitInputs: ({ maciPrivateKey, stateLeafIndex, pollPublicKey, }: IJoiningCircuitArgs) => IPollJoiningCircuitInputs;
104
102
  /**
105
103
  * Create circuit input for pollJoined
106
104
  * @param args Poll joined circuit inputs
107
105
  * @returns stringified circuit inputs
108
106
  */
109
- joinedCircuitInputs: ({ maciPrivKey, stateLeafIndex, voiceCreditsBalance, joinTimestamp, }: IJoinedCircuitArgs) => IPollJoinedCircuitInputs;
107
+ joinedCircuitInputs: ({ maciPrivateKey, stateLeafIndex, voiceCreditsBalance, }: IJoinedCircuitArgs) => IPollJoinedCircuitInputs;
110
108
  /**
111
109
  * Pad last unclosed batch
112
110
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Poll.d.ts","sourceRoot":"","sources":["../../ts/Poll.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAYpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,EAEN,OAAO,EACP,SAAS,EAMV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO,EAAuB,MAAM,kBAAkB,CAAC;AAIhE,OAAO,KAAK,EAEV,UAAU,EACV,UAAU,EACV,KAAK,EACL,SAAS,EACT,sBAAsB,EACtB,mBAAmB,EACnB,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B,GAAI,0DAIpB,kBAAkB,KAAG,wBAAwB,CAuB9C;IAEF;;OAEG;IACH,YAAY,QAAO,IAAI,CAIrB;IAEF;;;;OAIG;IACH,sBAAsB,QAAO,OAAO,CAUlC;IAEF;;;;;;;;;;;;;OAaG;IACH,eAAe,GAAI,QAAQ,MAAM,EAAE,YAAS,EAAE,eAAY,KAAG,6BAA6B,CAsQxF;IAEF;;;;OAIG;IACH,OAAO,CAAC,sCAAsC,CAkF5C;IAEF;;;;;OAKG;IACH,kBAAkB,QAAO;QAAE,WAAW,EAAE,SAAS,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAUtE;IAEF;;;OAGG;IACH,mBAAmB,QAAO,OAAO,CAAkF;IAEnH;;;OAGG;IACH,UAAU,QAAO,mBAAmB,CA0KlC;IAEF,eAAe,QAAO,mBAAmB,CAoIvC;IAEF;;;;;;;;OAQG;IACH,OAAO,CAAC,qCAAqC,CAiB3C;IAEF;;;;;;;;OAQG;IACH,OAAO,CAAC,mCAAmC,CAoBzC;IAEF;;;OAGG;IACH,IAAI,QAAO,IAAI,CA+Db;IAEF;;;;OAIG;IACH,MAAM,GAAI,GAAG,IAAI,KAAG,OAAO,CA2BzB;IAEF;;;OAGG;IACH,MAAM,IAAI,SAAS;IAwBnB;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;IA6B5D;;;OAGG;IACH,qBAAqB,GAAI,sBAAsB,MAAM,KAAG,IAAI,CAE1D;IAEF;;;OAGG;IACH,aAAa,GAAI,YAAY,MAAM,KAAG,IAAI,CAExC;IAEF;;;OAGG;IACH,aAAa,QAAO,MAAM,CAAoB;CAC/C"}
package/build/ts/Poll.js CHANGED
@@ -27,7 +27,7 @@ class Poll {
27
27
  this.ballots = [];
28
28
  this.messages = [];
29
29
  this.commands = [];
30
- this.encPubKeys = [];
30
+ this.encryptionPublicKeys = [];
31
31
  this.stateCopied = false;
32
32
  this.pubKeys = [domainobjs_1.padKey];
33
33
  // For message processing
@@ -56,13 +56,12 @@ class Poll {
56
56
  /**
57
57
  * Join the anonymous user to the Poll (to the tree)
58
58
  * @param nullifier - Hashed private key used as nullifier
59
- * @param pubKey - The poll public key.
59
+ * @param publicKey - The poll public key.
60
60
  * @param newVoiceCreditBalance - New voice credit balance of the user.
61
- * @param timestamp - The timestamp of the sign-up.
62
61
  * @returns The index of added state leaf
63
62
  */
64
- this.joinPoll = (nullifier, pubKey, newVoiceCreditBalance, timestamp) => {
65
- const stateLeaf = new domainobjs_1.StateLeaf(pubKey, newVoiceCreditBalance, timestamp);
63
+ this.joinPoll = (nullifier, publicKey, newVoiceCreditBalance) => {
64
+ const stateLeaf = new domainobjs_1.StateLeaf(publicKey, newVoiceCreditBalance);
66
65
  if (this.hasJoined(nullifier)) {
67
66
  throw new Error("UserAlreadyJoined");
68
67
  }
@@ -94,8 +93,8 @@ class Poll {
94
93
  this.actualStateTreeDepth = Math.max(1, Math.ceil(Math.log2(Number(this.numSignups))));
95
94
  this.stateTree = new lean_imt_1.LeanIMT(crypto_1.hashLeanIMT);
96
95
  // add all leaves
97
- this.pubKeys.forEach((pubKey) => {
98
- this.stateTree?.insert(pubKey.hash());
96
+ this.pubKeys.forEach((publicKey) => {
97
+ this.stateTree?.insert(publicKey.hash());
99
98
  });
100
99
  // create a poll state tree
101
100
  this.pollStateTree = new crypto_1.IncrementalQuinTree(this.actualStateTreeDepth, domainobjs_1.blankStateLeafHash, constants_1.STATE_TREE_ARITY, crypto_1.hash2);
@@ -104,7 +103,7 @@ class Poll {
104
103
  });
105
104
  // Create as many ballots as state leaves
106
105
  this.emptyBallotHash = this.emptyBallot.hash();
107
- this.ballotTree = new crypto_1.IncrementalQuinTree(this.stateTreeDepth, this.emptyBallotHash, constants_1.STATE_TREE_ARITY, crypto_1.hash2);
106
+ this.ballotTree = new crypto_1.IncrementalQuinTree(Number(this.treeDepths.stateTreeDepth), this.emptyBallotHash, constants_1.STATE_TREE_ARITY, crypto_1.hash2);
108
107
  this.ballotTree.insert(this.emptyBallotHash);
109
108
  // we fill the ballotTree with empty ballots hashes to match the number of signups in the tree
110
109
  while (this.ballots.length < this.pubKeys.length) {
@@ -116,13 +115,13 @@ class Poll {
116
115
  /**
117
116
  * Process one message.
118
117
  * @param message - The message to process.
119
- * @param encPubKey - The public key associated with the encryption private key.
118
+ * @param encryptionPublicKey - The public key associated with the encryption private key.
120
119
  * @returns A number of variables which will be used in the zk-SNARK circuit.
121
120
  */
122
- this.processMessage = (message, encPubKey, qv = true) => {
121
+ this.processMessage = (message, encryptionPublicKey, qv = true) => {
123
122
  try {
124
123
  // Decrypt the message
125
- const sharedKey = domainobjs_1.Keypair.genEcdhSharedKey(this.coordinatorKeypair.privKey, encPubKey);
124
+ const sharedKey = domainobjs_1.Keypair.genEcdhSharedKey(this.coordinatorKeypair.privateKey, encryptionPublicKey);
126
125
  const { command, signature } = domainobjs_1.PCommand.decrypt(message, sharedKey);
127
126
  const stateLeafIndex = command.stateIndex;
128
127
  // If the state tree index in the command is invalid, do nothing
@@ -136,7 +135,7 @@ class Poll {
136
135
  // The ballot to update (or not)
137
136
  const ballot = this.ballots[Number(stateLeafIndex)];
138
137
  // If the signature is invalid, do nothing
139
- if (!command.verifySignature(signature, stateLeaf.pubKey)) {
138
+ if (!command.verifySignature(signature, stateLeaf.publicKey)) {
140
139
  throw new errors_1.ProcessMessageError(errors_1.ProcessMessageErrors.InvalidSignature);
141
140
  }
142
141
  // If the nonce is invalid, do nothing
@@ -171,7 +170,7 @@ class Poll {
171
170
  const newStateLeaf = stateLeaf.copy();
172
171
  newStateLeaf.voiceCreditBalance = voiceCreditsLeft;
173
172
  // if the key changes, this is effectively a key-change message too
174
- newStateLeaf.pubKey = command.newPubKey.copy();
173
+ newStateLeaf.publicKey = command.newPublicKey.copy();
175
174
  // Deep-copy the ballot and update its attributes
176
175
  const newBallot = ballot.copy();
177
176
  // increase the nonce
@@ -220,24 +219,24 @@ class Poll {
220
219
  * Inserts a Message and the corresponding public key used to generate the
221
220
  * ECDH shared key which was used to encrypt said message.
222
221
  * @param message - The message to insert
223
- * @param encPubKey - The public key used to encrypt the message
222
+ * @param encryptionPublicKey - The public key used to encrypt the message
224
223
  */
225
- this.publishMessage = (message, encPubKey) => {
226
- (0, assert_1.default)(encPubKey.rawPubKey[0] < crypto_1.SNARK_FIELD_SIZE && encPubKey.rawPubKey[1] < crypto_1.SNARK_FIELD_SIZE, "The public key is not in the correct range");
224
+ this.publishMessage = (message, encryptionPublicKey) => {
225
+ (0, assert_1.default)(encryptionPublicKey.rawPubKey[0] < crypto_1.SNARK_FIELD_SIZE && encryptionPublicKey.rawPubKey[1] < crypto_1.SNARK_FIELD_SIZE, "The public key is not in the correct range");
227
226
  message.data.forEach((d) => {
228
227
  (0, assert_1.default)(d < crypto_1.SNARK_FIELD_SIZE, "The message data is not in the correct range");
229
228
  });
230
229
  // store the encryption pub key
231
- this.encPubKeys.push(encPubKey);
230
+ this.encryptionPublicKeys.push(encryptionPublicKey);
232
231
  // store the message locally
233
232
  this.messages.push(message);
234
233
  // add the message hash to the message tree
235
- const messageHash = message.hash(encPubKey);
234
+ const messageHash = message.hash(encryptionPublicKey);
236
235
  // update chain hash
237
236
  this.updateChainHash(messageHash);
238
237
  // Decrypt the message and store the Command
239
238
  // step 1. we generate the shared key
240
- const sharedKey = domainobjs_1.Keypair.genEcdhSharedKey(this.coordinatorKeypair.privKey, encPubKey);
239
+ const sharedKey = domainobjs_1.Keypair.genEcdhSharedKey(this.coordinatorKeypair.privateKey, encryptionPublicKey);
241
240
  try {
242
241
  // step 2. we decrypt it
243
242
  const { command } = domainobjs_1.PCommand.decrypt(message, sharedKey);
@@ -247,13 +246,13 @@ class Poll {
247
246
  catch (e) {
248
247
  // if there is an error we store an empty command
249
248
  const keyPair = new domainobjs_1.Keypair();
250
- const command = new domainobjs_1.PCommand(0n, keyPair.pubKey, 0n, 0n, 0n, 0n, 0n);
249
+ const command = new domainobjs_1.PCommand(0n, keyPair.publicKey, 0n, 0n, 0n, 0n, 0n);
251
250
  this.commands.push(command);
252
251
  }
253
252
  };
254
253
  /**
255
254
  * Updates message chain hash
256
- * @param messageHash hash of message with encPubKey
255
+ * @param messageHash hash of message with encryptionPublicKey
257
256
  */
258
257
  this.updateChainHash = (messageHash) => {
259
258
  this.chainHash = (0, crypto_1.hash2)([this.chainHash, messageHash]);
@@ -267,16 +266,16 @@ class Poll {
267
266
  * @param args Poll joining circuit inputs
268
267
  * @returns stringified circuit inputs
269
268
  */
270
- this.joiningCircuitInputs = ({ maciPrivKey, stateLeafIndex, pollPubKey, }) => {
269
+ this.joiningCircuitInputs = ({ maciPrivateKey, stateLeafIndex, pollPublicKey, }) => {
271
270
  // calculate the path elements for the state tree given the original state tree
272
271
  const { siblings, index } = this.stateTree.generateProof(Number(stateLeafIndex));
273
272
  const siblingsLength = siblings.length;
274
273
  // The index must be converted to a list of indices, 1 for each tree level.
275
- // The circuit tree depth is this.stateTreeDepth, so the number of siblings must be this.stateTreeDepth,
274
+ // The circuit tree depth is this.treeDepths.stateTreeDepth, so the number of siblings must be this.treeDepths.stateTreeDepth,
276
275
  // even if the tree depth is actually 3. The missing siblings can be set to 0, as they
277
276
  // won't be used to calculate the root in the circuit.
278
277
  const indices = [];
279
- for (let i = 0; i < this.stateTreeDepth; i += 1) {
278
+ for (let i = 0; i < this.treeDepths.stateTreeDepth; i += 1) {
280
279
  // eslint-disable-next-line no-bitwise
281
280
  indices.push(BigInt((index >> i) & 1));
282
281
  if (i >= siblingsLength) {
@@ -285,15 +284,15 @@ class Poll {
285
284
  }
286
285
  const siblingsArray = siblings.map((sibling) => [sibling]);
287
286
  // Create nullifier from private key
288
- const inputNullifier = BigInt(maciPrivKey.asCircuitInputs());
287
+ const inputNullifier = BigInt(maciPrivateKey.asCircuitInputs());
289
288
  const nullifier = (0, crypto_1.poseidon)([inputNullifier, this.pollId]);
290
289
  // Get state tree's root
291
290
  const stateRoot = this.stateTree.root;
292
291
  // Set actualStateTreeDepth as number of initial siblings length
293
292
  const actualStateTreeDepth = BigInt(siblingsLength);
294
293
  const circuitInputs = {
295
- privKey: maciPrivKey.asCircuitInputs(),
296
- pollPubKey: pollPubKey.asCircuitInputs(),
294
+ privateKey: maciPrivateKey.asCircuitInputs(),
295
+ pollPublicKey: pollPublicKey.asCircuitInputs(),
297
296
  siblings: siblingsArray,
298
297
  indices,
299
298
  nullifier,
@@ -308,23 +307,20 @@ class Poll {
308
307
  * @param args Poll joined circuit inputs
309
308
  * @returns stringified circuit inputs
310
309
  */
311
- this.joinedCircuitInputs = ({ maciPrivKey, stateLeafIndex, voiceCreditsBalance, joinTimestamp, }) => {
310
+ this.joinedCircuitInputs = ({ maciPrivateKey, stateLeafIndex, voiceCreditsBalance, }) => {
312
311
  // calculate the path elements for the state tree given the original state tree
313
- const { pathElements, pathIndices } = this.pollStateTree.genProof(Number(stateLeafIndex));
314
- // Get poll state tree's root
315
- const stateRoot = this.pollStateTree.root;
312
+ const { root: stateRoot, pathElements, pathIndices } = this.pollStateTree.genProof(Number(stateLeafIndex));
316
313
  const elementsLength = pathIndices.length;
317
- for (let i = 0; i < this.stateTreeDepth; i += 1) {
314
+ for (let i = 0; i < this.treeDepths.stateTreeDepth; i += 1) {
318
315
  if (i >= elementsLength) {
319
316
  pathElements[i] = [0n];
320
317
  pathIndices[i] = 0;
321
318
  }
322
319
  }
323
320
  const circuitInputs = {
324
- privKey: maciPrivKey.asCircuitInputs(),
321
+ privateKey: maciPrivateKey.asCircuitInputs(),
325
322
  pathElements: pathElements.map((item) => item.toString()),
326
323
  voiceCreditsBalance: voiceCreditsBalance.toString(),
327
- joinTimestamp: joinTimestamp.toString(),
328
324
  pathIndices: pathIndices.map((item) => item.toString()),
329
325
  actualStateTreeDepth: BigInt(this.actualStateTreeDepth),
330
326
  stateRoot,
@@ -409,13 +405,13 @@ class Poll {
409
405
  const idx = this.currentMessageBatchIndex * batchSize - i - 1;
410
406
  (0, assert_1.default)(idx >= 0, "The message index must be >= 0");
411
407
  let message;
412
- let encPubKey;
408
+ let encryptionPublicKey;
413
409
  if (idx < this.messages.length) {
414
410
  message = this.messages[idx];
415
- encPubKey = this.encPubKeys[idx];
411
+ encryptionPublicKey = this.encryptionPublicKeys[idx];
416
412
  try {
417
413
  // check if the command is valid
418
- const r = this.processMessage(message, encPubKey, qv);
414
+ const r = this.processMessage(message, encryptionPublicKey, qv);
419
415
  const index = r.stateLeafIndex;
420
416
  // we add at position 0 the original data
421
417
  currentStateLeaves.unshift(r.originalStateLeaf);
@@ -451,7 +447,7 @@ class Poll {
451
447
  // results in a valid state index thus forcing the circuit to look
452
448
  // for a valid state leaf, and failing to generate a proof
453
449
  // gen shared key
454
- const sharedKey = domainobjs_1.Keypair.genEcdhSharedKey(this.coordinatorKeypair.privKey, encPubKey);
450
+ const sharedKey = domainobjs_1.Keypair.genEcdhSharedKey(this.coordinatorKeypair.privateKey, encryptionPublicKey);
455
451
  // force decrypt it
456
452
  const { command } = domainobjs_1.PCommand.decrypt(message, sharedKey, true);
457
453
  // cache state leaf index
@@ -532,7 +528,7 @@ class Poll {
532
528
  // we need to fill the array with 0s to match the length of the state leaves
533
529
  // eslint-disable-next-line @typescript-eslint/prefer-for-of
534
530
  for (let i = 0; i < currentStateLeavesPathElements.length; i += 1) {
535
- while (currentStateLeavesPathElements[i].length < this.stateTreeDepth) {
531
+ while (currentStateLeavesPathElements[i].length < this.treeDepths.stateTreeDepth) {
536
532
  currentStateLeavesPathElements[i].push([0n]);
537
533
  }
538
534
  }
@@ -559,7 +555,7 @@ class Poll {
559
555
  // create a commitment to the state and ballot tree roots
560
556
  // this will be the hash of the roots with a salt
561
557
  circuitInputs.newSbCommitment = (0, crypto_1.hash3)([newStateRoot, newBallotRoot, newSbSalt]);
562
- const coordinatorPublicKeyHash = this.coordinatorKeypair.pubKey.hash();
558
+ const coordinatorPublicKeyHash = this.coordinatorKeypair.publicKey.hash();
563
559
  // If this is the last batch, release the lock
564
560
  if (this.numBatchesProcessed * batchSize >= this.messages.length) {
565
561
  this.maciStateRef.pollBeingProcessed = false;
@@ -579,7 +575,7 @@ class Poll {
579
575
  this.genProcessMessagesCircuitInputsPartial = (index) => {
580
576
  const { messageBatchSize } = this.batchSizes;
581
577
  (0, assert_1.default)(index <= this.messages.length, "The index must be <= the number of messages");
582
- // fill the msgs array with a copy of the messages we have
578
+ // fill the messages array with a copy of the messages we have
583
579
  // plus empty messages to fill the batch
584
580
  // @note create a message with state index 0 to add as padding
585
581
  // this way the message will look for state leaf 0
@@ -587,22 +583,22 @@ class Poll {
587
583
  // create a random key
588
584
  const key = new domainobjs_1.Keypair();
589
585
  // gen ecdh key
590
- const ecdh = domainobjs_1.Keypair.genEcdhSharedKey(key.privKey, this.coordinatorKeypair.pubKey);
586
+ const ecdh = domainobjs_1.Keypair.genEcdhSharedKey(key.privateKey, this.coordinatorKeypair.publicKey);
591
587
  // create an empty command with state index 0n
592
- const emptyCommand = new domainobjs_1.PCommand(0n, key.pubKey, 0n, 0n, 0n, 0n, 0n);
588
+ const emptyCommand = new domainobjs_1.PCommand(0n, key.publicKey, 0n, 0n, 0n, 0n, 0n);
593
589
  // encrypt it
594
- const msg = emptyCommand.encrypt(emptyCommand.sign(key.privKey), ecdh);
590
+ const msg = emptyCommand.encrypt(emptyCommand.sign(key.privateKey), ecdh);
595
591
  // copy the messages to a new array
596
- let msgs = this.messages.map((x) => x.asCircuitInputs());
592
+ let messages = this.messages.map((x) => x.asCircuitInputs());
597
593
  // pad with our state index 0 message
598
- while (msgs.length % messageBatchSize > 0) {
599
- msgs.push(msg.asCircuitInputs());
594
+ while (messages.length % messageBatchSize > 0) {
595
+ messages.push(msg.asCircuitInputs());
600
596
  }
601
597
  // copy the public keys, pad the array with the last keys if needed
602
- let encPubKeys = this.encPubKeys.map((x) => x.copy());
603
- while (encPubKeys.length % messageBatchSize > 0) {
598
+ let encryptionPublicKeys = this.encryptionPublicKeys.map((x) => x.copy());
599
+ while (encryptionPublicKeys.length % messageBatchSize > 0) {
604
600
  // pad with the public key used to encrypt the message with state index 0 (padding)
605
- encPubKeys.push(key.pubKey.copy());
601
+ encryptionPublicKeys.push(key.publicKey.copy());
606
602
  }
607
603
  // validate that the batch index is correct, if not fix it
608
604
  // this means that the end will be the last message
@@ -612,11 +608,11 @@ class Poll {
612
608
  }
613
609
  const batchStartIndex = index > 0 ? (index - 1) * messageBatchSize : 0;
614
610
  // we only take the messages we need for this batch
615
- // it slice msgs array from index of first message in current batch to
611
+ // it slice messages array from index of first message in current batch to
616
612
  // index of last message in current batch
617
- msgs = msgs.slice(batchStartIndex, index * messageBatchSize);
613
+ messages = messages.slice(batchStartIndex, index * messageBatchSize);
618
614
  // then take the ones part of this batch
619
- encPubKeys = encPubKeys.slice(batchStartIndex, index * messageBatchSize);
615
+ encryptionPublicKeys = encryptionPublicKeys.slice(batchStartIndex, index * messageBatchSize);
620
616
  // cache tree roots
621
617
  const currentStateRoot = this.pollStateTree.root;
622
618
  const currentBallotRoot = this.ballotTree.root;
@@ -632,10 +628,10 @@ class Poll {
632
628
  index: BigInt(batchStartIndex),
633
629
  inputBatchHash,
634
630
  outputBatchHash,
635
- msgs,
631
+ messages,
636
632
  actualStateTreeDepth: BigInt(this.actualStateTreeDepth),
637
- coordPrivKey: this.coordinatorKeypair.privKey.asCircuitInputs(),
638
- encPubKeys: encPubKeys.map((x) => x.asCircuitInputs()),
633
+ coordinatorPrivateKey: this.coordinatorKeypair.privateKey.asCircuitInputs(),
634
+ encryptionPublicKeys: encryptionPublicKeys.map((x) => x.asCircuitInputs()),
639
635
  currentStateRoot,
640
636
  currentBallotRoot,
641
637
  currentSbCommitment,
@@ -921,6 +917,7 @@ class Poll {
921
917
  const copied = new Poll(BigInt(this.pollEndTimestamp.toString()), this.coordinatorKeypair.copy(), {
922
918
  intStateTreeDepth: Number(this.treeDepths.intStateTreeDepth),
923
919
  voteOptionTreeDepth: Number(this.treeDepths.voteOptionTreeDepth),
920
+ stateTreeDepth: Number(this.treeDepths.stateTreeDepth),
924
921
  }, {
925
922
  tallyBatchSize: Number(this.batchSizes.tallyBatchSize.toString()),
926
923
  messageBatchSize: Number(this.batchSizes.messageBatchSize.toString()),
@@ -930,7 +927,7 @@ class Poll {
930
927
  copied.messages = this.messages.map((x) => x.copy());
931
928
  copied.commands = this.commands.map((x) => x.copy());
932
929
  copied.ballots = this.ballots.map((x) => x.copy());
933
- copied.encPubKeys = this.encPubKeys.map((x) => x.copy());
930
+ copied.encryptionPublicKeys = this.encryptionPublicKeys.map((x) => x.copy());
934
931
  if (this.ballotTree) {
935
932
  copied.ballotTree = this.ballotTree.copy();
936
933
  }
@@ -975,7 +972,7 @@ class Poll {
975
972
  this.batchSizes.messageBatchSize === p.batchSizes.messageBatchSize &&
976
973
  this.maxVoteOptions === p.maxVoteOptions &&
977
974
  this.messages.length === p.messages.length &&
978
- this.encPubKeys.length === p.encPubKeys.length &&
975
+ this.encryptionPublicKeys.length === p.encryptionPublicKeys.length &&
979
976
  this.numSignups === p.numSignups;
980
977
  if (!result) {
981
978
  return false;
@@ -985,8 +982,8 @@ class Poll {
985
982
  return false;
986
983
  }
987
984
  }
988
- for (let i = 0; i < this.encPubKeys.length; i += 1) {
989
- if (!this.encPubKeys[i].equals(p.encPubKeys[i])) {
985
+ for (let i = 0; i < this.encryptionPublicKeys.length; i += 1) {
986
+ if (!this.encryptionPublicKeys[i].equals(p.encryptionPublicKeys[i])) {
990
987
  return false;
991
988
  }
992
989
  }
@@ -997,7 +994,7 @@ class Poll {
997
994
  * @param serializedPrivateKey - the serialized private key
998
995
  */
999
996
  this.setCoordinatorKeypair = (serializedPrivateKey) => {
1000
- this.coordinatorKeypair = new domainobjs_1.Keypair(domainobjs_1.PrivKey.deserialize(serializedPrivateKey));
997
+ this.coordinatorKeypair = new domainobjs_1.Keypair(domainobjs_1.PrivateKey.deserialize(serializedPrivateKey));
1001
998
  };
1002
999
  /**
1003
1000
  * Set the number of signups to match the ones from the contract
@@ -1022,8 +1019,7 @@ class Poll {
1022
1019
  this.maxVoteOptions = constants_1.VOTE_OPTION_TREE_ARITY ** treeDepths.voteOptionTreeDepth;
1023
1020
  this.maciStateRef = maciStateRef;
1024
1021
  this.pollId = BigInt(maciStateRef.polls.size);
1025
- this.stateTreeDepth = maciStateRef.stateTreeDepth;
1026
- this.actualStateTreeDepth = maciStateRef.stateTreeDepth;
1022
+ this.actualStateTreeDepth = treeDepths.stateTreeDepth;
1027
1023
  this.currentMessageBatchIndex = 0;
1028
1024
  this.pollNullifiers = new Map();
1029
1025
  this.tallyResult = new Array(this.maxVoteOptions).fill(0n);
@@ -1038,6 +1034,7 @@ class Poll {
1038
1034
  */
1039
1035
  toJSON() {
1040
1036
  return {
1037
+ stateTreeDepth: Number(this.treeDepths.stateTreeDepth),
1041
1038
  pollEndTimestamp: this.pollEndTimestamp.toString(),
1042
1039
  treeDepths: this.treeDepths,
1043
1040
  batchSizes: this.batchSizes,
@@ -1046,7 +1043,7 @@ class Poll {
1046
1043
  messages: this.messages.map((message) => message.toJSON()),
1047
1044
  commands: this.commands.map((command) => command.toJSON()),
1048
1045
  ballots: this.ballots.map((ballot) => ballot.toJSON()),
1049
- encPubKeys: this.encPubKeys.map((encPubKey) => encPubKey.serialize()),
1046
+ encryptionPublicKeys: this.encryptionPublicKeys.map((encryptionPublicKey) => encryptionPublicKey.serialize()),
1050
1047
  currentMessageBatchIndex: this.currentMessageBatchIndex,
1051
1048
  pubKeys: this.pubKeys.map((leaf) => leaf.toJSON()),
1052
1049
  pollStateLeaves: this.pollStateLeaves.map((leaf) => leaf.toJSON()),
@@ -1069,7 +1066,7 @@ class Poll {
1069
1066
  // set all properties
1070
1067
  poll.pollStateLeaves = json.pollStateLeaves.map((leaf) => domainobjs_1.StateLeaf.fromJSON(leaf));
1071
1068
  poll.ballots = json.ballots.map((ballot) => domainobjs_1.Ballot.fromJSON(ballot));
1072
- poll.encPubKeys = json.encPubKeys.map((key) => domainobjs_1.PubKey.deserialize(key));
1069
+ poll.encryptionPublicKeys = json.encryptionPublicKeys.map((key) => domainobjs_1.PublicKey.deserialize(key));
1073
1070
  poll.messages = json.messages.map((message) => domainobjs_1.Message.fromJSON(message));
1074
1071
  poll.commands = json.commands.map((command) => domainobjs_1.PCommand.fromJSON(command));
1075
1072
  poll.tallyResult = json.results.map((result) => BigInt(result));