|
@ -15,11 +15,11 @@ describe("Comparators test", function () { |
|
|
const circuit = await tester(path.join(__dirname, "circuits", "iszero.circom")); |
|
|
const circuit = await tester(path.join(__dirname, "circuits", "iszero.circom")); |
|
|
|
|
|
|
|
|
let witness; |
|
|
let witness; |
|
|
witness = await circuit.calculateWitness({ "in": 111}); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": 111}, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": 0 }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": 0 }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
}); |
|
|
}); |
|
@ -27,11 +27,11 @@ describe("Comparators test", function () { |
|
|
const circuit = await tester(path.join(__dirname, "circuits", "isequal.circom")); |
|
|
const circuit = await tester(path.join(__dirname, "circuits", "isequal.circom")); |
|
|
|
|
|
|
|
|
let witness; |
|
|
let witness; |
|
|
witness = await circuit.calculateWitness({ "in": [111,222] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [111,222] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [444,444] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [444,444] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
}); |
|
|
}); |
|
@ -39,35 +39,35 @@ describe("Comparators test", function () { |
|
|
const circuit = await tester(path.join(__dirname, "circuits", "lessthan.circom")); |
|
|
const circuit = await tester(path.join(__dirname, "circuits", "lessthan.circom")); |
|
|
|
|
|
|
|
|
let witness; |
|
|
let witness; |
|
|
witness = await circuit.calculateWitness({ "in": [333,444] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [333,444] }), true; |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in":[1,1] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in":[1,1] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [661, 660] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [661, 660] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 1] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 1] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 444] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 444] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [1, 0] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [1, 0] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [555, 0] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [555, 0] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 0] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 0] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
}); |
|
|
}); |
|
@ -76,35 +76,35 @@ describe("Comparators test", function () { |
|
|
const circuit = await tester(path.join(__dirname, "circuits", "lesseqthan.circom")); |
|
|
const circuit = await tester(path.join(__dirname, "circuits", "lesseqthan.circom")); |
|
|
|
|
|
|
|
|
let witness; |
|
|
let witness; |
|
|
witness = await circuit.calculateWitness({ "in": [333,444] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [333,444] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in":[1,1] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in":[1,1] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [661, 660] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [661, 660] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 1] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 1] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 444] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 444] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [1, 0] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [1, 0] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [555, 0] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [555, 0] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 0] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 0] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
}); |
|
|
}); |
|
@ -113,35 +113,35 @@ describe("Comparators test", function () { |
|
|
const circuit = await tester(path.join(__dirname, "circuits", "greaterthan.circom")); |
|
|
const circuit = await tester(path.join(__dirname, "circuits", "greaterthan.circom")); |
|
|
|
|
|
|
|
|
let witness; |
|
|
let witness; |
|
|
witness = await circuit.calculateWitness({ "in": [333,444] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [333,444] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in":[1,1] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in":[1,1] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [661, 660] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [661, 660] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 1] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 1] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 444] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 444] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [1, 0] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [1, 0] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [555, 0] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [555, 0] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 0] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 0] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
}); |
|
|
}); |
|
@ -149,35 +149,35 @@ describe("Comparators test", function () { |
|
|
const circuit = await tester(path.join(__dirname, "circuits", "greatereqthan.circom")); |
|
|
const circuit = await tester(path.join(__dirname, "circuits", "greatereqthan.circom")); |
|
|
|
|
|
|
|
|
let witness; |
|
|
let witness; |
|
|
witness = await circuit.calculateWitness({ "in": [333,444] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [333,444] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in":[1,1] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in":[1,1] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [661, 660] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [661, 660] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 1] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 1] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 444] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 444] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
assert(witness[1].equals(bigInt(0))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [1, 0] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [1, 0] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [555, 0] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [555, 0] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 0] }); |
|
|
|
|
|
|
|
|
witness = await circuit.calculateWitness({ "in": [0, 0] }, true); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[0].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
assert(witness[1].equals(bigInt(1))); |
|
|
}); |
|
|
}); |
|
|