circomlib-testvectors/test/mimc.test.js
test/mimc.test.jsRaw
1const chai = require("chai");
2
3const Scalar = require("ffjavascript").Scalar;
4
5const mimc = require("circomlib").mimc7;
6
7const assert = chai.assert;
8
9const SEED = "mimc";
10
11function testvector(method, x, k) {
12 console.log(method);
13 console.log("input:", x, k);
14 console.log("output:", method(x, k));
15}
16
17describe("MiMC7 javascript testvectors", function () {
18 this.timeout(100000);
19 before( async () => {
20 });
21 it("MiMC7 Constants", async () => {
22 let cts = mimc.getConstants(SEED, 91);
23 console.log(cts[1]);
24 });
25 it("MiMC7", async () => {
26 testvector(mimc.hash, 1, 2);
27 testvector(mimc.multiHash,[Scalar.e(1), Scalar.e(2), Scalar.e(3)], Scalar.e(0));
28 testvector(mimc.hash, 12, 45);
29 });
30
31});