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