@semaphore-protocol/group 4.0.0-alpha.3 → 4.0.0-alpha.5

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,6 +1,6 @@
1
1
  /**
2
2
  * @module @semaphore-protocol/group
3
- * @version 4.0.0-alpha.3
3
+ * @version 4.0.0-alpha.5
4
4
  * @file A library to create and manage Semaphore groups.
5
5
  * @copyright Ethereum Foundation 2024
6
6
  * @license MIT
@@ -8,10 +8,12 @@
8
8
  */
9
9
  'use strict';
10
10
 
11
- Object.defineProperty(exports, '__esModule', { value: true });
12
-
13
11
  var imt = require('@zk-kit/imt');
14
12
 
13
+ function getDefaultExportFromCjs (x) {
14
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
15
+ }
16
+
15
17
  var poseidon2$1 = {};
16
18
 
17
19
  const F = BigInt('21888242871839275222246405745257275088548364400416034343698204186575808495617');
@@ -61,6 +63,7 @@ function poseidon(_inputs, opt) {
61
63
  return state[0];
62
64
  }
63
65
  var poseidon_1 = poseidon;
66
+ getDefaultExportFromCjs(poseidon_1);
64
67
 
65
68
  var unstringify = {};
66
69
 
@@ -108,112 +111,112 @@ function poseidon2(inputs) {
108
111
  return (0, _poseidon.default)(inputs, c);
109
112
  }
110
113
 
