@semaphore-protocol/proof 2.0.1 → 2.1.0
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.mjs +5 -1
- package/dist/index.node.js +5 -1
- package/dist/types/generateProof.d.ts +1 -1
- package/package.json +1 -1
- package/src/generateProof.ts +4 -1
- package/src/index.test.ts +15 -0
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module @semaphore-protocol/proof
|
|
3
|
-
* @version 2.0
|
|
3
|
+
* @version 2.1.0
|
|
4
4
|
* @file A library to generate and verify Semaphore proofs.
|
|
5
5
|
* @copyright Ethereum Foundation 2022
|
|
6
6
|
* @license MIT
|
|
@@ -84,6 +84,10 @@ function genSignalHash(signal) {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
function generateProof(identity, group, externalNullifier, signal, snarkArtifacts) {
|
|
87
|
+
if (snarkArtifacts === void 0) { snarkArtifacts = {
|
|
88
|
+
wasmFilePath: "https://www.trusted-setup-pse.org/semaphore/".concat(group.depth, "/semaphore.wasm"),
|
|
89
|
+
zkeyFilePath: "https://www.trusted-setup-pse.org/semaphore/".concat(group.depth, "/semaphore.zkey")
|
|
90
|
+
}; }
|
|
87
91
|
return __awaiter(this, void 0, void 0, function () {
|
|
88
92
|
var commitment, index, merkleProof, _a, proof, publicSignals;
|
|
89
93
|
return __generator(this, function (_b) {
|
package/dist/index.node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module @semaphore-protocol/proof
|
|
3
|
-
* @version 2.0
|
|
3
|
+
* @version 2.1.0
|
|
4
4
|
* @file A library to generate and verify Semaphore proofs.
|
|
5
5
|
* @copyright Ethereum Foundation 2022
|
|
6
6
|
* @license MIT
|
|
@@ -88,6 +88,10 @@ function genSignalHash(signal) {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
function generateProof(identity, group, externalNullifier, signal, snarkArtifacts) {
|
|
91
|
+
if (snarkArtifacts === void 0) { snarkArtifacts = {
|
|
92
|
+
wasmFilePath: "https://www.trusted-setup-pse.org/semaphore/".concat(group.depth, "/semaphore.wasm"),
|
|
93
|
+
zkeyFilePath: "https://www.trusted-setup-pse.org/semaphore/".concat(group.depth, "/semaphore.zkey")
|
|
94
|
+
}; }
|
|
91
95
|
return __awaiter(this, void 0, void 0, function () {
|
|
92
96
|
var commitment, index, merkleProof, _a, proof, publicSignals;
|
|
93
97
|
return __generator(this, function (_b) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Identity } from "@semaphore-protocol/identity";
|
|
2
2
|
import { Group } from "@semaphore-protocol/group";
|
|
3
3
|
import { BigNumberish, FullProof, SnarkArtifacts } from "./types";
|
|
4
|
-
export default function generateProof(identity: Identity, group: Group, externalNullifier: BigNumberish, signal: string, snarkArtifacts
|
|
4
|
+
export default function generateProof(identity: Identity, group: Group, externalNullifier: BigNumberish, signal: string, snarkArtifacts?: SnarkArtifacts): Promise<FullProof>;
|
package/package.json
CHANGED
package/src/generateProof.ts
CHANGED
|
@@ -9,7 +9,10 @@ export default async function generateProof(
|
|
|
9
9
|
group: Group,
|
|
10
10
|
externalNullifier: BigNumberish,
|
|
11
11
|
signal: string,
|
|
12
|
-
snarkArtifacts: SnarkArtifacts
|
|
12
|
+
snarkArtifacts: SnarkArtifacts = {
|
|
13
|
+
wasmFilePath: `https://www.trusted-setup-pse.org/semaphore/${group.depth}/semaphore.wasm`,
|
|
14
|
+
zkeyFilePath: `https://www.trusted-setup-pse.org/semaphore/${group.depth}/semaphore.zkey`
|
|
15
|
+
}
|
|
13
16
|
): Promise<FullProof> {
|
|
14
17
|
const commitment = identity.generateCommitment()
|
|
15
18
|
const index = group.indexOf(commitment)
|
package/src/index.test.ts
CHANGED
|
@@ -72,6 +72,21 @@ describe("Proof", () => {
|
|
|
72
72
|
expect(fullProof.publicSignals.externalNullifier).toBe(externalNullifier)
|
|
73
73
|
expect(fullProof.publicSignals.merkleRoot).toBe(group.root.toString())
|
|
74
74
|
}, 20000)
|
|
75
|
+
|
|
76
|
+
it("Should generate a Semaphore proof with default snark artifacts", async () => {
|
|
77
|
+
const group = new Group(treeDepth)
|
|
78
|
+
|
|
79
|
+
group.addMembers([BigInt(1), BigInt(2), identityCommitment])
|
|
80
|
+
|
|
81
|
+
fullProof = await generateProof(identity, group, externalNullifier, signal, {
|
|
82
|
+
wasmFilePath: `${snarkArtifactsPath}/semaphore.wasm`,
|
|
83
|
+
zkeyFilePath: `${snarkArtifactsPath}/semaphore.zkey`
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
expect(typeof fullProof).toBe("object")
|
|
87
|
+
expect(fullProof.publicSignals.externalNullifier).toBe(externalNullifier)
|
|
88
|
+
expect(fullProof.publicSignals.merkleRoot).toBe(group.root.toString())
|
|
89
|
+
}, 20000)
|
|
75
90
|
})
|
|
76
91
|
|
|
77
92
|
describe("# generateSignalHash", () => {
|