@semaphore-protocol/group 4.0.0-beta.7 → 4.0.0-beta.9

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/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module @semaphore-protocol/group
3
- * @version 4.0.0-beta.7
3
+ * @version 4.0.0-beta.9
4
4
  * @file A library to create and manage Semaphore groups.
5
5
  * @copyright Ethereum Foundation 2024
6
6
  * @license MIT
@@ -129,6 +129,11 @@ class Group {
129
129
  * @param members A list of identity commitments.
130
130
  */
131
131
  constructor(members = []) {
132
+ for (const member of members) {
133
+ if (member === 0n || member === "0") {
134
+ throw new Error("Failed to add member: value cannot be 0");
135
+ }
136
+ }
132
137
  this.leanIMT = new imt.LeanIMT((a, b) => poseidon2_2([a, b]), members.map(BigInt));
133
138
  }
134
139
  /**
@@ -234,9 +239,9 @@ class Group {
234
239
  * @param nodes The stringified JSON of the group.
235
240
  * @returns The {@link Group} instance.
236
241
  */
237
- static import(exportedGroup) {
242
+ static import(nodes) {
238
243
  const group = new Group();
239
- group.leanIMT.import(exportedGroup);
244
+ group.leanIMT.import(nodes);
240
245
  return group;
241
246
  }
242
247
  }
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module @semaphore-protocol/group
3
- * @version 4.0.0-beta.7
3
+ * @version 4.0.0-beta.9
4
4
  * @file A library to create and manage Semaphore groups.
5
5
  * @copyright Ethereum Foundation 2024
6
6
  * @license MIT
@@ -127,6 +127,11 @@ class Group {
127
127
  * @param members A list of identity commitments.
128
128
  */
129
129
  constructor(members = []) {
130
+ for (const member of members) {
131
+ if (member === 0n || member === "0") {
132
+ throw new Error("Failed to add member: value cannot be 0");
133
+ }
134
+ }
130
135
  this.leanIMT = new LeanIMT((a, b) => poseidon2_2([a, b]), members.map(BigInt));
131
136
  }
132
137
  /**
@@ -232,9 +237,9 @@ class Group {
232
237
  * @param nodes The stringified JSON of the group.
233
238
  * @returns The {@link Group} instance.
234
239
  */
235
- static import(exportedGroup) {
240
+ static import(nodes) {
236
241
  const group = new Group();
237
- group.leanIMT.import(exportedGroup);
242
+ group.leanIMT.import(nodes);
238
243
  return group;
239
244
  }
240
245
  }
@@ -86,6 +86,6 @@ export declare class Group {
86
86
  * @param nodes The stringified JSON of the group.
87
87
  * @returns The {@link Group} instance.
88
88
  */
89
- static import(exportedGroup: string): Group;
89
+ static import(nodes: string): Group;
90
90
  }
91
91
  export { LeanIMTMerkleProof as MerkleProof };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semaphore-protocol/group",
3
- "version": "4.0.0-beta.7",
3
+ "version": "4.0.0-beta.9",
4
4
  "description": "A library to create and manage Semaphore groups.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -23,6 +23,12 @@ export class Group {
23
23
  * @param members A list of identity commitments.
24
24
  */
25
25
  constructor(members: BigNumber[] = []) {
26
+ for (const member of members) {
27
+ if (member === 0n || member === "0") {
28
+ throw new Error("Failed to add member: value cannot be 0")
29
+ }
30
+ }
31
+
26
32
  this.leanIMT = new LeanIMT((a, b) => poseidon2([a, b]), members.map(BigInt))
27
33
  }
28
34
 
@@ -144,10 +150,10 @@ export class Group {
144
150
  * @param nodes The stringified JSON of the group.
145
151
  * @returns The {@link Group} instance.
146
152
  */
147
- static import(exportedGroup: string): Group {
153
+ static import(nodes: string): Group {
148
154
  const group = new Group()
149
155
 
150
- group.leanIMT.import(exportedGroup)
156
+ group.leanIMT.import(nodes)
151
157
 
152
158
  return group
153
159
  }