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

  1. const path = require("path");
  2. const tester = require("circom").tester;
  3. const mimcjs = require("../src/mimcsponge.js");
  4. describe("MiMC Sponge Circuit test", function () {
  5. let circuit;
  6. this.timeout(100000);
  7. it("Should check permutation", async () => {
  8. circuit = await tester(path.join(__dirname, "circuits", "mimc_sponge_test.circom"));
  9. const w = await circuit.calculateWitness({xL_in: 1, xR_in: 2, k: 3});
  10. const out2 = mimcjs.hash(1,2,3);
  11. await circuit.assertOut(w, {xL_out: out2.xL, xR_out: out2.xR});
  12. await circuit.checkConstraints(w);
  13. });
  14. it("Should check hash", async () => {
  15. circuit = await tester(path.join(__dirname, "circuits", "mimc_sponge_hash_test.circom"));
  16. const w = await circuit.calculateWitness({ins: [1, 2], k: 0});
  17. const out2 = mimcjs.multiHash([1,2], 0, 3);
  18. await circuit.assertOut(w, {outs: out2});
  19. await circuit.checkConstraints(w);
  20. });
  21. });