@semaphore-protocol/proof 0.3.3 → 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/README.md CHANGED
@@ -38,7 +38,8 @@
38
38
  </h4>
39
39
  </div>
40
40
 
41
- ---
41
+ | This library provides utility functions to generate and verify Semaphore proofs compatible with the Semaphore [circuits](https://github.com/semaphore-protocol/semaphore/tree/main/circuits). Generating valid zero-knowledge proofs requires files that can only be obtained in an attested [trusted-setup ceremony](https://storage.googleapis.com/trustedsetup-a86f4.appspot.com/semaphore/semaphore_top_index.html). For a complete list of ready-to-use files visit [trusted-setup-pse.org](http://www.trusted-setup-pse.org/). |
42
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
42
43
 
43
44
  ## 🛠 Install
44
45
 
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module @semaphore-protocol/proof
3
- * @version 0.3.3
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) {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module @semaphore-protocol/proof
3
- * @version 0.3.3
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: SnarkArtifacts): Promise<FullProof>;
4
+ export default function generateProof(identity: Identity, group: Group, externalNullifier: BigNumberish, signal: string, snarkArtifacts?: SnarkArtifacts): Promise<FullProof>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semaphore-protocol/proof",
3
- "version": "0.3.3",
3
+ "version": "2.1.0",
4
4
  "description": "A library to generate and verify Semaphore proofs.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.node.js",
@@ -37,8 +37,8 @@
37
37
  "@ethersproject/bytes": "^5.5.0",
38
38
  "@ethersproject/solidity": "^5.5.0",
39
39
  "@ethersproject/strings": "^5.5.0",
40
- "@semaphore-protocol/group": "0.1.2",
41
- "@semaphore-protocol/identity": "0.2.2",
40
+ "@semaphore-protocol/group": "2.0.0",
41
+ "@semaphore-protocol/identity": "2.0.0",
42
42
  "circomlibjs": "0.0.8",
43
43
  "snarkjs": "^0.4.13"
44
44
  }
@@ -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", () => {