@semaphore-protocol/proof 2.5.0 → 2.6.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.mjs +9 -9
- package/dist/index.node.js +9 -9
- package/dist/types/generateProof.d.ts +1 -1
- package/package.json +3 -3
- package/src/generateProof.ts +3 -5
- package/src/index.test.ts +3 -4
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module @semaphore-protocol/proof
|
|
3
|
-
* @version 2.
|
|
3
|
+
* @version 2.6.1
|
|
4
4
|
* @file A library to generate and verify Semaphore proofs.
|
|
5
5
|
* @copyright Ethereum Foundation 2022
|
|
6
6
|
* @license MIT
|
|
@@ -87,13 +87,13 @@ function genSignalHash(signal) {
|
|
|
87
87
|
return BigInt(keccak256(["bytes32"], [signal])) >> BigInt(8);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
function generateProof(
|
|
90
|
+
function generateProof(_a, groupOrMerkleProof, externalNullifier, signal, snarkArtifacts) {
|
|
91
|
+
var trapdoor = _a.trapdoor, nullifier = _a.nullifier, commitment = _a.commitment;
|
|
91
92
|
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
-
var
|
|
93
|
-
return __generator(this, function (
|
|
94
|
-
switch (
|
|
93
|
+
var merkleProof, index, _b, proof, publicSignals;
|
|
94
|
+
return __generator(this, function (_c) {
|
|
95
|
+
switch (_c.label) {
|
|
95
96
|
case 0:
|
|
96
|
-
commitment = identity.generateCommitment();
|
|
97
97
|
if ("depth" in groupOrMerkleProof) {
|
|
98
98
|
index = groupOrMerkleProof.indexOf(commitment);
|
|
99
99
|
if (index === -1) {
|
|
@@ -111,15 +111,15 @@ function generateProof(identity, groupOrMerkleProof, externalNullifier, signal,
|
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
return [4 /*yield*/, groth16.fullProve({
|
|
114
|
-
identityTrapdoor:
|
|
115
|
-
identityNullifier:
|
|
114
|
+
identityTrapdoor: trapdoor,
|
|
115
|
+
identityNullifier: nullifier,
|
|
116
116
|
treePathIndices: merkleProof.pathIndices,
|
|
117
117
|
treeSiblings: merkleProof.siblings,
|
|
118
118
|
externalNullifier: externalNullifier,
|
|
119
119
|
signalHash: genSignalHash(signal)
|
|
120
120
|
}, snarkArtifacts.wasmFilePath, snarkArtifacts.zkeyFilePath)];
|
|
121
121
|
case 1:
|
|
122
|
-
|
|
122
|
+
_b = _c.sent(), proof = _b.proof, publicSignals = _b.publicSignals;
|
|
123
123
|
return [2 /*return*/, {
|
|
124
124
|
proof: proof,
|
|
125
125
|
publicSignals: {
|
package/dist/index.node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module @semaphore-protocol/proof
|
|
3
|
-
* @version 2.
|
|
3
|
+
* @version 2.6.1
|
|
4
4
|
* @file A library to generate and verify Semaphore proofs.
|
|
5
5
|
* @copyright Ethereum Foundation 2022
|
|
6
6
|
* @license MIT
|
|
@@ -91,13 +91,13 @@ function genSignalHash(signal) {
|
|
|
91
91
|
return BigInt(solidity.keccak256(["bytes32"], [signal])) >> BigInt(8);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
function generateProof(
|
|
94
|
+
function generateProof(_a, groupOrMerkleProof, externalNullifier, signal, snarkArtifacts) {
|
|
95
|
+
var trapdoor = _a.trapdoor, nullifier = _a.nullifier, commitment = _a.commitment;
|
|
95
96
|
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
-
var
|
|
97
|
-
return __generator(this, function (
|
|
98
|
-
switch (
|
|
97
|
+
var merkleProof, index, _b, proof, publicSignals;
|
|
98
|
+
return __generator(this, function (_c) {
|
|
99
|
+
switch (_c.label) {
|
|
99
100
|
case 0:
|
|
100
|
-
commitment = identity.generateCommitment();
|
|
101
101
|
if ("depth" in groupOrMerkleProof) {
|
|
102
102
|
index = groupOrMerkleProof.indexOf(commitment);
|
|
103
103
|
if (index === -1) {
|
|
@@ -115,15 +115,15 @@ function generateProof(identity, groupOrMerkleProof, externalNullifier, signal,
|
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
117
|
return [4 /*yield*/, snarkjs.groth16.fullProve({
|
|
118
|
-
identityTrapdoor:
|
|
119
|
-
identityNullifier:
|
|
118
|
+
identityTrapdoor: trapdoor,
|
|
119
|
+
identityNullifier: nullifier,
|
|
120
120
|
treePathIndices: merkleProof.pathIndices,
|
|
121
121
|
treeSiblings: merkleProof.siblings,
|
|
122
122
|
externalNullifier: externalNullifier,
|
|
123
123
|
signalHash: genSignalHash(signal)
|
|
124
124
|
}, snarkArtifacts.wasmFilePath, snarkArtifacts.zkeyFilePath)];
|
|
125
125
|
case 1:
|
|
126
|
-
|
|
126
|
+
_b = _c.sent(), proof = _b.proof, publicSignals = _b.publicSignals;
|
|
127
127
|
return [2 /*return*/, {
|
|
128
128
|
proof: proof,
|
|
129
129
|
publicSignals: {
|
|
@@ -2,4 +2,4 @@ import { Group } from "@semaphore-protocol/group";
|
|
|
2
2
|
import type { Identity } from "@semaphore-protocol/identity";
|
|
3
3
|
import { MerkleProof } from "@zk-kit/incremental-merkle-tree";
|
|
4
4
|
import { BigNumberish, FullProof, SnarkArtifacts } from "./types";
|
|
5
|
-
export default function generateProof(
|
|
5
|
+
export default function generateProof({ trapdoor, nullifier, commitment }: Identity, groupOrMerkleProof: Group | MerkleProof, 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": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "A library to generate and verify Semaphore proofs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.node.js",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"typedoc": "^0.22.11"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@semaphore-protocol/group": "2.
|
|
40
|
-
"@semaphore-protocol/identity": "2.
|
|
39
|
+
"@semaphore-protocol/group": "2.6.1",
|
|
40
|
+
"@semaphore-protocol/identity": "2.6.1"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@ethersproject/bytes": "^5.7.0",
|
package/src/generateProof.ts
CHANGED
|
@@ -6,14 +6,12 @@ import generateSignalHash from "./generateSignalHash"
|
|
|
6
6
|
import { BigNumberish, FullProof, SnarkArtifacts } from "./types"
|
|
7
7
|
|
|
8
8
|
export default async function generateProof(
|
|
9
|
-
|
|
9
|
+
{ trapdoor, nullifier, commitment }: Identity,
|
|
10
10
|
groupOrMerkleProof: Group | MerkleProof,
|
|
11
11
|
externalNullifier: BigNumberish,
|
|
12
12
|
signal: string,
|
|
13
13
|
snarkArtifacts?: SnarkArtifacts
|
|
14
14
|
): Promise<FullProof> {
|
|
15
|
-
const commitment = identity.generateCommitment()
|
|
16
|
-
|
|
17
15
|
let merkleProof: MerkleProof
|
|
18
16
|
|
|
19
17
|
if ("depth" in groupOrMerkleProof) {
|
|
@@ -37,8 +35,8 @@ export default async function generateProof(
|
|
|
37
35
|
|
|
38
36
|
const { proof, publicSignals } = await groth16.fullProve(
|
|
39
37
|
{
|
|
40
|
-
identityTrapdoor:
|
|
41
|
-
identityNullifier:
|
|
38
|
+
identityTrapdoor: trapdoor,
|
|
39
|
+
identityNullifier: nullifier,
|
|
42
40
|
treePathIndices: merkleProof.pathIndices,
|
|
43
41
|
treeSiblings: merkleProof.siblings,
|
|
44
42
|
externalNullifier,
|
package/src/index.test.ts
CHANGED
|
@@ -21,7 +21,6 @@ describe("Proof", () => {
|
|
|
21
21
|
const verificationKeyPath = `./snark-artifacts/semaphore.json`
|
|
22
22
|
|
|
23
23
|
const identity = new Identity()
|
|
24
|
-
const identityCommitment = identity.generateCommitment()
|
|
25
24
|
|
|
26
25
|
let fullProof: FullProof
|
|
27
26
|
let curve: any
|
|
@@ -52,7 +51,7 @@ describe("Proof", () => {
|
|
|
52
51
|
it("Should not generate a Semaphore proof with default snark artifacts with Node.js", async () => {
|
|
53
52
|
const group = new Group(treeDepth)
|
|
54
53
|
|
|
55
|
-
group.addMembers([BigInt(1), BigInt(2),
|
|
54
|
+
group.addMembers([BigInt(1), BigInt(2), identity.commitment])
|
|
56
55
|
|
|
57
56
|
const fun = () => generateProof(identity, group, externalNullifier, signal)
|
|
58
57
|
|
|
@@ -62,7 +61,7 @@ describe("Proof", () => {
|
|
|
62
61
|
it("Should generate a Semaphore proof passing a group as parameter", async () => {
|
|
63
62
|
const group = new Group(treeDepth)
|
|
64
63
|
|
|
65
|
-
group.addMembers([BigInt(1), BigInt(2),
|
|
64
|
+
group.addMembers([BigInt(1), BigInt(2), identity.commitment])
|
|
66
65
|
|
|
67
66
|
fullProof = await generateProof(identity, group, externalNullifier, signal, {
|
|
68
67
|
wasmFilePath,
|
|
@@ -77,7 +76,7 @@ describe("Proof", () => {
|
|
|
77
76
|
it("Should generate a Semaphore proof passing a Merkle proof as parametr", async () => {
|
|
78
77
|
const group = new Group(treeDepth)
|
|
79
78
|
|
|
80
|
-
group.addMembers([BigInt(1), BigInt(2),
|
|
79
|
+
group.addMembers([BigInt(1), BigInt(2), identity.commitment])
|
|
81
80
|
|
|
82
81
|
fullProof = await generateProof(identity, group.generateProofOfMembership(2), externalNullifier, signal, {
|
|
83
82
|
wasmFilePath,
|