@semaphore-protocol/proof 3.15.2 → 4.0.0-alpha
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/LICENSE +1 -1
- package/README.md +18 -28
- package/dist/index.browser.mjs +800 -0
- package/dist/index.node.js +272 -1065
- package/dist/index.node.mjs +270 -1065
- package/dist/types/generate-proof.d.ts +15 -0
- package/dist/types/get-snark-artifacts.browser.d.ts +2 -0
- package/dist/types/get-snark-artifacts.node.d.ts +2 -0
- package/dist/types/hash.d.ts +1 -1
- package/dist/types/index.d.ts +6 -5
- package/dist/types/{packProof.d.ts → pack-proof.d.ts} +1 -1
- package/dist/types/types/index.d.ts +6 -4
- package/dist/types/{unpackProof.d.ts → unpack-proof.d.ts} +1 -1
- package/dist/types/verify-proof.d.ts +8 -0
- package/package.json +20 -13
- package/src/generate-proof.ts +81 -0
- package/src/get-snark-artifacts.browser.ts +9 -0
- package/src/get-snark-artifacts.node.ts +24 -0
- package/src/hash.ts +1 -1
- package/src/index.ts +6 -5
- package/src/{packProof.ts → pack-proof.ts} +1 -1
- package/src/types/index.ts +7 -4
- package/src/{unpackProof.ts → unpack-proof.ts} +1 -1
- package/src/verification-keys.json +522 -0
- package/src/verify-proof.ts +36 -0
- package/dist/types/calculateNullifierHash.d.ts +0 -8
- package/dist/types/generateProof.d.ts +0 -15
- package/dist/types/index.test.d.ts +0 -1
- package/dist/types/verifyProof.d.ts +0 -8
- package/src/calculateNullifierHash.ts +0 -16
- package/src/generateProof.ts +0 -69
- package/src/index.test.ts +0 -147
- package/src/verificationKeys.json +0 -712
- package/src/verifyProof.ts +0 -31
package/src/verifyProof.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { verify } from "@zk-kit/groth16"
|
|
2
|
-
import hash from "./hash"
|
|
3
|
-
import { SemaphoreProof } from "./types"
|
|
4
|
-
import unpackProof from "./unpackProof"
|
|
5
|
-
import verificationKeys from "./verificationKeys.json"
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Verifies a Semaphore proof.
|
|
9
|
-
* @param fullProof The SnarkJS Semaphore proof.
|
|
10
|
-
* @param treeDepth The Merkle tree depth.
|
|
11
|
-
* @returns True if the proof is valid, false otherwise.
|
|
12
|
-
*/
|
|
13
|
-
export default function verifyProof(
|
|
14
|
-
{ merkleTreeRoot, nullifierHash, externalNullifier, signal, proof }: SemaphoreProof,
|
|
15
|
-
treeDepth: number
|
|
16
|
-
): Promise<boolean> {
|
|
17
|
-
if (treeDepth < 16 || treeDepth > 32) {
|
|
18
|
-
throw new TypeError("The tree depth must be a number between 16 and 32")
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const verificationKey = {
|
|
22
|
-
...verificationKeys,
|
|
23
|
-
vk_delta_2: verificationKeys.vk_delta_2[treeDepth - 16],
|
|
24
|
-
IC: verificationKeys.IC[treeDepth - 16]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return verify(verificationKey, {
|
|
28
|
-
publicSignals: [merkleTreeRoot, nullifierHash, hash(signal), hash(externalNullifier)],
|
|
29
|
-
proof: unpackProof(proof)
|
|
30
|
-
})
|
|
31
|
-
}
|