2024-12-05 17:53:43 +08:00
|
|
|
// import chai from "chai";
|
|
|
|
// import {createCode, abi} from "../src/mimcsponge_gencontract.js";
|
|
|
|
// import { ethers } from "ethers";
|
|
|
|
// import ganache from "ganache";
|
2021-10-30 13:57:29 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// import buildMimcSponge from "../src/mimcsponge.js";
|
2021-10-06 11:28:14 +02:00
|
|
|
|
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// const assert = chai.assert;
|
|
|
|
// const log = (msg) => { if (process.env.MOCHA_VERBOSE) console.log(msg); };
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// const SEED = "mimcsponge";
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// describe("MiMC Sponge Smart contract test", () => {
|
|
|
|
// let mimc;
|
|
|
|
// let mimcJS;
|
|
|
|
// let account;
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// before(async () => {
|
|
|
|
// const provider = new ethers.providers.Web3Provider(ganache.provider());
|
2021-10-30 13:57:29 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// account = provider.getSigner(0);
|
|
|
|
// mimcJS = await buildMimcSponge();
|
|
|
|
// });
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// it("Should deploy the contract", async () => {
|
2021-10-30 13:57:29 +02:00
|
|
|
|
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// const C = new ethers.ContractFactory(
|
|
|
|
// abi,
|
|
|
|
// createCode(SEED, 220),
|
|
|
|
// account
|
|
|
|
// );
|
2021-10-30 13:57:29 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// mimc = await C.deploy();
|
|
|
|
// });
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// it("Shold calculate the mimc correctly", async () => {
|
2021-10-06 11:28:14 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// const res = await mimc["MiMCSponge"](1,2, 3);
|
2021-10-30 13:57:29 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// // console.log("Cir: " + bigInt(res.toString(16)).toString(16));
|
2021-10-30 13:57:29 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// const res2 = mimcJS.hash(1,2, 3);
|
|
|
|
// // console.log("Ref: " + bigInt(res2).toString(16));
|
2021-10-30 13:57:29 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// assert.equal(res.xL.toString(), mimcJS.F.toString(res2.xL));
|
|
|
|
// assert.equal(res.xR.toString(), mimcJS.F.toString(res2.xR));
|
2021-10-30 13:57:29 +02:00
|
|
|
|
2024-12-05 17:53:43 +08:00
|
|
|
// });
|
|
|
|
// });
|
2021-10-06 11:28:14 +02:00
|
|
|
|