Skip to content

Commit

Permalink
check that ultraplonk still works
Browse files Browse the repository at this point in the history
  • Loading branch information
olehmisar committed Feb 5, 2025
1 parent f89e719 commit 7f31960
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/fixture-projects/hardhat-project/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const config: HardhatUserConfig = {
},
noir: {
version: TEST_NOIR_VERSION,
flavor: ["ultra_keccak_honk", "ultra_plonk"],
},
};

Expand Down
35 changes: 35 additions & 0 deletions test/noir.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// tslint:disable-next-line no-implicit-dependencies
import { UltraPlonkBackend } from "@aztec/bb.js";
import { assert, expect } from "chai";
import fs from "fs";
import { TASK_CLEAN, TASK_COMPILE } from "hardhat/builtin-tasks/task-names";
Expand Down Expand Up @@ -76,6 +77,40 @@ describe("Integration tests examples", function () {
});
expect(resultJs).to.eq(true);
});

it("proves and verifies on-chain ultra_plonk", async function () {
await this.hre.run("compile");

// Deploy a verifier contract
const contractFactory =
await this.hre.ethers.getContractFactory("UltraVerifier");
const contract = await contractFactory.deploy();
await contract.waitForDeployment();

// Generate a proof
const { noir, backend } = await this.hre.noir.getCircuit(
"my_circuit",
UltraPlonkBackend,
);
const input = { x: 1, y: 2 };
const { witness } = await noir.execute(input);
const { proof, publicInputs } = await backend.generateProof(witness);
// it matches because we marked y as `pub` in `main.nr`
expect(BigInt(publicInputs[0])).to.eq(BigInt(input.y));

// Verify the proof on-chain
const result = await contract.verify(proof, [
this.hre.ethers.toBeHex(input.y, 32),
]);
expect(result).to.eq(true);

// You can also verify in JavaScript.
const resultJs = await backend.verifyProof({
proof,
publicInputs: [String(input.y)],
});
expect(resultJs).to.eq(true);
});
});

describe("HardhatConfig extension", function () {
Expand Down

0 comments on commit 7f31960

Please sign in to comment.