Browse Source

All testst finished with c_build

master
Jordi Baylina 5 years ago
parent
commit
7a6b0eda6e
No known key found for this signature in database GPG Key ID: 7480C80C1BE43112
15 changed files with 48 additions and 79 deletions
  1. +3
    -4
      test/babyjub.js
  2. +5
    -5
      test/binsum.js
  3. +1
    -3
      test/eddsa.js
  4. +5
    -4
      test/eddsamimc.js
  5. +2
    -4
      test/eddsaposeidon.js
  6. +3
    -6
      test/escalarmul.js
  7. +2
    -4
      test/escalarmulany.js
  8. +5
    -10
      test/escalarmulfix.js
  9. +1
    -2
      test/mimccircuit.js
  10. +2
    -4
      test/mimcspongecircuit.js
  11. +4
    -10
      test/multiplexer.js
  12. +2
    -4
      test/point2bits.js
  13. +2
    -4
      test/poseidoncircuit.js
  14. +4
    -8
      test/smtprocessor.js
  15. +7
    -7
      test/smtverifier.js

+ 3
- 4
test/babyjub.js

@ -77,8 +77,8 @@ describe("Baby Jub test", function () {
it("Should check (0,1) is a valid poiny", async() => { it("Should check (0,1) is a valid poiny", async() => {
const w = await circuitTest.calculateWitness({x: 0, y:1}); 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() => { 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]}); await circuitPbk.assertOut(w, {Ax : A[0], Ay: A[1]});
// TODO Check constraints
// assert(circuitPbk.checkWitness(w));
await circuitPbk.checkConstraints(w);
}); });
}); });

+ 5
- 5
test/binsum.js

@ -9,13 +9,13 @@ const assert = chai.assert;
describe("Sum test", function () { describe("Sum test", function () {
this.timeout(100000);
this.timeout(100000000);
it("Should create a constant circuit", async () => { it("Should create a constant circuit", async () => {
const circuit = await tester(path.join(__dirname, "circuits", "constants_test.circom")); 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)}); const witness = await circuit.calculateWitness({ "in": bigInt("d807aa98", 16)});
@ -24,9 +24,9 @@ describe("Sum test", function () {
}); });
it("Should create a sum circuit", async () => { it("Should create a sum circuit", async () => {
const circuit = await tester(path.join(__dirname, "circuits", "sum_test.circom")); 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" }); const witness = await circuit.calculateWitness({ "a": "111", "b": "222" });

+ 1
- 3
test/eddsa.js

@ -62,8 +62,6 @@ describe("EdDSA test", function () {
const w = await circuit.calculateWitness({A: aBits, R8: r8Bits, S: sBits, msg: msgBits}); const w = await circuit.calculateWitness({A: aBits, R8: r8Bits, S: sBits, msg: msgBits});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
}); });
}); });

+ 5
- 4
test/eddsamimc.js

@ -37,8 +37,9 @@ describe("EdDSA MiMC test", function () {
S: signature.S, S: signature.S,
M: msg}); M: msg});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
}); });
it("Detect Invalid signature", async () => { it("Detect Invalid signature", async () => {
@ -89,7 +90,7 @@ describe("EdDSA MiMC test", function () {
S: signature.S, S: signature.S,
M: msg}); M: msg});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
}); });
}); });

+ 2
- 4
test/eddsaposeidon.js

@ -38,8 +38,7 @@ describe("EdDSA Poseidon test", function () {
S: signature.S, S: signature.S,
M: msg}); M: msg});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
}); });
it("Detect Invalid signature", async () => { it("Detect Invalid signature", async () => {
@ -90,7 +89,6 @@ describe("EdDSA Poseidon test", function () {
S: signature.S, S: signature.S,
M: msg}); M: msg});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
}); });
}); });

+ 3
- 6
test/escalarmul.js

