-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(verification): added actions helper to extract artifacts from a …
…zKey Added helper functions to extract the solidity verifier and the verification key from a zkey
- Loading branch information
Showing
4 changed files
with
138 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import chai, { expect } from "chai" | ||
import chaiAsPromised from "chai-as-promised" | ||
import dotenv from "dotenv" | ||
import { cwd } from "process" | ||
import fs from "fs" | ||
import { exportVerifierAndVKey, exportVerifierContract, exportVkey } from "../../src" | ||
import { envType } from "../utils" | ||
import { TestingEnvironment } from "../../src/types/enums" | ||
|
||
chai.use(chaiAsPromised) | ||
dotenv.config() | ||
|
||
/** | ||
* Unit test for Verification utilities. | ||
*/ | ||
|
||
describe("Verification utilities", () => { | ||
const finalZkeyPath = `${cwd()}/packages/actions/test/data/circuit-small_00001.zkey` | ||
const verifierExportPath = `${cwd()}/packages/actions/test/data/verifier.sol` | ||
const vKeyExportPath = `${cwd()}/packages/actions/test/data/vkey.json` | ||
const solidityVersion = "0.8.10" | ||
describe("exportVerifierContract", () => { | ||
if (envType === TestingEnvironment.PRODUCTION) { | ||
it("should export the verifier contract", async () => { | ||
await exportVerifierContract(solidityVersion, finalZkeyPath, verifierExportPath) | ||
expect(fs.existsSync(verifierExportPath)).to.be.true | ||
}) | ||
} | ||
it("should fail when the zkey is not found", async () => { | ||
await expect(exportVerifierContract("0.8.0", "invalid-path", verifierExportPath)).to.be.rejected | ||
}) | ||
}) | ||
describe("exportVkey", () => { | ||
if (envType === TestingEnvironment.PRODUCTION) { | ||
it("should export the vkey", async () => { | ||
await exportVkey(finalZkeyPath, vKeyExportPath) | ||
expect(fs.existsSync(vKeyExportPath)).to.be.true | ||
}) | ||
} | ||
it("should fail when the zkey is not found", async () => { | ||
await expect(exportVkey("invalid-path", vKeyExportPath)).to.be.rejected | ||
}) | ||
}) | ||
describe("exportVerifierAndVKey", () => { | ||
if (envType === TestingEnvironment.PRODUCTION) { | ||
it("should export the verifier contract and the vkey", async () => { | ||
await exportVerifierAndVKey("0.8.0", finalZkeyPath, verifierExportPath, vKeyExportPath) | ||
expect(fs.existsSync(verifierExportPath)).to.be.true | ||
expect(fs.existsSync(vKeyExportPath)).to.be.true | ||
}) | ||
} | ||
it("should fail when the zkey is not found", async () => { | ||
await expect(exportVerifierAndVKey("0.8.0", "invalid-path", verifierExportPath, vKeyExportPath)).to.be | ||
.rejected | ||
}) | ||
}) | ||
afterAll(() => { | ||
if (fs.existsSync(verifierExportPath)) { | ||
fs.unlinkSync(verifierExportPath) | ||
} | ||
if (fs.existsSync(vKeyExportPath)) { | ||
fs.unlinkSync(vKeyExportPath) | ||
} | ||
}) | ||
}) |