circomlib/test/escalarmulany.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

const chai = require("chai");
const path = require("path");
2019-12-14 22:32:45 +03:00
const bigInt = require("big-integer");
const tester = require("circom").tester;
function print(circuit, w, s) {
console.log(s + ": " + w[circuit.getSignalIdx(s)]);
}
describe("Escalarmul test", function () {
let circuitEMulAny;
this.timeout(100000);
let g = [
2019-12-14 22:32:45 +03:00
bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
bigInt("16950150798460657717958625567821834550301663161624707787222815936182638968203")
];
before( async() => {
2019-12-14 22:32:45 +03:00
circuitEMulAny = await tester(path.join(__dirname, "circuits", "escalarmulany_test.circom"));
});
it("Should generate Same escalar mul", async () => {
2019-12-14 22:32:45 +03:00
const w = await circuitEMulAny.calculateWitness({"e": 1, "p": g});
2019-12-16 23:35:52 +03:00
await circuitEMulAny.checkConstraints(w);
2019-12-14 22:32:45 +03:00
await circuitEMulAny.assertOut(w, {out: g});
});
it("If multiply by order should return 0", async () => {
const r = bigInt("2736030358979909402780800718157159386076813972158567259200215660948447373041");
2019-12-14 22:32:45 +03:00
const w = await circuitEMulAny.calculateWitness({"e": r, "p": g});
2019-12-16 23:35:52 +03:00
await circuitEMulAny.checkConstraints(w);
2019-12-14 22:32:45 +03:00
await circuitEMulAny.assertOut(w, {out: [0,1]});
});
});