diff --git a/test/babyjub.js b/test/babyjub.js index d41c039..e8a84a0 100644 --- a/test/babyjub.js +++ b/test/babyjub.js @@ -77,8 +77,8 @@ describe("Baby Jub test", function () { 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 @@ describe("Baby Jub test", function () { await circuitPbk.assertOut(w, {Ax : A[0], Ay: A[1]}); - // TODO Check constraints - // assert(circuitPbk.checkWitness(w)); + await circuitPbk.checkConstraints(w); }); }); diff --git a/test/binsum.js b/test/binsum.js index 32408f1..c0e94a8 100644 --- a/test/binsum.js +++ b/test/binsum.js @@ -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 @@ describe("Sum test", function () { }); 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" }); diff --git a/test/eddsa.js b/test/eddsa.js index 81f79f0..c74ebe9 100644 --- a/test/eddsa.js +++ b/test/eddsa.js @@ -62,8 +62,6 @@ describe("EdDSA test", function () { const w = await circuit.calculateWitness({A: aBits, R8: r8Bits, S: sBits, msg: msgBits}); - // TODO - // assert(circuit.checkWitness(w)); - + await circuit.checkConstraints(w); }); }); diff --git a/test/eddsamimc.js b/test/eddsamimc.js index 62f202e..bdb56fc 100644 --- a/test/eddsamimc.js +++ b/test/eddsamimc.js @@ -37,8 +37,9 @@ describe("EdDSA MiMC test", function () { S: signature.S, M: msg}); - // TODO - // assert(circuit.checkWitness(w)); + + await circuit.checkConstraints(w); + }); it("Detect Invalid signature", async () => { @@ -89,7 +90,7 @@ describe("EdDSA MiMC test", function () { S: signature.S, M: msg}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); + }); }); diff --git a/test/eddsaposeidon.js b/test/eddsaposeidon.js index 2360cd7..bcd12e5 100644 --- a/test/eddsaposeidon.js +++ b/test/eddsaposeidon.js @@ -38,8 +38,7 @@ describe("EdDSA Poseidon test", function () { S: signature.S, M: msg}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); }); it("Detect Invalid signature", async () => { @@ -90,7 +89,6 @@ describe("EdDSA Poseidon test", function () { S: signature.S, M: msg}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); }); }); diff --git a/test/escalarmul.js b/test/escalarmul.js index 955057b..ec60597 100644 --- a/test/escalarmul.js +++ b/test/escalarmul.js @@ -20,8 +20,7 @@ describe("Exponentioation test", function () { const w = await circuit.calculateWitness({in: 1}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); let g = [ bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"), @@ -48,8 +47,7 @@ describe("Exponentioation test", function () { const w = await circuit.calculateWitness({in: 1}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); let g = [ bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"), @@ -80,8 +78,7 @@ describe("Exponentioation test", function () { const w = await circuit.calculateWitness({"in": 31}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); let g = [ bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"), diff --git a/test/escalarmulany.js b/test/escalarmulany.js index a3e5973..ef3dfc9 100644 --- a/test/escalarmulany.js +++ b/test/escalarmulany.js @@ -25,8 +25,7 @@ describe("Escalarmul test", function () { 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 @@ describe("Escalarmul test", function () { 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]}); diff --git a/test/escalarmulfix.js b/test/escalarmulfix.js index 28f4769..2d0a35c 100644 --- a/test/escalarmulfix.js +++ b/test/escalarmulfix.js @@ -23,8 +23,7 @@ describe("Escalarmul test", function () { 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 @@ describe("Escalarmul test", function () { 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 @@ describe("Escalarmul test", function () { 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 @@ describe("Escalarmul test", function () { 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 @@ describe("Escalarmul test", function () { const w = await circuit.calculateWitness({"e": babyjub.subOrder }); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); await circuit.assertOut(w, {out: [0,1]}); }); diff --git a/test/mimccircuit.js b/test/mimccircuit.js index d579650..ae14125 100644 --- a/test/mimccircuit.js +++ b/test/mimccircuit.js @@ -20,7 +20,6 @@ describe("MiMC Circuit test", function () { await circuit.assertOut(w, {out: res2}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); }); }); diff --git a/test/mimcspongecircuit.js b/test/mimcspongecircuit.js index 405f153..3205534 100644 --- a/test/mimcspongecircuit.js +++ b/test/mimcspongecircuit.js @@ -19,8 +19,7 @@ describe("MiMC Sponge Circuit test", function () { 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 @@ describe("MiMC Sponge Circuit test", function () { await circuit.assertOut(w, {outs: out2}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); }); }); diff --git a/test/multiplexer.js b/test/multiplexer.js index 0f14c3d..67b1975 100644 --- a/test/multiplexer.js +++ b/test/multiplexer.js @@ -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 @@ describe("Mux4 test", function() { 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 @@ describe("Mux4 test", function() { 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 @@ describe("Mux4 test", function() { 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 @@ describe("Mux4 test", function() { 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]}); } diff --git a/test/point2bits.js b/test/point2bits.js index c86d46e..48eb88e 100644 --- a/test/point2bits.js +++ b/test/point2bits.js @@ -13,13 +13,11 @@ describe("Point 2 bits test", function() { 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); }); }); diff --git a/test/poseidoncircuit.js b/test/poseidoncircuit.js index 0d7654e..f1799aa 100644 --- a/test/poseidoncircuit.js +++ b/test/poseidoncircuit.js @@ -37,8 +37,7 @@ describe("Poseidon Circuit test", function () { 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 @@ describe("Poseidon Circuit test", function () { await circuit.assertOut(w, {out : res2}); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); }); }); diff --git a/test/smtprocessor.js b/test/smtprocessor.js index a1caf96..10b9beb 100644 --- a/test/smtprocessor.js +++ b/test/smtprocessor.js @@ -28,8 +28,7 @@ async function testInsert(tree, key, value, circuit, log ) { newValue: value }, log); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); await circuit.assertOut(w, {newRoot: res.newRoot}); @@ -51,8 +50,7 @@ async function testDelete(tree, key, circuit) { newValue: res.delValue }); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); await circuit.assertOut(w, {newRoot: res.newRoot}); } @@ -73,8 +71,7 @@ async function testUpdate(tree, key, newValue, circuit) { newValue: res.newValue }); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); await circuit.assertOut(w, {newRoot: res.newRoot}); } @@ -190,8 +187,7 @@ describe("SMT test", function () { 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)); }); diff --git a/test/smtverifier.js b/test/smtverifier.js index 9432f47..475dd4d 100644 --- a/test/smtverifier.js +++ b/test/smtverifier.js @@ -31,8 +31,8 @@ async function testInclusion(tree, key, circuit) { value: res.foundValue }); - // TODO - // assert(circuit.checkWitness(w)); + await circuit.checkConstraints(w); + } async function testExclusion(tree, key, circuit) { @@ -54,11 +54,11 @@ async function testExclusion(tree, key, circuit) { 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 @@ describe("SMT test", function () { value: 0 }); - // TODO - // assert(circuit.checkWitness(w)); + + await circuit.checkConstraints(w); }); it("Check inclussion Adria case", async () => {