@semaphore-protocol/proof 4.0.0-alpha.4 → 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,20 +1,18 @@
1
1
  /**
2
2
  * @module @semaphore-protocol/proof
3
- * @version 4.0.0-alpha.4
3
+ * @version 4.0.0-alpha.5
4
4
  * @file A library to generate and verify Semaphore proofs.
5
5
  * @copyright Ethereum Foundation 2024
6
6
  * @license MIT
7
7
  * @see [Github]{@link https://github.com/semaphore-protocol/semaphore/tree/main/packages/proof}
8
8
  */
9
- 'use strict';
10
-
11
- var bignumber = require('@ethersproject/bignumber');
12
- var snarkjs = require('snarkjs');
13
- var download = require('download');
14
- var fs = require('fs');
15
- var tmp = require('tmp');
16
- var bytes = require('@ethersproject/bytes');
17
- var keccak256 = require('@ethersproject/keccak256');
9
+ import { BigNumber } from '@ethersproject/bignumber';
10
+ import { groth16 } from 'snarkjs';
11
+ import download from 'download';
12
+ import fs from 'fs';
13
+ import tmp from 'tmp';
14
+ import { zeroPad } from '@ethersproject/bytes';
15
+ import { keccak256 } from '@ethersproject/keccak256';
18
16
 
19
17
  /******************************************************************************
20
18
  Copyright (c) Microsoft Corporation.
@@ -30,7 +28,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
30
28
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
31
29
  PERFORMANCE OF THIS SOFTWARE.
32
30
  ***************************************************************************** */
33
- /* global Reflect, Promise */
31
+ /* global Reflect, Promise, SuppressedError, Symbol */
34
32
 
35
33
 
36
34
  var __assign = function() {
@@ -80,147 +78,152 @@ function __generator(thisArg, body) {
80
78
  } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
81
79
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
82
80
  }
83
- }
81
+ }
82
+
83
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
84
+ var e = new Error(message);
85
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
86
+ };
84
87
 
