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.

51 lines
1.5 KiB

  1. const chai = require("chai");
  2. const path = require("path");
  3. const wasm_tester = require("circom_tester").wasm;
  4. const F1Field = require("ffjavascript").F1Field;
  5. const Scalar = require("ffjavascript").Scalar;
  6. exports.p = Scalar.fromString("21888242871839275222246405745257275088548364400416034343698204186575808495617");
  7. const Fr = new F1Field(exports.p);
  8. function print(circuit, w, s) {
  9. console.log(s + ": " + w[circuit.getSignalIdx(s)]);
  10. }
  11. describe("Escalarmul test", function () {
  12. let circuitEMulAny;
  13. this.timeout(100000);
  14. let g;
  15. before( async() => {
  16. circuitEMulAny = await wasm_tester(path.join(__dirname, "circuits", "escalarmulany_test.circom"));
  17. g = [
  18. Fr.e("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
  19. Fr.e("16950150798460657717958625567821834550301663161624707787222815936182638968203")
  20. ]
  21. });
  22. it("Should generate Same escalar mul", async () => {
  23. const w = await circuitEMulAny.calculateWitness({"e": 1, "p": g});
  24. await circuitEMulAny.checkConstraints(w);
  25. await circuitEMulAny.assertOut(w, {out: g}, true);
  26. });
  27. it("If multiply by order should return 0", async () => {
  28. const r = Fr.e("2736030358979909402780800718157159386076813972158567259200215660948447373041");
  29. const w = await circuitEMulAny.calculateWitness({"e": r, "p": g});
  30. await circuitEMulAny.checkConstraints(w);
  31. await circuitEMulAny.assertOut(w, {out: [0,1]}, true);
  32. });
  33. });