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