@semaphore-protocol/proof 4.0.0-beta.8 → 4.0.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.
@@ -1,6 +1,6 @@
1
1
  import type { Group, MerkleProof } from "@semaphore-protocol/group";
2
2
  import type { Identity } from "@semaphore-protocol/identity";
3
- import { type SnarkArtifacts } from "@zk-kit/utils";
3
+ import { type SnarkArtifacts } from "@zk-kit/artifacts";
4
4
  import type { BigNumberish } from "ethers";
5
5
  import type { SemaphoreProof } from "./types";
6
6
  /**
@@ -15,6 +15,7 @@ import type { SemaphoreProof } from "./types";
15
15
  * If it is not defined, it will be inferred from the group or Merkle proof passed as the second parameter.
16
16
  * Finally, the artifacts themselves can be passed manually with file paths,
17
17
  * or they will be automatically fetched.
18
+ * Please keep in mind that groups with 1 member or 2 members cannot be considered anonymous.
18
19
  * @param identity The Semaphore identity.
19
20
  * @param groupOrMerkleProof The Semaphore group or its Merkle proof.
20
21
  * @param message The Semaphore message.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semaphore-protocol/proof",
3
- "version": "4.0.0-beta.8",
3
+ "version": "4.0.0",
4
4
  "description": "A library to generate and verify Semaphore proofs.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -48,12 +48,13 @@
48
48
  "rollup-plugin-cleanup": "^3.2.1"
49
49
  },
50
50
  "peerDependencies": {
51
- "@semaphore-protocol/group": "4.0.0-beta.8",
52
- "@semaphore-protocol/identity": "4.0.0-beta.8"
51
+ "@semaphore-protocol/group": "4.0.0",
52
+ "@semaphore-protocol/identity": "4.0.0"
53
53
  },
54
54
  "dependencies": {
55
- "@semaphore-protocol/utils": "4.0.0-beta.8",
56
- "@zk-kit/utils": "1.0.0-beta.4",
55
+ "@semaphore-protocol/utils": "4.0.0",
56
+ "@zk-kit/artifacts": "1.8.0",
57
+ "@zk-kit/utils": "1.0.0",
57
58
  "ethers": "6.10.0",
58
59
  "snarkjs": "0.7.4"
59
60
  }
@@ -3,7 +3,7 @@ import type { Identity } from "@semaphore-protocol/identity"
3
3
  import { MAX_DEPTH, MIN_DEPTH } from "@semaphore-protocol/utils/constants"
4
4
  import { requireDefined, requireNumber, requireObject, requireTypes } from "@zk-kit/utils/error-handlers"
5
5
  import { packGroth16Proof } from "@zk-kit/utils/proof-packing"
6
- import { maybeGetSemaphoreSnarkArtifacts, type SnarkArtifacts } from "@zk-kit/utils"
6
+ import { maybeGetSnarkArtifacts, Project, type SnarkArtifacts } from "@zk-kit/artifacts"
7
7
  import type { BigNumberish } from "ethers"
8
8
  import { type NumericString, groth16 } from "snarkjs"
9
9
  import hash from "./hash"
@@ -22,6 +22,7 @@ import type { SemaphoreProof } from "./types"
22
22
  * If it is not defined, it will be inferred from the group or Merkle proof passed as the second parameter.
23
23
  * Finally, the artifacts themselves can be passed manually with file paths,
24
24
  * or they will be automatically fetched.
25
+ * Please keep in mind that groups with 1 member or 2 members cannot be considered anonymous.
25
26
  * @param identity The Semaphore identity.
26
27
  * @param groupOrMerkleProof The Semaphore group or its Merkle proof.
27
28
  * @param message The Semaphore message.
@@ -79,11 +80,14 @@ export default async function generateProof(
79
80
  throw new TypeError(`The tree depth must be a number between ${MIN_DEPTH} and ${MAX_DEPTH}`)
80
81
  }
81
82
  } else {
82
- merkleTreeDepth = merkleProofLength
83
+ merkleTreeDepth = merkleProofLength !== 0 ? merkleProofLength : 1
83
84
  }
84
85
 
85
86
  // If the Snark artifacts are not defined they will be automatically downloaded.
86
- snarkArtifacts ??= await maybeGetSemaphoreSnarkArtifacts(merkleTreeDepth)
87
+ snarkArtifacts ??= await maybeGetSnarkArtifacts(Project.SEMAPHORE, {
88
+ parameters: [merkleTreeDepth],
89
+ version: "4.0.0"
90
+ })
87
91
  const { wasm, zkey } = snarkArtifacts
88
92
 
89
93
  // The index must be converted to a list of indices, 1 for each tree level.