From 18f330414ef42ee43364fe0e4810801b307abd9e Mon Sep 17 00:00:00 2001 From: Artem Chystiakov Date: Thu, 10 Oct 2024 17:45:17 +0300 Subject: [PATCH] fix readme --- README.md | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 1915e11..25b25d1 100644 --- a/README.md +++ b/README.md @@ -189,31 +189,28 @@ component main = Multiplier(); ```ts -// file location: ./scripts/multiplier.test.ts +// file location: ./test/multiplier.test.ts import { zkit } from "hardhat"; // hardhat-zkit plugin import { expect } from "chai"; // chai-zkit extension import { Multiplier } from "@zkit"; // zktype circuit-object -async function main() { - const circuit: Multiplier = await zkit.getCircuit("Multiplier"); - // or await zkit.getCircuit("circuits/multiplier.circom:Multiplier"); +describe("Multiplier", () => { + it("should test the circuit", async () => { + const circuit: Multiplier = await zkit.getCircuit("Multiplier"); + // or await zkit.getCircuit("circuits/multiplier.circom:Multiplier"); - // witness testing - await expect(circuit) - .with.witnessInputs({ in1: "3", in2: "7" }) - .to.have.witnessOutputs({ out: "21" }); + // witness testing + await expect(circuit) + .with.witnessInputs({ in1: "3", in2: "7" }) + .to.have.witnessOutputs({ out: "21" }); - // proof testing - const proof = await circuit.generateProof({ in1: "4", in2: "2" }); - await expect(circuit).to.verifyProof(proof); + // proof testing + const proof = await circuit.generateProof({ in1: "4", in2: "2" }); - console.log("OK"); -} - -main() - .then() - .catch((e) => console.log(e)); + await expect(circuit).to.verifyProof(proof); + }); +}); ``` @@ -228,7 +225,7 @@ npx hardhat zkit make This command will install the newest compatible Circom compiler, compile the provided circuit, download the necessary `ptau` file regarding the number of circuit's constraints, build the required `zkey` and `vkey` files, and generate TypeScript object wrappers to enable full typization of signals and ZK proofs. -Afterward, you may run the provided hardhat script via `npx hardhat run ./scripts/multiplier.test.ts`. +Afterward, copy the provided script to the `test` directory and run the tests via `npx hardhat test`. You will see that all the tests are passing! > Check out the [Medium blog post](https://medium.com/@Arvolear/introducing-hardhat-zkit-how-did-you-even-use-circom-before-a7b463a5575b) to learn more.