85
- function getSnarkArtifacts(treeDepth) {
86
- return __awaiter(this, void 0, void 0, function () {
87
- var tmpDir, tmpPath;
88
- return __generator(this, function (_a) {
89
- switch (_a.label) {
90
- case 0:
91
- tmpDir = "semaphore-proof";
92
- tmpPath = "".concat(tmp.tmpdir, "/").concat(tmpDir, "-").concat(treeDepth);
93
- if (!(!fs.existsSync(tmpPath) || fs.readdirSync(tmpPath).length !== 2)) return [3 /*break*/, 3];
94
- return [4 /*yield*/, download("https://semaphore.cedoor.dev/artifacts/".concat(treeDepth, "/semaphore.wasm"), tmpPath)];
95
- case 1:
96
- _a.sent();
97
- return [4 /*yield*/, download("https://semaphore.cedoor.dev/artifacts/".concat(treeDepth, "/semaphore.zkey"), tmpPath)];
98
- case 2:
99
- _a.sent();
100
- _a.label = 3;
101
- case 3: return [2 /*return*/, {
102
- wasmFilePath: "".concat(tmpPath, "/semaphore.wasm"),
103
- zkeyFilePath: "".concat(tmpPath, "/semaphore.zkey")
104
- }];
105
- }
106
- });
107
- });
88
+ function getSnarkArtifacts(treeDepth) {
89
+ return __awaiter(this, void 0, void 0, function () {
90
+ var tmpDir, tmpPath;
91
+ return __generator(this, function (_a) {
92
+ switch (_a.label) {
93
+ case 0:
94
+ tmpDir = "semaphore-proof";
95
+ tmpPath = "".concat(tmp.tmpdir, "/").concat(tmpDir, "-").concat(treeDepth);
96
+ if (!(!fs.existsSync(tmpPath) || fs.readdirSync(tmpPath).length !== 2)) return [3 /*break*/, 3];
97
+ return [4 /*yield*/, download("https://semaphore.cedoor.dev/artifacts/".concat(treeDepth, "/semaphore.wasm"), tmpPath)];
98
+ case 1:
99
+ _a.sent();
100
+ return [4 /*yield*/, download("https://semaphore.cedoor.dev/artifacts/".concat(treeDepth, "/semaphore.zkey"), tmpPath)];
101
+ case 2:
102
+ _a.sent();
103
+ _a.label = 3;
104
+ case 3: return [2 /*return*/, {
105
+ wasmFilePath: "".concat(tmpPath, "/semaphore.wasm"),
106
+ zkeyFilePath: "".concat(tmpPath, "/semaphore.zkey")
107
+ }];
108
+ }
109
+ });
110
+ });
108
111
  }
109
112
 
110
- /**
111
- * Creates a keccak256 hash of a message compatible with the SNARK scalar modulus.
112
- * @param message The message to be hashed.
113
- * @returns The message digest.
114
- */
115
- function hash(message) {
116
- message = bignumber.BigNumber.from(message).toTwos(256).toHexString();
117
- message = bytes.zeroPad(message, 32);
118
- return (BigInt(keccak256.keccak256(message)) >> BigInt(8)).toString();
113
+ /**
114
+ * Creates a keccak256 hash of a message compatible with the SNARK scalar modulus.
115
+ * @param message The message to be hashed.
116
+ * @returns The message digest.
117
+ */
118
+ function hash(message) {
119
+ message = BigNumber.from(message).toTwos(256).toHexString();
120
+ message = zeroPad(message, 32);
121
+ return (BigInt(keccak256(message)) >> BigInt(8)).toString();
119
122
  }
120
123
 
121
- /**
122
- * Packs the Groth16 proof points into a format compatible with Semaphore.
123
- * @param proof The proof points generated with SnarkJS.
124
- * @returns The proof points compatible with Semaphore.
125
- */
126
- function packPoints(proof) {
127
- return [
128
- proof.pi_a[0],
129
- proof.pi_a[1],
130
- proof.pi_b[0][1],
131
- proof.pi_b[0][0],
132
- proof.pi_b[1][1],
133
- proof.pi_b[1][0],
134
- proof.pi_c[0],
135
- proof.pi_c[1]
136
- ];
124
+ /**
125
+ * Packs the Groth16 proof points into a format compatible with Semaphore.
126
+ * @param proof The proof points generated with SnarkJS.
127
+ * @returns The proof points compatible with Semaphore.
128
+ */
129
+ function packPoints(proof) {
130
+ return [
131
+ proof.pi_a[0],
132
+ proof.pi_a[1],
133
+ proof.pi_b[0][1],
134
+ proof.pi_b[0][0],
135
+ proof.pi_b[1][1],
136
+ proof.pi_b[1][0],
137
+ proof.pi_c[0],
138
+ proof.pi_c[1]
139
+ ];
137
140
  }
138
141
 
139
- /**
140
- * Generates a Semaphore proof.
141
- * @param identity The Semaphore identity.
142
- * @param groupOrMerkleProof The Semaphore group or its Merkle proof.
143
- * @param scope The external nullifier.
144
- * @param message The Semaphore signal.
145
- * @param merkleTreeDepth The depth of the tree with which the circuit was compiled.
146
- * @param snarkArtifacts The SNARK artifacts.
147
- * @returns The Semaphore proof ready to be verified.
148
- */
149
- function generateProof(identity, groupOrMerkleProof, message, scope, merkleTreeDepth, snarkArtifacts) {
150
- return __awaiter(this, void 0, void 0, function () {
151
- var merkleProof, leafIndex, merkleProofLength, merkleProofIndices, merkleProofSiblings, i, _a, proof, publicSignals;
152
- return __generator(this, function (_b) {
153
- switch (_b.label) {
154
- case 0:
155
- if ("siblings" in groupOrMerkleProof) {
156
- merkleProof = groupOrMerkleProof;
157
- }
158
- else {
159
- leafIndex = groupOrMerkleProof.indexOf(identity.commitment);
160
- merkleProof = groupOrMerkleProof.generateMerkleProof(leafIndex);
161
- }
162
- merkleProofLength = merkleProof.siblings.length;
163
- if (merkleTreeDepth !== undefined) {
164
- if (merkleTreeDepth < 1 || merkleTreeDepth > 12) {
165
- throw new TypeError("The tree depth must be a number between 1 and 12");
166
- }
167
- }
168
- else {
169
- merkleTreeDepth = merkleProofLength;
170
- }
171
- if (!!snarkArtifacts) return [3 /*break*/, 2];
172
- return [4 /*yield*/, getSnarkArtifacts(merkleTreeDepth)];
173
- case 1:
174
- snarkArtifacts = _b.sent();
175
- _b.label = 2;
176
- case 2:
177
- merkleProofIndices = [];
178
- merkleProofSiblings = merkleProof.siblings;
179
- for (i = 0; i < merkleTreeDepth; i += 1) {
180
- merkleProofIndices.push((merkleProof.index >> i) & 1);
181
- if (merkleProofSiblings[i] === undefined) {
182
- merkleProofSiblings[i] = "0";
183
- }
184
- }
185
- return [4 /*yield*/, snarkjs.groth16.fullProve({
186
- secret: identity.secretScalar,
187
- merkleProofLength: merkleProofLength,
188
- merkleProofIndices: merkleProofIndices,
189
- merkleProofSiblings: merkleProofSiblings,
190
- scope: hash(scope),
191
- message: hash(message)
192
- }, snarkArtifacts.wasmFilePath, snarkArtifacts.zkeyFilePath)];
193
- case 3:
194
- _a = _b.sent(), proof = _a.proof, publicSignals = _a.publicSignals;
195
- return [2 /*return*/, {
196
- merkleTreeDepth: merkleTreeDepth,
197
- merkleTreeRoot: publicSignals[0],
198
- nullifier: publicSignals[1],
199
- message: bignumber.BigNumber.from(message).toString(),
200
- scope: bignumber.BigNumber.from(scope).toString(),
201
- points: packPoints(proof)
202
- }];
203
- }
204
- });
205
- });
142
+ /**
143
+ * Generates a Semaphore proof.
144
+ * @param identity The Semaphore identity.
145
+ * @param groupOrMerkleProof The Semaphore group or its Merkle proof.
146
+ * @param scope The external nullifier.
147
+ * @param message The Semaphore signal.
148
+ * @param merkleTreeDepth The depth of the tree with which the circuit was compiled.
149
+ * @param snarkArtifacts The SNARK artifacts.
150
+ * @returns The Semaphore proof ready to be verified.
151
+ */
152
+ function generateProof(identity, groupOrMerkleProof, message, scope, merkleTreeDepth, snarkArtifacts) {
153
+ return __awaiter(this, void 0, void 0, function () {
154
+ var merkleProof, leafIndex, merkleProofLength, merkleProofIndices, merkleProofSiblings, i, _a, proof, publicSignals;
155
+ return __generator(this, function (_b) {
156
+ switch (_b.label) {
157
+ case 0:
158
+ if ("siblings" in groupOrMerkleProof) {
159
+ merkleProof = groupOrMerkleProof;
160
+ }
161
+ else {
162
+ leafIndex = groupOrMerkleProof.indexOf(identity.commitment);
163
+ merkleProof = groupOrMerkleProof.generateMerkleProof(leafIndex);
164
+ }
165
+ merkleProofLength = merkleProof.siblings.length;
166
+ if (merkleTreeDepth !== undefined) {
167
+ if (merkleTreeDepth < 1 || merkleTreeDepth > 12) {
168
+ throw new TypeError("The tree depth must be a number between 1 and 12");
169
+ }
170
+ }
171
+ else {
172
+ merkleTreeDepth = merkleProofLength;
173
+ }
174
+ if (!!snarkArtifacts) return [3 /*break*/, 2];
175
+ return [4 /*yield*/, getSnarkArtifacts(merkleTreeDepth)];
176
+ case 1:
177
+ snarkArtifacts = _b.sent();
178
+ _b.label = 2;
179
+ case 2:
180
+ merkleProofIndices = [];
181
+ merkleProofSiblings = merkleProof.siblings;
182
+ for (i = 0; i < merkleTreeDepth; i += 1) {
183
+ merkleProofIndices.push((merkleProof.index >> i) & 1);
184
+ if (merkleProofSiblings[i] === undefined) {
185
+ merkleProofSiblings[i] = "0";
186
+ }
187
+ }
188
+ return [4 /*yield*/, groth16.fullProve({
189
+ secret: identity.secretScalar,
190
+ merkleProofLength: merkleProofLength,
191
+ merkleProofIndices: merkleProofIndices,
192
+ merkleProofSiblings: merkleProofSiblings,
193
+ scope: hash(scope),
194
+ message: hash(message)
195
+ }, snarkArtifacts.wasmFilePath, snarkArtifacts.zkeyFilePath)];
196
+ case 3:
197
+ _a = _b.sent(), proof = _a.proof, publicSignals = _a.publicSignals;
198
+ return [2 /*return*/, {
199
+ merkleTreeDepth: merkleTreeDepth,
200
+ merkleTreeRoot: publicSignals[0],
201
+ nullifier: publicSignals[1],
202
+ message: BigNumber.from(message).toString(),
203
+ scope: BigNumber.from(scope).toString(),
204
+ points: packPoints(proof)
205
+ }];
206
+ }
207
+ });
208
+ });
206
209
  }
207
210
 
208
- /**
209
- * Unpacks the Groth16 proof points into their original form.
210
- * @param proof The proof points compatible with Semaphore.
211
- * @returns The proof points compatible with SnarkJS.
212
- */
213
- function unpackPoints(proof) {
214
- return {
215
- pi_a: [proof[0], proof[1]],
216
- pi_b: [
217
- [proof[3], proof[2]],
218
- [proof[5], proof[4]]
219
- ],
220
- pi_c: [proof[6], proof[7]],
221
- protocol: "groth16",
222
- curve: "bn128"
223
- };
211
+ /**
212
+ * Unpacks the Groth16 proof points into their original form.
213
+ * @param proof The proof points compatible with Semaphore.
214
+ * @returns The proof points compatible with SnarkJS.
215
+ */
216
+ function unpackPoints(proof) {
217
+ return {
218
+ pi_a: [proof[0], proof[1]],
219
+ pi_b: [
220
+ [proof[3], proof[2]],
221
+ [proof[5], proof[4]]
222
+ ],
223
+ pi_c: [proof[6], proof[7]],
224
+ protocol: "groth16",
225
+ curve: "bn128"
226
+ };
224
227
  }
225
228
 
226
229
  var protocol = "groth16";
@@ -797,29 +800,24 @@ var verificationKeys = {
797
800
  IC: IC
798
801
  };
799
802
 
800
- /**
801
- * Verifies a Semaphore proof.
802
- * @param fullProof The SnarkJS Semaphore proof.
803
- * @param treeDepth The depth of the tree.
804
- * @returns True if the proof is valid, false otherwise.
805
- */
806
- function verifyProof(_a) {
807
- var merkleTreeDepth = _a.merkleTreeDepth, merkleTreeRoot = _a.merkleTreeRoot, nullifier = _a.nullifier, message = _a.message, scope = _a.scope, points = _a.points;
808
- return __awaiter(this, void 0, void 0, function () {
809
- var verificationKey;
810
- return __generator(this, function (_b) {
811
- // TODO: support all tree depths after trusted-setup.
812
- if (merkleTreeDepth < 1 || merkleTreeDepth > 12) {
813
- throw new TypeError("The tree depth must be a number between 1 and 12");
814
- }
815
- verificationKey = __assign(__assign({}, verificationKeys), { vk_delta_2: verificationKeys.vk_delta_2[merkleTreeDepth - 1], IC: verificationKeys.IC[merkleTreeDepth - 1] });
816
- return [2 /*return*/, snarkjs.groth16.verify(verificationKey, [merkleTreeRoot, nullifier, hash(message), hash(scope)], unpackPoints(points))];
817
- });
818
- });
803
+ /**
804
+ * Verifies a Semaphore proof.
805
+ * @param proof The Semaphore proof.
806
+ * @returns True if the proof is valid, false otherwise.
807
+ */
808
+ function verifyProof(_a) {
809
+ var merkleTreeDepth = _a.merkleTreeDepth, merkleTreeRoot = _a.merkleTreeRoot, nullifier = _a.nullifier, message = _a.message, scope = _a.scope, points = _a.points;
810
+ return __awaiter(this, void 0, void 0, function () {
811
+ var verificationKey;
812
+ return __generator(this, function (_b) {
813
+ // TODO: support all tree depths after trusted-setup.
814
+ if (merkleTreeDepth < 1 || merkleTreeDepth > 12) {
815
+ throw new TypeError("The tree depth must be a number between 1 and 12");
816
+ }
817
+ verificationKey = __assign(__assign({}, verificationKeys), { vk_delta_2: verificationKeys.vk_delta_2[merkleTreeDepth - 1], IC: verificationKeys.IC[merkleTreeDepth - 1] });
818
+ return [2 /*return*/, groth16.verify(verificationKey, [merkleTreeRoot, nullifier, hash(message), hash(scope)], unpackPoints(points))];
819
+ });
820
+ });
819
821
  }
820
822
 
821
- exports.generateProof = generateProof;
822
- exports.getSnarkArtifacts = getSnarkArtifacts;
823
- exports.packPoints = packPoints;
824
- exports.unpackPoints = unpackPoints;
825
- exports.verifyProof = verifyProof;
823
+ export { generateProof, getSnarkArtifacts, packPoints, unpackPoints, verifyProof };
@@ -1,15 +1,15 @@
1
- import { BytesLike, Hexable } from "@ethersproject/bytes";
2
- import type { Group, MerkleProof } from "@semaphore-protocol/group";
3
- import type { Identity } from "@semaphore-protocol/identity";
4
- import { SemaphoreProof, SnarkArtifacts } from "./types";
5
- /**
6
- * Generates a Semaphore proof.
7
- * @param identity The Semaphore identity.
8
- * @param groupOrMerkleProof The Semaphore group or its Merkle proof.
9
- * @param scope The external nullifier.
10
- * @param message The Semaphore signal.
11
- * @param merkleTreeDepth The depth of the tree with which the circuit was compiled.
12
- * @param snarkArtifacts The SNARK artifacts.
13
- * @returns The Semaphore proof ready to be verified.
14
- */
15
- export default function generateProof(identity: Identity, groupOrMerkleProof: Group | MerkleProof, message: BytesLike | Hexable | number | bigint, scope: BytesLike | Hexable | number | bigint, merkleTreeDepth?: number, snarkArtifacts?: SnarkArtifacts): Promise<SemaphoreProof>;
1
+ import { BytesLike, Hexable } from "@ethersproject/bytes";
2
+ import type { Group, MerkleProof } from "@semaphore-protocol/group";
3
+ import type { Identity } from "@semaphore-protocol/identity";
4
+ import { SemaphoreProof, SnarkArtifacts } from "./types";
5
+ /**
6
+ * Generates a Semaphore proof.
7
+ * @param identity The Semaphore identity.
8
+ * @param groupOrMerkleProof The Semaphore group or its Merkle proof.
9
+ * @param scope The external nullifier.
10
+ * @param message The Semaphore signal.
11
+ * @param merkleTreeDepth The depth of the tree with which the circuit was compiled.
12
+ * @param snarkArtifacts The SNARK artifacts.
13
+ * @returns The Semaphore proof ready to be verified.
14
+ */
15
+ export default function generateProof(identity: Identity, groupOrMerkleProof: Group | MerkleProof, message: BytesLike | Hexable | number | bigint, scope: BytesLike | Hexable | number | bigint, merkleTreeDepth?: number, snarkArtifacts?: SnarkArtifacts): Promise<SemaphoreProof>;
@@ -1,2 +1,2 @@
1
- import { SnarkArtifacts } from "./types";
2
- export default function getSnarkArtifacts(treeDepth: number): Promise<SnarkArtifacts>;
1
+ import { SnarkArtifacts } from "./types";
2
+ export default function getSnarkArtifacts(treeDepth: number): Promise<SnarkArtifacts>;
@@ -1,2 +1,2 @@
1
- import { SnarkArtifacts } from "./types";
2
- export default function getSnarkArtifacts(treeDepth: number): Promise<SnarkArtifacts>;
1
+ import { SnarkArtifacts } from "./types";
2
+ export default function getSnarkArtifacts(treeDepth: number): Promise<SnarkArtifacts>;
@@ -1,8 +1,8 @@
1
- import { BytesLike, Hexable } from "@ethersproject/bytes";
2
- import { NumericString } from "snarkjs";
3
- /**
4
- * Creates a keccak256 hash of a message compatible with the SNARK scalar modulus.
5
- * @param message The message to be hashed.
6
- * @returns The message digest.
7
- */
8
- export default function hash(message: BytesLike | Hexable | number | bigint): NumericString;
1
+ import { BytesLike, Hexable } from "@ethersproject/bytes";
2
+ import { NumericString } from "snarkjs";
3
+ /**
4
+ * Creates a keccak256 hash of a message compatible with the SNARK scalar modulus.
5
+ * @param message The message to be hashed.
6
+ * @returns The message digest.
7
+ */
8
+ export default function hash(message: BytesLike | Hexable | number | bigint): NumericString;
@@ -1,7 +1,7 @@
1
- import generateProof from "./generate-proof";
2
- import getSnarkArtifacts from "./get-snark-artifacts.node";
3
- import packPoints from "./pack-points";
4
- import unpackPoints from "./unpack-points";
5
- import verifyProof from "./verify-proof";
6
- export * from "./types";
7
- export { generateProof, getSnarkArtifacts, packPoints, unpackPoints, verifyProof };
1
+ import generateProof from "./generate-proof";
2
+ import getSnarkArtifacts from "./get-snark-artifacts.node";
3
+ import packPoints from "./pack-points";
4
+ import unpackPoints from "./unpack-points";
5
+ import verifyProof from "./verify-proof";
6
+ export * from "./types";
7
+ export { generateProof, getSnarkArtifacts, packPoints, unpackPoints, verifyProof };
@@ -1,8 +1,8 @@
1
- import { Groth16Proof } from "snarkjs";
2
- import { PackedPoints } from "./types";
3
- /**
4
- * Packs the Groth16 proof points into a format compatible with Semaphore.
5
- * @param proof The proof points generated with SnarkJS.
6
- * @returns The proof points compatible with Semaphore.
7
- */
8
- export default function packPoints(proof: Groth16Proof): PackedPoints;
1
+ import { Groth16Proof } from "snarkjs";
2
+ import { PackedPoints } from "./types";
3
+ /**
4
+ * Packs the Groth16 proof points into a format compatible with Semaphore.
5
+ * @param proof The proof points generated with SnarkJS.
6
+ * @returns The proof points compatible with Semaphore.
7
+ */
8
+ export default function packPoints(proof: Groth16Proof): PackedPoints;
@@ -1,24 +1,24 @@
1
- import type { NumericString } from "snarkjs";
2
- export type BigNumberish = string | number | bigint;
3
- export type SnarkArtifacts = {
4
- wasmFilePath: string;
5
- zkeyFilePath: string;
6
- };
7
- export type SemaphoreProof = {
8
- merkleTreeDepth: number;
9
- merkleTreeRoot: NumericString;
10
- message: NumericString;
11
- nullifier: NumericString;
12
- scope: NumericString;
13
- points: PackedPoints;
14
- };
15
- export type PackedPoints = [
16
- NumericString,
17
- NumericString,
18
- NumericString,
19
- NumericString,
20
- NumericString,
21
- NumericString,
22
- NumericString,
23
- NumericString
24
- ];
1
+ import type { NumericString } from "snarkjs";
2
+ export type BigNumberish = string | number | bigint;
3
+ export type SnarkArtifacts = {
4
+ wasmFilePath: string;
5
+ zkeyFilePath: string;
6
+ };
7
+ export type SemaphoreProof = {
8
+ merkleTreeDepth: number;
9
+ merkleTreeRoot: NumericString;
10
+ message: NumericString;
11
+ nullifier: NumericString;
12
+ scope: NumericString;
13
+ points: PackedPoints;
14
+ };
15
+ export type PackedPoints = [
16
+ NumericString,
17
+ NumericString,
18
+ NumericString,
19
+ NumericString,
20
+ NumericString,
21
+ NumericString,
22
+ NumericString,
23
+ NumericString
24
+ ];
@@ -1,8 +1,8 @@
1
- import { Groth16Proof } from "snarkjs";
2
- import { PackedPoints } from "./types";
3
- /**
4
- * Unpacks the Groth16 proof points into their original form.
5
- * @param proof The proof points compatible with Semaphore.
6
- * @returns The proof points compatible with SnarkJS.
7
- */
8
- export default function unpackPoints(proof: PackedPoints): Groth16Proof;
1
+ import { Groth16Proof } from "snarkjs";
2
+ import { PackedPoints } from "./types";
3
+ /**
4
+ * Unpacks the Groth16 proof points into their original form.
5
+ * @param proof The proof points compatible with Semaphore.
6
+ * @returns The proof points compatible with SnarkJS.
7
+ */
8
+ export default function unpackPoints(proof: PackedPoints): Groth16Proof;
@@ -1,8 +1,7 @@
1
- import { SemaphoreProof } from "./types";
2
- /**
3
- * Verifies a Semaphore proof.
4
- * @param fullProof The SnarkJS Semaphore proof.
5
- * @param treeDepth The depth of the tree.
6
- * @returns True if the proof is valid, false otherwise.
7
- */
8
- export default function verifyProof({ merkleTreeDepth, merkleTreeRoot, nullifier, message, scope, points }: SemaphoreProof): Promise<boolean>;
1
+ import { SemaphoreProof } from "./types";
2
+ /**
3
+ * Verifies a Semaphore proof.
4
+ * @param proof The Semaphore proof.
5
+ * @returns True if the proof is valid, false otherwise.
6
+ */
7
+ export default function verifyProof({ merkleTreeDepth, merkleTreeRoot, nullifier, message, scope, points }: SemaphoreProof): Promise<boolean>;
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@semaphore-protocol/proof",
3
- "version": "4.0.0-alpha.4",
3
+ "version": "4.0.0-alpha.5",
4
4
  "description": "A library to generate and verify Semaphore proofs.",
5
+ "type": "module",
5
6
  "license": "MIT",
6
- "main": "dist/index.node.js",
7
- "browser": "dist/index.browser.mjs",
7
+ "main": "dist/index.browser.js",
8
+ "types": "dist/types/index.d.ts",
8
9
  "exports": {
9
10
  ".": {
11
+ "types": "./dist/types/index.d.ts",
10
12
  "node": {
11
- "import": "./dist/index.node.mjs",
12
- "require": "./dist/index.node.js"
13
+ "require": "./dist/index.node.cjs",
14
+ "default": "./dist/index.node.js"
13
15
  },
14
- "browser": "./dist/index.browser.mjs",
15
- "default": "./dist/index.browser.mjs",
16
- "types": "./dist/types/index.d.ts"
16
+ "browser": "./dist/index.browser.js",
17
+ "default": "./dist/index.browser.js"
17
18
  }
18
19
  },
19
- "types": "dist/types/index.d.ts",
20
20
  "files": [
21
21
  "dist/",
22
22
  "src/",
@@ -40,18 +40,18 @@
40
40
  "devDependencies": {
41
41
  "@ethersproject/strings": "^5.7.0",
42
42
  "@rollup/plugin-alias": "^5.1.0",
43
- "@rollup/plugin-json": "^5.0.1",
43
+ "@rollup/plugin-json": "^6.1.0",
44
44
  "@types/download": "^8.0.5",
45
45
  "@types/tmp": "^0.2.6",
46
46
  "poseidon-lite": "^0.2.0",
47
47
  "rimraf": "^5.0.5",
48
48
  "rollup": "^4.0.2",
49
49
  "rollup-plugin-cleanup": "^3.2.1",
50
- "rollup-plugin-typescript2": "^0.31.2"
50
+ "rollup-plugin-typescript2": "^0.36.0"
51
51
  },
52
52
  "peerDependencies": {
53
- "@semaphore-protocol/group": "4.0.0-alpha.4",
54
- "@semaphore-protocol/identity": "4.0.0-alpha.4"
53
+ "@semaphore-protocol/group": "4.0.0-alpha.5",
54
+ "@semaphore-protocol/identity": "4.0.0-alpha.5"
55
55
  },
56
56
  "dependencies": {
57
57
  "@ethersproject/bignumber": "5.7.0",
@@ -6,8 +6,7 @@ import verificationKeys from "./verification-keys.json"
6
6
 
7
7
  /**
8
8
  * Verifies a Semaphore proof.
9
- * @param fullProof The SnarkJS Semaphore proof.
10
- * @param treeDepth The depth of the tree.
9
+ * @param proof The Semaphore proof.
11
10
  * @returns True if the proof is valid, false otherwise.
12
11
  */
13
12
  export default async function verifyProof({