circomlib/test/mimccircuit.js

26 lines
625 B
JavaScript
Raw Permalink Normal View History

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