You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

37 lines
981 B

const path = require("path");
const tester = require("circom").tester;
const mimcjs = require("../src/mimcsponge.js");
describe("MiMC Sponge Circuit test", function () {
let circuit;
this.timeout(100000);
it("Should check permutation", async () => {
circuit = await tester(path.join(__dirname, "circuits", "mimc_sponge_test.circom"));
const w = await circuit.calculateWitness({xL_in: 1, xR_in: 2, k: 3});
const out2 = mimcjs.hash(1,2,3);
await circuit.assertOut(w, {xL_out: out2.xL, xR_out: out2.xR});
await circuit.checkConstraints(w);
});
it("Should check hash", async () => {
circuit = await tester(path.join(__dirname, "circuits", "mimc_sponge_hash_test.circom"));
const w = await circuit.calculateWitness({ins: [1, 2], k: 0});
const out2 = mimcjs.multiHash([1,2], 0, 3);
await circuit.assertOut(w, {outs: out2});
await circuit.checkConstraints(w);
});
});