@ -20,8 +20,7 @@ describe("Exponentioation test", function () {
const w = await circuit.calculateWitness({in: 1}); const w = await circuit.calculateWitness({in: 1});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
let g = [ let g = [
bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"), bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
@ -48,8 +47,7 @@ describe("Exponentioation test", function () {
const w = await circuit.calculateWitness({in: 1}); const w = await circuit.calculateWitness({in: 1});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
let g = [ let g = [
bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"), bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
@ -80,8 +78,7 @@ describe("Exponentioation test", function () {
const w = await circuit.calculateWitness({"in": 31}); const w = await circuit.calculateWitness({"in": 31});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
let g = [ let g = [
bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"), bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),

+ 2
- 4
test/escalarmulany.js

@ -25,8 +25,7 @@ describe("Escalarmul test", function () {
const w = await circuitEMulAny.calculateWitness({"e": 1, "p": g}); const w = await circuitEMulAny.calculateWitness({"e": 1, "p": g});
// TODO
// assert(circuitEMulAny.checkWitness(w));
await circuitEMulAny.checkConstraints(w);
await circuitEMulAny.assertOut(w, {out: g}); await circuitEMulAny.assertOut(w, {out: g});
@ -37,8 +36,7 @@ describe("Escalarmul test", function () {
const r = bigInt("2736030358979909402780800718157159386076813972158567259200215660948447373041"); const r = bigInt("2736030358979909402780800718157159386076813972158567259200215660948447373041");
const w = await circuitEMulAny.calculateWitness({"e": r, "p": g}); 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]}); await circuitEMulAny.assertOut(w, {out: [0,1]});

+ 5
- 10
test/escalarmulfix.js

@ -23,8 +23,7 @@ describe("Escalarmul test", function () {
const w = await circuit.calculateWitness({"e": 0}); const w = await circuit.calculateWitness({"e": 0});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
await circuit.assertOut(w, {out: [0,1]}); await circuit.assertOut(w, {out: [0,1]});
@ -34,8 +33,7 @@ describe("Escalarmul test", function () {
const w = await circuit.calculateWitness({"e": 1}); const w = await circuit.calculateWitness({"e": 1});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
await circuit.assertOut(w, {out: babyjub.Base8}); await circuit.assertOut(w, {out: babyjub.Base8});
@ -51,8 +49,7 @@ describe("Escalarmul test", function () {
const w = await circuit.calculateWitness({"e": s}); const w = await circuit.calculateWitness({"e": s});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
const expectedRes = babyjub.mulPointEscalar(base8, s); const expectedRes = babyjub.mulPointEscalar(base8, s);
@ -72,8 +69,7 @@ describe("Escalarmul test", function () {
const w = await circuit.calculateWitness({"e": s}); const w = await circuit.calculateWitness({"e": s});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
const expectedRes = babyjub.mulPointEscalar(base8, s); const expectedRes = babyjub.mulPointEscalar(base8, s);
@ -85,8 +81,7 @@ describe("Escalarmul test", function () {
const w = await circuit.calculateWitness({"e": babyjub.subOrder }); const w = await circuit.calculateWitness({"e": babyjub.subOrder });
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
await circuit.assertOut(w, {out: [0,1]}); await circuit.assertOut(w, {out: [0,1]});
}); });

+ 1
- 2
test/mimccircuit.js

@ -20,7 +20,6 @@ describe("MiMC Circuit test", function () {
await circuit.assertOut(w, {out: res2}); await circuit.assertOut(w, {out: res2});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
}); });
}); });

+ 2
- 4
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}); 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}); await circuit.assertOut(w, {outs: out2});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
}); });
}); });

+ 4
- 10
test/multiplexer.js

@ -4,7 +4,6 @@ const tester = require("circom").tester;
describe("Mux4 test", function() { describe("Mux4 test", function() {
this.timeout(100000); this.timeout(100000);
it("Should create a constant multiplexer 4", async () => { it("Should create a constant multiplexer 4", async () => {
const circuit = await tester(path.join(__dirname, "circuits", "mux4_1.circom")); 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++) { for (let i=0; i<16; i++) {
const w = await circuit.calculateWitness({ "selector": i }); const w = await circuit.calculateWitness({ "selector": i });
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
await circuit.assertOut(w, {out: ct16[i]}); await circuit.assertOut(w, {out: ct16[i]});
} }
}); });
@ -57,8 +54,7 @@ describe("Mux4 test", function() {
for (let i=0; i<8; i++) { for (let i=0; i<8; i++) {
const w = await circuit.calculateWitness({ "selector": i }); const w = await circuit.calculateWitness({ "selector": i });
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
await circuit.assertOut(w, {out: ct8[i]}); await circuit.assertOut(w, {out: ct8[i]});
} }
@ -77,8 +73,7 @@ describe("Mux4 test", function() {
for (let i=0; i<4; i++) { for (let i=0; i<4; i++) {
const w = await circuit.calculateWitness({ "selector": i }); const w = await circuit.calculateWitness({ "selector": i });
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
await circuit.assertOut(w, {out: ct4[i]}); await circuit.assertOut(w, {out: ct4[i]});
} }
@ -95,8 +90,7 @@ describe("Mux4 test", function() {
for (let i=0; i<2; i++) { for (let i=0; i<2; i++) {
const w = await circuit.calculateWitness({ "selector": i }); const w = await circuit.calculateWitness({ "selector": i });
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
await circuit.assertOut(w, {out: ct2[i]}); await circuit.assertOut(w, {out: ct2[i]});
} }

+ 2
- 4
test/point2bits.js

@ -13,13 +13,11 @@ describe("Point 2 bits test", function() {
it("Should do the both convertions for 8Base", async () => { it("Should do the both convertions for 8Base", async () => {
const w = await circuit.calculateWitness({ in: babyJub.Base8}); 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 () => { it("Should do the both convertions for Zero point", async () => {
const w = await circuit.calculateWitness({ in: [0, 1]}); const w = await circuit.calculateWitness({ in: [0, 1]});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
}); });
}); });

+ 2
- 4
test/poseidoncircuit.js

@ -37,8 +37,7 @@ describe("Poseidon Circuit test", function () {
await circuit.assertOut(w, {out : res2}); await circuit.assertOut(w, {out : res2});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
}); });
it("Should check constrain of hash([3, 4])", async () => { it("Should check constrain of hash([3, 4])", async () => {
@ -51,7 +50,6 @@ describe("Poseidon Circuit test", function () {
await circuit.assertOut(w, {out : res2}); await circuit.assertOut(w, {out : res2});
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
}); });
}); });

+ 4
- 8
test/smtprocessor.js

@ -28,8 +28,7 @@ async function testInsert(tree, key, value, circuit, log ) {
newValue: value newValue: value
}, log); }, log);
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
await circuit.assertOut(w, {newRoot: res.newRoot}); await circuit.assertOut(w, {newRoot: res.newRoot});
@ -51,8 +50,7 @@ async function testDelete(tree, key, circuit) {
newValue: res.delValue newValue: res.delValue
}); });
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
await circuit.assertOut(w, {newRoot: res.newRoot}); await circuit.assertOut(w, {newRoot: res.newRoot});
} }
@ -73,8 +71,7 @@ async function testUpdate(tree, key, newValue, circuit) {
newValue: res.newValue newValue: res.newValue
}); });
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
await circuit.assertOut(w, {newRoot: res.newRoot}); await circuit.assertOut(w, {newRoot: res.newRoot});
} }
@ -190,8 +187,7 @@ describe("SMT test", function () {
const root1 = w[circuit.symbols["main.oldRoot"].idxWit]; const root1 = w[circuit.symbols["main.oldRoot"].idxWit];
const root2 = w[circuit.symbols["main.newRoot"].idxWit]; const root2 = w[circuit.symbols["main.newRoot"].idxWit];
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
assert(root1.equals(root2)); assert(root1.equals(root2));
}); });

+ 7
- 7
test/smtverifier.js

@ -31,8 +31,8 @@ async function testInclusion(tree, key, circuit) {
value: res.foundValue value: res.foundValue
}); });
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
} }
async function testExclusion(tree, key, circuit) { async function testExclusion(tree, key, circuit) {
@ -54,11 +54,11 @@ async function testExclusion(tree, key, circuit) {
value: 0 value: 0
}); });
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
} }
describe("SMT test", function () {
describe("SMT Verifier test", function () {
let circuit; let circuit;
let tree; let tree;
@ -105,8 +105,8 @@ describe("SMT test", function () {
value: 0 value: 0
}); });
// TODO
// assert(circuit.checkWitness(w));
await circuit.checkConstraints(w);
}); });
it("Check inclussion Adria case", async () => { it("Check inclussion Adria case", async () => {

Loading…
Cancel
Save