All testst finished with c_build
jump to
@@ -77,8 +77,8 @@ });
it("Should check (0,1) is a valid poiny", async() => { const w = await circuitTest.calculateWitness({x: 0, y:1}); - // TODO Check constraints - // assert(circuitTest.checkWitness(w)); + + await circuitTest.checkConstraints(w); }); it("Should check (1,0) is an invalid point", async() => {@@ -106,8 +106,7 @@ const w = await circuitPbk.calculateWitness(input);
await circuitPbk.assertOut(w, {Ax : A[0], Ay: A[1]}); - // TODO Check constraints - // assert(circuitPbk.checkWitness(w)); + await circuitPbk.checkConstraints(w); }); });
@@ -9,13 +9,13 @@ const assert = chai.assert;
describe("Sum test", function () { - this.timeout(100000); + this.timeout(100000000); it("Should create a constant circuit", async () => { const circuit = await tester(path.join(__dirname, "circuits", "constants_test.circom")); + await circuit.loadConstraints(); - // TODO - // assert.equal(cirDef.nVars, 2); + assert.equal(circuit.nWires, 2); const witness = await circuit.calculateWitness({ "in": bigInt("d807aa98", 16)});@@ -24,9 +24,9 @@ assert(witness[1].equals(bigInt("d807aa98", 16)));
}); it("Should create a sum circuit", async () => { const circuit = await tester(path.join(__dirname, "circuits", "sum_test.circom")); + await circuit.loadConstraints(); - // TODO - // assert.equal(cirDef.nVars, 97); // 32 (in1) + 32(in2) + 32(out) + 1 (carry) + assert.equal(circuit.nWires, 97); // 32 (in1) + 32(in2) + 32(out) + 1 (carry) const witness = await circuit.calculateWitness({ "a": "111", "b": "222" });
@@ -62,8 +62,6 @@ const aBits = buffer2bits(pPubKey);
const w = await circuit.calculateWitness({A: aBits, R8: r8Bits, S: sBits, msg: msgBits}); - // TODO - // assert(circuit.checkWitness(w)); - + await circuit.checkConstraints(w); }); });
@@ -37,8 +37,9 @@ R8y: signature.R8[1],
S: signature.S, M: msg}); - // TODO - // assert(circuit.checkWitness(w)); + + await circuit.checkConstraints(w); + }); it("Detect Invalid signature", async () => {@@ -89,7 +90,7 @@ R8y: signature.R8[1],
S: signature.S, M: msg}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); + }); });
@@ -38,8 +38,7 @@ R8y: signature.R8[1],
S: signature.S, M: msg}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); }); it("Detect Invalid signature", async () => {@@ -90,7 +89,6 @@ R8y: signature.R8[1],
S: signature.S, M: msg}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); }); });
@@ -20,8 +20,7 @@ const circuit = await tester(path.join(__dirname, "circuits", "escalarmulw4table_test.circom"));
const w = await circuit.calculateWitness({in: 1}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); let g = [ bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),@@ -48,8 +47,7 @@ const circuit = await tester(path.join(__dirname, "circuits", "escalarmulw4table_test3.circom"));
const w = await circuit.calculateWitness({in: 1}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); let g = [ bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),@@ -80,8 +78,7 @@ const circuit = await tester(path.join(__dirname, "circuits", "escalarmul_test.circom"));
const w = await circuit.calculateWitness({"in": 31}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); let g = [ bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
@@ -25,8 +25,7 @@ it("Should generate Same escalar mul", async () => {
const w = await circuitEMulAny.calculateWitness({"e": 1, "p": g}); - // TODO - // assert(circuitEMulAny.checkWitness(w)); + await circuitEMulAny.checkConstraints(w); await circuitEMulAny.assertOut(w, {out: g});@@ -37,8 +36,7 @@
const r = bigInt("2736030358979909402780800718157159386076813972158567259200215660948447373041"); const w = await circuitEMulAny.calculateWitness({"e": r, "p": g}); - // TODO - // assert(circuitEMulAny.checkWitness(w)); + await circuitEMulAny.checkConstraints(w); await circuitEMulAny.assertOut(w, {out: [0,1]});
@@ -23,8 +23,7 @@ it("Should generate Same escalar mul", async () => {
const w = await circuit.calculateWitness({"e": 0}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); await circuit.assertOut(w, {out: [0,1]});@@ -34,8 +33,7 @@ it("Should generate Same escalar mul", async () => {
const w = await circuit.calculateWitness({"e": 1}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); await circuit.assertOut(w, {out: babyjub.Base8});@@ -51,8 +49,7 @@ ];
const w = await circuit.calculateWitness({"e": s}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); const expectedRes = babyjub.mulPointEscalar(base8, s);@@ -72,8 +69,7 @@ const s = bigInt(i);
const w = await circuit.calculateWitness({"e": s}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); const expectedRes = babyjub.mulPointEscalar(base8, s);@@ -85,8 +81,7 @@ it("If multiply by order should return 0", async () => {
const w = await circuit.calculateWitness({"e": babyjub.subOrder }); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); await circuit.assertOut(w, {out: [0,1]}); });
@@ -20,7 +20,6 @@ const res2 = mimcjs.hash(1,2,91);
await circuit.assertOut(w, {out: res2}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); }); });
@@ -19,8 +19,7 @@ const out2 = mimcjs.hash(1,2,3);
await circuit.assertOut(w, {xL_out: out2.xL, xR_out: out2.xR}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); });@@ -33,7 +32,6 @@ const out2 = mimcjs.multiHash([1,2], 0, 3);
await circuit.assertOut(w, {outs: out2}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); }); });
@@ -4,7 +4,6 @@ const tester = require("circom").tester;
describe("Mux4 test", function() { this.timeout(100000); - it("Should create a constant multiplexer 4", async () => { const circuit = await tester(path.join(__dirname, "circuits", "mux4_1.circom"));@@ -31,11 +30,9 @@
for (let i=0; i<16; i++) { const w = await circuit.calculateWitness({ "selector": i }); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); await circuit.assertOut(w, {out: ct16[i]}); - } });@@ -57,8 +54,7 @@
for (let i=0; i<8; i++) { const w = await circuit.calculateWitness({ "selector": i }); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); await circuit.assertOut(w, {out: ct8[i]}); }@@ -77,8 +73,7 @@
for (let i=0; i<4; i++) { const w = await circuit.calculateWitness({ "selector": i }); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); await circuit.assertOut(w, {out: ct4[i]}); }@@ -95,8 +90,7 @@
for (let i=0; i<2; i++) { const w = await circuit.calculateWitness({ "selector": i }); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); await circuit.assertOut(w, {out: ct2[i]}); }
@@ -13,13 +13,11 @@ });
it("Should do the both convertions for 8Base", async () => { const w = await circuit.calculateWitness({ in: babyJub.Base8}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); }); it("Should do the both convertions for Zero point", async () => { const w = await circuit.calculateWitness({ in: [0, 1]}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); }); });
@@ -37,8 +37,7 @@ assert.equal("12242166908188651009877250812424843524687801523336557272219921456462821518061", res2.toString());
await circuit.assertOut(w, {out : res2}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); }); it("Should check constrain of hash([3, 4])", async () => {@@ -51,7 +50,6 @@ assert.equal("17185195740979599334254027721507328033796809509313949281114643312710535000993", res2.toString());
await circuit.assertOut(w, {out : res2}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); }); });
@@ -28,8 +28,7 @@ newKey: key,
newValue: value }, log); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); await circuit.assertOut(w, {newRoot: res.newRoot});@@ -51,8 +50,7 @@ newKey: res.delKey,
newValue: res.delValue }); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); await circuit.assertOut(w, {newRoot: res.newRoot}); }@@ -73,8 +71,7 @@ newKey: res.newKey,
newValue: res.newValue }); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); await circuit.assertOut(w, {newRoot: res.newRoot}); }@@ -190,8 +187,7 @@
const root1 = w[circuit.symbols["main.oldRoot"].idxWit]; const root2 = w[circuit.symbols["main.newRoot"].idxWit]; - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); assert(root1.equals(root2)); });
@@ -31,8 +31,8 @@ key: key,
value: res.foundValue }); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); + } async function testExclusion(tree, key, circuit) {@@ -54,11 +54,11 @@ key: key,
value: 0 }); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); + } -describe("SMT test", function () { +describe("SMT Verifier test", function () { let circuit; let tree;@@ -105,8 +105,8 @@ key: 44,
value: 0 }); - // TODO - // assert(circuit.checkWitness(w)); + + await circuit.checkConstraints(w); }); it("Check inclussion Adria case", async () => {