diff --git a/packages/actions/src/types/snarkjs.d.ts b/packages/actions/src/types/snarkjs.d.ts new file mode 100644 index 00000000..1ac7c1ca --- /dev/null +++ b/packages/actions/src/types/snarkjs.d.ts @@ -0,0 +1,58 @@ +/** Declaration file generated by dts-gen */ + +declare module "snarkjs" { + // eslint-disable-next-line @typescript-eslint/no-use-before-define + export = snarkjs + + declare const snarkjs: { + groth16: { + exportSolidityCallData: any + fullProve: any + prove: any + verify: any + } + plonk: { + exportSolidityCallData: any + fullProve: any + prove: any + setup: any + verify: any + } + powersOfTau: { + beacon: any + challengeContribute: any + contribute: any + convert: any + exportChallenge: any + exportJson: any + importResponse: any + newAccumulator: any + preparePhase2: any + truncate: any + verify: any + } + r1cs: { + exportJson: any + info: any + print: any + } + wtns: { + calculate: any + debug: any + exportJson: any + } + zKey: { + beacon: any + bellmanContribute: any + contribute: any + exportBellman: any + exportJson: any + exportSolidityVerifier: any + exportVerificationKey: any + importBellman: any + newZKey: any + verifyFromInit: any + verifyFromR1cs: any + } + } +} diff --git a/packages/actions/test/unit/verification.test.ts b/packages/actions/test/unit/verification.test.ts index 450a1b83..bf801022 100644 --- a/packages/actions/test/unit/verification.test.ts +++ b/packages/actions/test/unit/verification.test.ts @@ -2,6 +2,8 @@ import chai, { expect } from "chai" import chaiAsPromised from "chai-as-promised" import { cwd } from "process" import { verifyZKey } from "../../src" +import { envType } from "../utils" +import { TestingEnvironment } from "../../src/types/enums" chai.use(chaiAsPromised) @@ -11,11 +13,26 @@ chai.use(chaiAsPromised) describe("Verification", () => { /// @note verify that a zKey is valid describe("verifyzKey", () => { - const zkeyPath = `${cwd()}/packages/actions/test/data/artifacts/circuit_0000.zkey` - const badzkeyPath = `${cwd()}/packages/actions/test/data/artifacts/bad_circuit_0000.zkey` - const wrongZkeyPath = `${cwd()}/packages/actions/test/data/artifacts/notcircuit_0000.zkey` - const potPath = `${cwd()}/packages/actions/test/data/artifacts/powersOfTau28_hez_final_02.ptau` - const r1csPath = `${cwd()}/packages/actions/test/data/artifacts/circuit.r1cs` + let zkeyPath: string = "" + let badzkeyPath: string = "" + let wrongZkeyPath: string = "" + let potPath: string = "" + let r1csPath: string = "" + + if (envType === TestingEnvironment.DEVELOPMENT) { + zkeyPath = `${cwd()}/../actions/test/data/artifacts/circuit_0000.zkey` + badzkeyPath = `${cwd()}/../actions/test/data/artifacts/bad_circuit_0000.zkey` + wrongZkeyPath = `${cwd()}/../actions/test/data/artifacts/notcircuit_0000.zkey` + potPath = `${cwd()}/../actions/test/data/artifacts/powersOfTau28_hez_final_02.ptau` + r1csPath = `${cwd()}/../actions/test/data/artifacts/circuit.r1cs` + } else { + zkeyPath = `${cwd()}/packages/actions/test/data/artifacts/circuit_0000.zkey` + badzkeyPath = `${cwd()}/packages/actions/test/data/artifacts/bad_circuit_0000.zkey` + wrongZkeyPath = `${cwd()}/packages/actions/test/data/artifacts/notcircuit_0000.zkey` + potPath = `${cwd()}/packages/actions/test/data/artifacts/powersOfTau28_hez_final_02.ptau` + r1csPath = `${cwd()}/packages/actions/test/data/artifacts/circuit.r1cs` + } + it("should return true for a valid zkey", async () => { expect(await verifyZKey(r1csPath, zkeyPath, potPath)).to.be.true })