Skip to content

Commit 7b3621a

Browse files
authored
refactor: add @zk-kit/artifacts (#788)
* refactor: add `@zk-kit/artifacts` * chore: update `jest.config.ts` * test: increase timeouts * chore: bump `@zk-kit/utils` * fix: bump `@zk-kit/artifacts`
1 parent f3f3688 commit 7b3621a

File tree

6 files changed

+713
-812
lines changed

6 files changed

+713
-812
lines changed

packages/group/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@
4040
},
4141
"dependencies": {
4242
"@zk-kit/imt": "2.0.0-beta.4",
43-
"@zk-kit/utils": "1.0.0-beta.4"
43+
"@zk-kit/utils": "1.0.0-beta.5"
4444
}
4545
}

packages/identity/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"dependencies": {
4242
"@zk-kit/baby-jubjub": "1.0.0",
4343
"@zk-kit/eddsa-poseidon": "1.0.0",
44-
"@zk-kit/utils": "1.0.0-beta.4",
44+
"@zk-kit/utils": "1.0.0-beta.5",
4545
"poseidon-lite": "0.2.0"
4646
}
4747
}

packages/proof/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
},
5454
"dependencies": {
5555
"@semaphore-protocol/utils": "4.0.0-beta.10",
56-
"@zk-kit/utils": "1.0.0-beta.4",
56+
"@zk-kit/artifacts": "^1.3.2",
57+
"@zk-kit/utils": "1.0.0-beta.5",
5758
"ethers": "6.10.0",
5859
"snarkjs": "0.7.4"
5960
}

packages/proof/src/generate-proof.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Identity } from "@semaphore-protocol/identity"
33
import { MAX_DEPTH, MIN_DEPTH } from "@semaphore-protocol/utils/constants"
44
import { requireDefined, requireNumber, requireObject, requireTypes } from "@zk-kit/utils/error-handlers"
55
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"
77
import type { BigNumberish } from "ethers"
88
import { type NumericString, groth16 } from "snarkjs"
99
import hash from "./hash"
@@ -83,7 +83,7 @@ export default async function generateProof(
8383
}
8484

8585
// If the Snark artifacts are not defined they will be automatically downloaded.
86-
snarkArtifacts ??= await maybeGetSemaphoreSnarkArtifacts(merkleTreeDepth)
86+
snarkArtifacts ??= await maybeGetSnarkArtifacts(Project.SEMAPHORE, { parameters: [merkleTreeDepth] })
8787
const { wasm, zkey } = snarkArtifacts
8888

8989
// The index must be converted to a list of indices, 1 for each tree level.

packages/proof/tests/index.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe("Proof", () => {
4646

4747
expect(typeof proof).toBe("object")
4848
expect(BigInt(proof.merkleTreeRoot)).toBe(group.root)
49-
}, 70000)
49+
}, 80000)
5050

5151
it("Should generate a Semaphore proof passing a Merkle proof instead of a group", async () => {
5252
const group = new Group([1n, 2n, identity.commitment])
@@ -55,7 +55,7 @@ describe("Proof", () => {
5555

5656
expect(typeof proof).toBe("object")
5757
expect(BigInt(proof.merkleTreeRoot)).toBe(group.root)
58-
}, 70000)
58+
}, 80000)
5959

6060
it("Should generate a Semaphore proof without passing the tree depth", async () => {
6161
const group = new Group([1n, 2n, identity.commitment])
@@ -64,7 +64,7 @@ describe("Proof", () => {
6464

6565
expect(typeof proof).toBe("object")
6666
expect(BigInt(proof.merkleTreeRoot)).toBe(group.root)
67-
}, 70000)
67+
}, 80000)
6868

6969
it("Should throw an error because snarkArtifacts is not an object", async () => {
7070
const group = new Group([1n, 2n, identity.commitment])
@@ -102,6 +102,6 @@ describe("Proof", () => {
102102
const response = await verifyProof(proof)
103103

104104
expect(response).toBe(true)
105-
})
105+
}, 80_000)
106106
})
107107
})

0 commit comments

Comments
 (0)