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