2018-12-06 19:32:49 +03:00
|
|
|
const chai = require("chai");
|
|
|
|
const path = require("path");
|
2019-12-14 22:32:45 +03:00
|
|
|
const tester = require("circom").tester;
|
2018-12-06 19:32:49 +03:00
|
|
|
|
|
|
|
const mimcjs = require("../src/mimc7.js");
|
|
|
|
|
|
|
|
describe("MiMC Circuit test", function () {
|
|
|
|
let circuit;
|
|
|
|
|
|
|
|
this.timeout(100000);
|
|
|
|
|
|
|
|
before( async () => {
|
2019-12-14 22:32:45 +03:00
|
|
|
circuit = await tester(path.join(__dirname, "circuits", "mimc_test.circom"));
|
2018-12-06 19:32:49 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it("Should check constrain", async () => {
|
2020-03-26 21:24:20 +03:00
|
|
|
const w = await circuit.calculateWitness({x_in: 1, k: 2}, true);
|
2018-12-06 19:32:49 +03:00
|
|
|
|
|
|
|
const res2 = mimcjs.hash(1,2,91);
|
|
|
|
|
2019-12-14 22:32:45 +03:00
|
|
|
await circuit.assertOut(w, {out: res2});
|
2018-12-06 19:32:49 +03:00
|
|
|
|
2019-12-16 23:35:52 +03:00
|
|
|
await circuit.checkConstraints(w);
|
2018-12-06 19:32:49 +03:00
|
|
|
});
|
|
|
|
});
|