111
- var Group = /** @class */ (function () {
112
- /**
113
- * Initializes the group with the group id and the tree depth.
114
- * @param members List of group members.
115
- */
116
- function Group(members) {
117
- if (members === void 0) { members = []; }
118
- this.leanIMT = new imt.LeanIMT(function (a, b) { return poseidon2_2([a, b]); }, members.map(BigInt));
119
- }
120
- Object.defineProperty(Group.prototype, "root", {
121
- /**
122
- * Returns the root hash of the tree.
123
- * @returns Root hash.
124
- */
125
- get: function () {
126
- var _a;
127
- return (_a = this.leanIMT.root) === null || _a === void 0 ? void 0 : _a.toString();
128
- },
129
- enumerable: false,
130
- configurable: true
131
- });
132
- Object.defineProperty(Group.prototype, "depth", {
133
- /**
134
- * Returns the depth of the tree.
135
- * @returns Tree depth.
136
- */
137
- get: function () {
138
- return this.leanIMT.depth;
139
- },
140
- enumerable: false,
141
- configurable: true
142
- });
143
- Object.defineProperty(Group.prototype, "size", {
144
- /**
145
- * Returns the size of the tree (i.e. number of leaves).
146
- * @returns Tree depth.
147
- */
148
- get: function () {
149
- return this.leanIMT.size;
150
- },
151
- enumerable: false,
152
- configurable: true
153
- });
154
- Object.defineProperty(Group.prototype, "members", {
155
- /**
156
- * Returns the members (i.e. identity commitments) of the group.
157
- * @returns List of members.
158
- */
159
- get: function () {
160
- return this.leanIMT.leaves.map(String);
161
- },
162
- enumerable: false,
163
- configurable: true
164
- });
165
- /**
166
- * Returns the index of a member. If the member does not exist it returns -1.
167
- * @param member Group member.
168
- * @returns Index of the member.
169
- */
170
- Group.prototype.indexOf = function (member) {
171
- return this.leanIMT.indexOf(BigInt(member));
172
- };
173
- /**
174
- * Adds a new member to the group.
175
- * @param member New member.
176
- */
177
- Group.prototype.addMember = function (member) {
178
- this.leanIMT.insert(BigInt(member));
179
- };
180
- /**
181
- * Adds new members to the group.
182
- * @param members New members.
183
- */
184
- Group.prototype.addMembers = function (members) {
185
- this.leanIMT.insertMany(members.map(BigInt));
186
- };
187
- /**
188
- * Updates a member in the group.
189
- * @param index Index of the member to be updated.
190
- * @param member New member value.
191
- */
192
- Group.prototype.updateMember = function (index, member) {
193
- this.leanIMT.update(index, BigInt(member));
194
- };
195
- /**
196
- * Removes a member from the group.
197
- * @param index Index of the member to be removed.
198
- */
199
- Group.prototype.removeMember = function (index) {
200
- this.leanIMT.update(index, BigInt(0));
201
- };
202
- /**
203
- * Creates a proof of membership.
204
- * @param index Index of the proof's member.
205
- * @returns Proof object.
206
- */
207
- Group.prototype.generateMerkleProof = function (_index) {
208
- var _a = this.leanIMT.generateProof(_index), index = _a.index, leaf = _a.leaf, root = _a.root, siblings = _a.siblings;
209
- return {
210
- index: index,
211
- leaf: leaf.toString(),
212
- root: root.toString(),
213
- siblings: siblings.map(String)
214
- };
215
- };
216
- return Group;
114
+ var Group = /** @class */ (function () {
115
+ /**
116
+ * Initializes the group with the group id and the tree depth.
117
+ * @param members List of group members.
118
+ */
119
+ function Group(members) {
120
+ if (members === void 0) { members = []; }
121
+ this.leanIMT = new imt.LeanIMT(function (a, b) { return poseidon2_2([a, b]); }, members.map(BigInt));
122
+ }
123
+ Object.defineProperty(Group.prototype, "root", {
124
+ /**
125
+ * Returns the root hash of the tree.
126
+ * @returns Root hash.
127
+ */
128
+ get: function () {
129
+ var _a;
130
+ return (_a = this.leanIMT.root) === null || _a === void 0 ? void 0 : _a.toString();
131
+ },
132
+ enumerable: false,
133
+ configurable: true
134
+ });
135
+ Object.defineProperty(Group.prototype, "depth", {
136
+ /**
137
+ * Returns the depth of the tree.
138
+ * @returns Tree depth.
139
+ */
140
+ get: function () {
141
+ return this.leanIMT.depth;
142
+ },
143
+ enumerable: false,
144
+ configurable: true
145
+ });
146
+ Object.defineProperty(Group.prototype, "size", {
147
+ /**
148
+ * Returns the size of the tree (i.e. number of leaves).
149
+ * @returns Tree depth.
150
+ */
151
+ get: function () {
152
+ return this.leanIMT.size;
153
+ },
154
+ enumerable: false,
155
+ configurable: true
156
+ });
157
+ Object.defineProperty(Group.prototype, "members", {
158
+ /**
159
+ * Returns the members (i.e. identity commitments) of the group.
160
+ * @returns List of members.
161
+ */
162
+ get: function () {
163
+ return this.leanIMT.leaves.map(String);
164
+ },
165
+ enumerable: false,
166
+ configurable: true
167
+ });
168
+ /**
169
+ * Returns the index of a member. If the member does not exist it returns -1.
170
+ * @param member Group member.
171
+ * @returns Index of the member.
172
+ */
173
+ Group.prototype.indexOf = function (member) {
174
+ return this.leanIMT.indexOf(BigInt(member));
175
+ };
176
+ /**
177
+ * Adds a new member to the group.
178
+ * @param member New member.
179
+ */
180
+ Group.prototype.addMember = function (member) {
181
+ this.leanIMT.insert(BigInt(member));
182
+ };
183
+ /**
184
+ * Adds new members to the group.
185
+ * @param members New members.
186
+ */
187
+ Group.prototype.addMembers = function (members) {
188
+ this.leanIMT.insertMany(members.map(BigInt));
189
+ };
190
+ /**
191
+ * Updates a member in the group.
192
+ * @param index Index of the member to be updated.
193
+ * @param member New member value.
194
+ */
195
+ Group.prototype.updateMember = function (index, member) {
196
+ this.leanIMT.update(index, BigInt(member));
197
+ };
198
+ /**
199
+ * Removes a member from the group.
200
+ * @param index Index of the member to be removed.
201
+ */
202
+ Group.prototype.removeMember = function (index) {
203
+ this.leanIMT.update(index, BigInt(0));
204
+ };
205
+ /**
206
+ * Creates a proof of membership.
207
+ * @param index Index of the proof's member.
208
+ * @returns Proof object.
209
+ */
210
+ Group.prototype.generateMerkleProof = function (_index) {
211
+ var _a = this.leanIMT.generateProof(_index), index = _a.index, leaf = _a.leaf, root = _a.root, siblings = _a.siblings;
212
+ return {
213
+ index: index,
214
+ leaf: leaf.toString(),
215
+ root: root.toString(),
216
+ siblings: siblings.map(String)
217
+ };
218
+ };
219
+ return Group;
217
220
  }());
218
221
 
219
222
  exports.Group = Group;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module @semaphore-protocol/group
3
- * @version 4.0.0-alpha.3
3
+ * @version 4.0.0-alpha.5
4
4
  * @file A library to create and manage Semaphore groups.
5
5
  * @copyright Ethereum Foundation 2024
6
6
  * @license MIT
@@ -8,6 +8,10 @@
8
8
  */
9
9
  import { LeanIMT } from '@zk-kit/imt';
10
10
 
11
+ function getDefaultExportFromCjs (x) {
12
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
13
+ }
14
+
11
15
  var poseidon2$1 = {};
12
16
 
13
17
  const F = BigInt('21888242871839275222246405745257275088548364400416034343698204186575808495617');
@@ -57,6 +61,7 @@ function poseidon(_inputs, opt) {
57
61
  return state[0];
58
62
  }
59
63
  var poseidon_1 = poseidon;
64
+ getDefaultExportFromCjs(poseidon_1);
60
65
 
61
66
  var unstringify = {};
62
67
 
@@ -104,112 +109,112 @@ function poseidon2(inputs) {
104
109
  return (0, _poseidon.default)(inputs, c);
105
110
  }
106
111
 
107
- var Group = /** @class */ (function () {
108
- /**
109
- * Initializes the group with the group id and the tree depth.
110
- * @param members List of group members.
111
- */
112
- function Group(members) {
113
- if (members === void 0) { members = []; }
114
- this.leanIMT = new LeanIMT(function (a, b) { return poseidon2_2([a, b]); }, members.map(BigInt));
115
- }
116
- Object.defineProperty(Group.prototype, "root", {
117
- /**
118
- * Returns the root hash of the tree.
119
- * @returns Root hash.
120
- */
121
- get: function () {
122
- var _a;
123
- return (_a = this.leanIMT.root) === null || _a === void 0 ? void 0 : _a.toString();
124
- },
125
- enumerable: false,
126
- configurable: true
127
- });
128
- Object.defineProperty(Group.prototype, "depth", {
129
- /**
130
- * Returns the depth of the tree.
131
- * @returns Tree depth.
132
- */
133
- get: function () {
134
- return this.leanIMT.depth;
135
- },
136
- enumerable: false,
137
- configurable: true
138
- });
139
- Object.defineProperty(Group.prototype, "size", {
140
- /**
141
- * Returns the size of the tree (i.e. number of leaves).
142
- * @returns Tree depth.
143
- */
144
- get: function () {
145
- return this.leanIMT.size;
146
- },
147
- enumerable: false,
148
- configurable: true
149
- });
150
- Object.defineProperty(Group.prototype, "members", {
151
- /**
152
- * Returns the members (i.e. identity commitments) of the group.
153
- * @returns List of members.
154
- */
155
- get: function () {
156
- return this.leanIMT.leaves.map(String);
157
- },
158
- enumerable: false,
159
- configurable: true
160
- });
161
- /**
162
- * Returns the index of a member. If the member does not exist it returns -1.
163
- * @param member Group member.
164
- * @returns Index of the member.
165
- */
166
- Group.prototype.indexOf = function (member) {
167
- return this.leanIMT.indexOf(BigInt(member));
168
- };
169
- /**
170
- * Adds a new member to the group.
171
- * @param member New member.
172
- */
173
- Group.prototype.addMember = function (member) {
174
- this.leanIMT.insert(BigInt(member));
175
- };
176
- /**
177
- * Adds new members to the group.
178
- * @param members New members.
179
- */
180
- Group.prototype.addMembers = function (members) {
181
- this.leanIMT.insertMany(members.map(BigInt));
182
- };
183
- /**
184
- * Updates a member in the group.
185
- * @param index Index of the member to be updated.
186
- * @param member New member value.
187
- */
188
- Group.prototype.updateMember = function (index, member) {
189
- this.leanIMT.update(index, BigInt(member));
190
- };
191
- /**
192
- * Removes a member from the group.
193
- * @param index Index of the member to be removed.
194
- */
195
- Group.prototype.removeMember = function (index) {
196
- this.leanIMT.update(index, BigInt(0));
197
- };
198
- /**
199
- * Creates a proof of membership.
200
- * @param index Index of the proof's member.
201
- * @returns Proof object.
202
- */
203
- Group.prototype.generateMerkleProof = function (_index) {
204
- var _a = this.leanIMT.generateProof(_index), index = _a.index, leaf = _a.leaf, root = _a.root, siblings = _a.siblings;
205
- return {
206
- index: index,
207
- leaf: leaf.toString(),
208
- root: root.toString(),
209
- siblings: siblings.map(String)
210
- };
211
- };
212
- return Group;
112
+ var Group = /** @class */ (function () {
113
+ /**
114
+ * Initializes the group with the group id and the tree depth.
115
+ * @param members List of group members.
116
+ */
117
+ function Group(members) {
118
+ if (members === void 0) { members = []; }
119
+ this.leanIMT = new LeanIMT(function (a, b) { return poseidon2_2([a, b]); }, members.map(BigInt));
120
+ }
121
+ Object.defineProperty(Group.prototype, "root", {
122
+ /**
123
+ * Returns the root hash of the tree.
124
+ * @returns Root hash.
125
+ */
126
+ get: function () {
127
+ var _a;
128
+ return (_a = this.leanIMT.root) === null || _a === void 0 ? void 0 : _a.toString();
129
+ },
130
+ enumerable: false,
131
+ configurable: true
132
+ });
133
+ Object.defineProperty(Group.prototype, "depth", {
134
+ /**
135
+ * Returns the depth of the tree.
136
+ * @returns Tree depth.
137
+ */
138
+ get: function () {
139
+ return this.leanIMT.depth;
140
+ },
141
+ enumerable: false,
142
+ configurable: true
143
+ });
144
+ Object.defineProperty(Group.prototype, "size", {
145
+ /**
146
+ * Returns the size of the tree (i.e. number of leaves).
147
+ * @returns Tree depth.
148
+ */
149
+ get: function () {
150
+ return this.leanIMT.size;
151
+ },
152
+ enumerable: false,
153
+ configurable: true
154
+ });
155
+ Object.defineProperty(Group.prototype, "members", {
156
+ /**
157
+ * Returns the members (i.e. identity commitments) of the group.
158
+ * @returns List of members.
159
+ */
160
+ get: function () {
161
+ return this.leanIMT.leaves.map(String);
162
+ },
163
+ enumerable: false,
164
+ configurable: true
165
+ });
166
+ /**
167
+ * Returns the index of a member. If the member does not exist it returns -1.
168
+ * @param member Group member.
169
+ * @returns Index of the member.
170
+ */
171
+ Group.prototype.indexOf = function (member) {
172
+ return this.leanIMT.indexOf(BigInt(member));
173
+ };
174
+ /**
175
+ * Adds a new member to the group.
176
+ * @param member New member.
177
+ */
178
+ Group.prototype.addMember = function (member) {
179
+ this.leanIMT.insert(BigInt(member));
180
+ };
181
+ /**
182
+ * Adds new members to the group.
183
+ * @param members New members.
184
+ */
185
+ Group.prototype.addMembers = function (members) {
186
+ this.leanIMT.insertMany(members.map(BigInt));
187
+ };
188
+ /**
189
+ * Updates a member in the group.
190
+ * @param index Index of the member to be updated.
191
+ * @param member New member value.
192
+ */
193
+ Group.prototype.updateMember = function (index, member) {
194
+ this.leanIMT.update(index, BigInt(member));
195
+ };
196
+ /**
197
+ * Removes a member from the group.
198
+ * @param index Index of the member to be removed.
199
+ */
200
+ Group.prototype.removeMember = function (index) {
201
+ this.leanIMT.update(index, BigInt(0));
202
+ };
203
+ /**
204
+ * Creates a proof of membership.
205
+ * @param index Index of the proof's member.
206
+ * @returns Proof object.
207
+ */
208
+ Group.prototype.generateMerkleProof = function (_index) {
209
+ var _a = this.leanIMT.generateProof(_index), index = _a.index, leaf = _a.leaf, root = _a.root, siblings = _a.siblings;
210
+ return {
211
+ index: index,
212
+ leaf: leaf.toString(),
213
+ root: root.toString(),
214
+ siblings: siblings.map(String)
215
+ };
216
+ };
217
+ return Group;
213
218
  }());
214
219
 
215
220
  export { Group };
@@ -1,63 +1,63 @@
1
- import { LeanIMT } from "@zk-kit/imt";
2
- import { BigNumberish, MerkleProof } from "./types";
3
- export default class Group {
4
- leanIMT: LeanIMT;
5
- /**
6
- * Initializes the group with the group id and the tree depth.
7
- * @param members List of group members.
8
- */
9
- constructor(members?: BigNumberish[]);
10
- /**
11
- * Returns the root hash of the tree.
12
- * @returns Root hash.
13
- */
14
- get root(): string | undefined;
15
- /**
16
- * Returns the depth of the tree.
17
- * @returns Tree depth.
18
- */
19
- get depth(): number;
20
- /**
21
- * Returns the size of the tree (i.e. number of leaves).
22
- * @returns Tree depth.
23
- */
24
- get size(): number;
25
- /**
26
- * Returns the members (i.e. identity commitments) of the group.
27
- * @returns List of members.
28
- */
29
- get members(): string[];
30
- /**
31
- * Returns the index of a member. If the member does not exist it returns -1.
32
- * @param member Group member.
33
- * @returns Index of the member.
34
- */
35
- indexOf(member: BigNumberish): number;
36
- /**
37
- * Adds a new member to the group.
38
- * @param member New member.
39
- */
40
- addMember(member: BigNumberish): void;
41
- /**
42
- * Adds new members to the group.
43
- * @param members New members.
44
- */
45
- addMembers(members: BigNumberish[]): void;
46
- /**
47
- * Updates a member in the group.
48
- * @param index Index of the member to be updated.
49
- * @param member New member value.
50
- */
51
- updateMember(index: number, member: BigNumberish): void;
52
- /**
53
- * Removes a member from the group.
54
- * @param index Index of the member to be removed.
55
- */
56
- removeMember(index: number): void;
57
- /**
58
- * Creates a proof of membership.
59
- * @param index Index of the proof's member.
60
- * @returns Proof object.
61
- */
62
- generateMerkleProof(_index: number): MerkleProof;
63
- }
1
+ import { LeanIMT } from "@zk-kit/imt";
2
+ import { BigNumberish, MerkleProof } from "./types";
3
+ export default class Group {
4
+ leanIMT: LeanIMT;
5
+ /**
6
+ * Initializes the group with the group id and the tree depth.
7
+ * @param members List of group members.
8
+ */
9
+ constructor(members?: BigNumberish[]);
10
+ /**
11
+ * Returns the root hash of the tree.
12
+ * @returns Root hash.
13
+ */
14
+ get root(): string | undefined;
15
+ /**
16
+ * Returns the depth of the tree.
17
+ * @returns Tree depth.
18
+ */
19
+ get depth(): number;
20
+ /**
21
+ * Returns the size of the tree (i.e. number of leaves).
22
+ * @returns Tree depth.
23
+ */
24
+ get size(): number;
25
+ /**
26
+ * Returns the members (i.e. identity commitments) of the group.
27
+ * @returns List of members.
28
+ */
29
+ get members(): string[];
30
+ /**
31
+ * Returns the index of a member. If the member does not exist it returns -1.
32
+ * @param member Group member.
33
+ * @returns Index of the member.
34
+ */
35
+ indexOf(member: BigNumberish): number;
36
+ /**
37
+ * Adds a new member to the group.
38
+ * @param member New member.
39
+ */
40
+ addMember(member: BigNumberish): void;
41
+ /**
42
+ * Adds new members to the group.
43
+ * @param members New members.
44
+ */
45
+ addMembers(members: BigNumberish[]): void;
46
+ /**
47
+ * Updates a member in the group.
48
+ * @param index Index of the member to be updated.
49
+ * @param member New member value.
50
+ */
51
+ updateMember(index: number, member: BigNumberish): void;
52
+ /**
53
+ * Removes a member from the group.
54
+ * @param index Index of the member to be removed.
55
+ */
56
+ removeMember(index: number): void;
57
+ /**
58
+ * Creates a proof of membership.
59
+ * @param index Index of the proof's member.
60
+ * @returns Proof object.
61
+ */
62
+ generateMerkleProof(_index: number): MerkleProof;
63
+ }
@@ -1,3 +1,3 @@
1
- import Group from "./group";
2
- export { Group };
3
- export * from "./types";
1
+ import Group from "./group";
2
+ export { Group };
3
+ export * from "./types";
@@ -1,3 +1,3 @@
1
- import { LeanIMTMerkleProof } from "@zk-kit/imt";
2
- export type BigNumberish = string | number | bigint;
3
- export type MerkleProof = LeanIMTMerkleProof<string>;
1
+ import { LeanIMTMerkleProof } from "@zk-kit/imt";
2
+ export type BigNumberish = string | number | bigint;
3
+ export type MerkleProof = LeanIMTMerkleProof<string>;
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@semaphore-protocol/group",
3
- "version": "4.0.0-alpha.3",
3
+ "version": "4.0.0-alpha.5",
4
4
  "description": "A library to create and manage Semaphore groups.",
5
+ "type": "module",
5
6
  "license": "MIT",
6
- "main": "dist/index.node.js",
7
+ "main": "dist/index.js",
8
+ "types": "dist/types/index.d.ts",
7
9
  "exports": {
8
- "import": "./dist/index.mjs",
9
- "require": "./dist/index.node.js",
10
- "types": "./dist/types/index.d.ts"
10
+ "types": "./dist/types/index.d.ts",
11
+ "require": "./dist/index.cjs",
12
+ "default": "./dist/index.js"
11
13
  },
12
- "types": "dist/types/index.d.ts",
13
14
  "files": [
14
15
  "dist/",
15
16
  "src/",
@@ -29,11 +30,11 @@
29
30
  "access": "public"
30
31
  },
31
32
  "devDependencies": {
32
- "@rollup/plugin-commonjs": "^24.0.1",
33
- "@rollup/plugin-node-resolve": "^15.0.1",
33
+ "@rollup/plugin-commonjs": "^25.0.7",
34
+ "@rollup/plugin-node-resolve": "^15.2.3",
34
35
  "poseidon-lite": "^0.2.0",
35
36
  "rollup-plugin-cleanup": "^3.2.1",
36
- "rollup-plugin-typescript2": "^0.31.2"
37
+ "rollup-plugin-typescript2": "^0.36.0"
37
38
  },
38
39
  "dependencies": {
39
40
  "@zk-kit/imt": "^2.0.0-beta"