circomlib/test/escalarmulany.js
test/escalarmulany.jsRaw
1const chai = require("chai");
2const path = require("path");
3const tester = require("circom").tester;
4const Fr = require("ffjavascript").bn128.Fr;
5
6
7function print(circuit, w, s) {
8 console.log(s + ": " + w[circuit.getSignalIdx(s)]);
9}
10
11describe("Escalarmul test", function () {
12 let circuitEMulAny;
13
14 this.timeout(100000);
15
16 let g = [
17 Fr.e("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
18 Fr.e("16950150798460657717958625567821834550301663161624707787222815936182638968203")
19 ];
20
21 before( async() => {
22 circuitEMulAny = await tester(path.join(__dirname, "circuits", "escalarmulany_test.circom"));
23 });
24
25 it("Should generate Same escalar mul", async () => {
26
27 const w = await circuitEMulAny.calculateWitness({"e": 1, "p": g});
28
29 await circuitEMulAny.checkConstraints(w);
30
31 await circuitEMulAny.assertOut(w, {out: g}, true);
32
33 });
34
35 it("If multiply by order should return 0", async () => {
36
37 const r = Fr.e("2736030358979909402780800718157159386076813972158567259200215660948447373041");
38 const w = await circuitEMulAny.calculateWitness({"e": r, "p": g});
39
40 await circuitEMulAny.checkConstraints(w);
41
42 await circuitEMulAny.assertOut(w, {out: [0,1]}, true);
43
44 });
45
46});
47