@semaphore-protocol/proof 4.0.0-beta.9 → 4.0.1
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.browser.js +1015 -191
- package/dist/index.node.cjs +1015 -191
- package/dist/index.node.js +1015 -191
- package/dist/types/generate-proof.d.ts +2 -1
- package/package.json +6 -5
- package/src/generate-proof.ts +9 -5
- package/src/verification-keys.json +946 -186
|
@@ -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/
|
|
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.
|
|
3
|
+
"version": "4.0.1",
|
|
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.
|
|
52
|
-
"@semaphore-protocol/identity": "4.0.
|
|
51
|
+
"@semaphore-protocol/group": "4.0.1",
|
|
52
|
+
"@semaphore-protocol/identity": "4.0.1"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@semaphore-protocol/utils": "4.0.
|
|
56
|
-
"@zk-kit/
|
|
55
|
+
"@semaphore-protocol/utils": "4.0.1",
|
|
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
|
}
|
package/src/generate-proof.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Group, MerkleProof } from "@semaphore-protocol/group"
|
|
2
2
|
import type { Identity } from "@semaphore-protocol/identity"
|
|
3
3
|
import { MAX_DEPTH, MIN_DEPTH } from "@semaphore-protocol/utils/constants"
|
|
4
|
+
import { Project, maybeGetSnarkArtifacts, type SnarkArtifacts } from "@zk-kit/artifacts"
|
|
4
5
|
import { requireDefined, requireNumber, requireObject, requireTypes } from "@zk-kit/utils/error-handlers"
|
|
5
6
|
import { packGroth16Proof } from "@zk-kit/utils/proof-packing"
|
|
6
|
-
import { maybeGetSemaphoreSnarkArtifacts, type SnarkArtifacts } from "@zk-kit/utils"
|
|
7
7
|
import type { BigNumberish } from "ethers"
|
|
8
|
-
import { type NumericString
|
|
8
|
+
import { groth16, type NumericString } from "snarkjs"
|
|
9
9
|
import hash from "./hash"
|
|
10
10
|
import toBigInt from "./to-bigint"
|
|
11
11
|
import type { SemaphoreProof } from "./types"
|
|
@@ -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
|
|
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.
|
|
@@ -114,7 +118,7 @@ export default async function generateProof(
|
|
|
114
118
|
|
|
115
119
|
return {
|
|
116
120
|
merkleTreeDepth,
|
|
117
|
-
merkleTreeRoot:
|
|
121
|
+
merkleTreeRoot: merkleProof.root.toString(),
|
|
118
122
|
nullifier: publicSignals[1],
|
|
119
123
|
message: message.toString() as NumericString,
|
|
120
124
|
scope: scope.toString() as NumericString,
|