Skip to content

Commit 56c044a

Browse files
committed
updated latest supported Circom version to 2.2.0
1 parent 86f97e8 commit 56c044a

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

src/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ export const COMPILER_AMD_REPOSITORY_URL = "https://github.com/iden3/circom/rele
2929
export const COMPILER_ARM_REPOSITORY_URL = "https://github.com/distributed-lab/circom/releases/download";
3030
export const COMPILER_WASM_REPOSITORY_URL = "https://github.com/distributed-lab/circom-wasm/releases/download";
3131

32-
export const LATEST_SUPPORTED_CIRCOM_VERSION = "2.1.9";
32+
export const LATEST_SUPPORTED_CIRCOM_VERSION = "2.2.0";
3333
export const OLDEST_SUPPORTED_CIRCOM_VERSION = "2.0.5";
3434

3535
export const WASM_COMPILER_VERSIONING: { [key: string]: string } = {
3636
"2.1.8": "0.2.18-rc.3",
3737
"2.1.9": "0.2.19-rc.0",
38+
"2.2.0": "0.2.20-rc.0",
3839
};

src/core/dependencies/parser/CircomTemplateInputsVisitor.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
BusDeclarationContext,
23
CircomValueType,
34
CircomVisitor,
45
ExpressionContext,
@@ -143,6 +144,10 @@ export class CircomTemplateInputsVisitor extends CircomVisitor<void> {
143144
throw new Error("INTERNAL ERROR: SignalIdentifier should have a SignalDeclarationContext as a parent of parent");
144145
}
145146

147+
if (ctx.parentCtx!.parentCtx instanceof BusDeclarationContext) {
148+
return;
149+
}
150+
146151
const signalDeclarationContext = ctx.parentCtx!.parentCtx as SignalDeclarationContext;
147152

148153
let signalType = "intermediate";

test/integration/tasks.test.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { expect } from "chai";
88
import { before } from "mocha";
99
import { stub, SinonStub } from "sinon";
1010

11+
import * as snarkjs from "snarkjs";
12+
1113
import { HardhatUserConfig } from "hardhat/config";
1214

1315
import {
@@ -25,7 +27,6 @@ import { cleanUp, useEnvironment } from "@test-helpers";
2527
import { getNormalizedFullPath } from "@src/utils/path-utils";
2628
import { getCompileCacheEntry, getSetupCacheEntry } from "../utils";
2729

28-
import { HardhatZKit } from "@src/types/hardhat-zkit";
2930
import { BaseCircomCompilerFactory } from "@src/core";
3031
import { CircomCompilerDownloader } from "@src/core/compiler/CircomCompilerDownloader";
3132

@@ -58,7 +59,7 @@ describe("ZKit tasks", async function () {
5859
return circuitFullPaths;
5960
}
6061

61-
async function checkMake(config: HardhatUserConfig, zkit: HardhatZKit) {
62+
async function checkMake(config: HardhatUserConfig) {
6263
const cacheFullPath: string = getNormalizedFullPath(config.paths!.root!, "cache");
6364

6465
expect(fsExtra.readdirSync(cacheFullPath)).to.be.deep.eq([
@@ -70,7 +71,9 @@ describe("ZKit tasks", async function () {
7071
expect(entry).to.be.deep.eq(await getSetupCacheEntry(entry.circuitSourceName, entry.r1csSourcePath));
7172
});
7273

73-
getZkitCircuitFullPaths(config).forEach((path, index) => {
74+
const circuitFullPaths = getZkitCircuitFullPaths(config);
75+
76+
circuitFullPaths.forEach((path, index) => {
7477
expect(fsExtra.readdirSync(path)).to.be.deep.eq([
7578
`${circuitNames[index]}.r1cs`,
7679
`${circuitNames[index]}.sym`,
@@ -84,12 +87,15 @@ describe("ZKit tasks", async function () {
8487
const ptauFullPath: string = getNormalizedFullPath(config.paths!.root!, "zkit/ptau");
8588
expect(fsExtra.readdirSync(ptauFullPath)).to.be.deep.eq(["powers-of-tau-8.ptau"]);
8689

87-
const circuit = await zkit.getCircuit("Multiplier2");
88-
await expect(circuit).with.witnessInputs({ in1: "3", in2: "7" }).to.have.witnessOutputs(["21"]);
90+
const proof = await snarkjs.groth16.fullProve(
91+
{ in: ["3", "7", "2"] },
92+
`${circuitFullPaths[1]}/Multiplier3Arr_js/Multiplier3Arr.wasm`,
93+
`${circuitFullPaths[1]}/Multiplier3Arr.zkey`,
94+
);
8995

90-
const proof = await circuit.generateProof({ in1: "4", in2: "2" });
96+
const verifier = JSON.parse(fsExtra.readFileSync(`${circuitFullPaths[1]}/Multiplier3Arr.vkey.json`).toString());
9197

92-
await expect(circuit).to.verifyProof(proof);
98+
expect(await snarkjs.groth16.verify(verifier, proof.publicSignals, proof.proof)).to.be.true;
9399
}
94100

95101
function updateInclude(filePath: string, newIncludePath: string) {
@@ -342,7 +348,7 @@ describe("ZKit tasks", async function () {
342348
await this.hre.run({ scope: ZKIT_SCOPE_NAME, task: TASK_CIRCUITS_COMPILE });
343349
await this.hre.run({ scope: ZKIT_SCOPE_NAME, task: TASK_CIRCUITS_SETUP });
344350

345-
await checkMake(this.hre.config, this.hre.zkit);
351+
await checkMake(this.hre.config);
346352
});
347353
});
348354

@@ -352,7 +358,7 @@ describe("ZKit tasks", async function () {
352358
it("should correctly compile circuits and generate vkey, zkey files", async function () {
353359
await this.hre.run({ scope: ZKIT_SCOPE_NAME, task: TASK_CIRCUITS_MAKE });
354360

355-
await checkMake(this.hre.config, this.hre.zkit);
361+
await checkMake(this.hre.config);
356362
});
357363
});
358364

@@ -362,7 +368,7 @@ describe("ZKit tasks", async function () {
362368
it("should correctly generate verifiers after running the verifiers task", async function () {
363369
await this.hre.run({ scope: ZKIT_SCOPE_NAME, task: TASK_GENERATE_VERIFIERS });
364370

365-
await checkMake(this.hre.config, this.hre.zkit);
371+
await checkMake(this.hre.config);
366372

367373
const verifiersFullPath: string = getNormalizedFullPath(this.hre.config.paths.root, "contracts/verifiers");
368374
expect(fsExtra.readdirSync(verifiersFullPath)).to.be.deep.eq(circuitNames.map((name) => `${name}Verifier.sol`));
@@ -392,7 +398,7 @@ describe("ZKit tasks", async function () {
392398
const cacheDir: string = getNormalizedFullPath(this.hre.config.paths.root, "cache");
393399
const zkitDir: string = getNormalizedFullPath(this.hre.config.paths.root, "zkit");
394400

395-
await checkMake(this.hre.config, this.hre.zkit);
401+
await checkMake(this.hre.config);
396402

397403
await this.hre.run({ scope: ZKIT_SCOPE_NAME, task: TASK_ZKIT_CLEAN });
398404

0 commit comments

Comments
 (0)