@ -1,55 +1,53 @@ |
|||||
const chai = require("chai"); |
const chai = require("chai"); |
||||
const path = require("path"); |
const path = require("path"); |
||||
const snarkjs = require("snarkjs"); |
|
||||
const compiler = require("circom"); |
|
||||
|
|
||||
const assert = chai.assert; |
const assert = chai.assert; |
||||
|
|
||||
const bigInt = snarkjs.bigInt; |
|
||||
|
const bigInt = require("big-integer"); |
||||
|
const tester = require("circom").tester; |
||||
|
|
||||
function print(circuit, w, s) { |
function print(circuit, w, s) { |
||||
console.log(s + ": " + w[circuit.getSignalIdx(s)]); |
console.log(s + ": " + w[circuit.getSignalIdx(s)]); |
||||
} |
} |
||||
|
|
||||
function checkSub(_a,_b, circuit) { |
|
||||
|
async function checkSub(_a,_b, circuit) { |
||||
let a=bigInt(_a); |
let a=bigInt(_a); |
||||
let b=bigInt(_b); |
let b=bigInt(_b); |
||||
if (a.lesser(bigInt.zero)) a = a.add(bigInt.one.shl(16)); |
|
||||
if (b.lesser(bigInt.zero)) b = b.add(bigInt.one.shl(16)); |
|
||||
const w = circuit.calculateWitness({a: a, b: b}); |
|
||||
|
if (a.lesser(bigInt.zero)) a = a.add(bigInt.one.shiftLeft(16)); |
||||
|
if (b.lesser(bigInt.zero)) b = b.add(bigInt.one.shiftLeft(16)); |
||||
|
const w = await circuit.calculateWitness({a: a, b: b}); |
||||
|
|
||||
let res = a.sub(b); |
|
||||
if (res.lesser(bigInt.zero)) res = res.add(bigInt.one.shl(16)); |
|
||||
assert( w[circuit.getSignalIdx("main.out")].equals(bigInt(res)) ); |
|
||||
|
let res = a.minus(b); |
||||
|
if (res.lesser(bigInt.zero)) res = res.add(bigInt.one.shiftLeft(16)); |
||||
|
await circuit.assertOut(w, {out: bigInt(res)}); |
||||
} |
} |
||||
|
|
||||
describe("BinSub test", () => { |
|
||||
let circuit; |
|
||||
before( async() => { |
|
||||
const cirDef = await compiler(path.join(__dirname, "circuits", "binsub_test.circom")); |
|
||||
|
describe("BinSub test", function () { |
||||
|
|
||||
circuit = new snarkjs.Circuit(cirDef); |
|
||||
|
this.timeout(100000); |
||||
|
|
||||
console.log("NConstrains BinSub: " + circuit.nConstraints); |
|
||||
|
let circuit; |
||||
|
before( async() => { |
||||
|
circuit = await tester(path.join(__dirname, "circuits", "binsub_test.circom")); |
||||
}); |
}); |
||||
|
|
||||
it("Should check variuos ege cases", async () => { |
it("Should check variuos ege cases", async () => { |
||||
checkSub(0,0, circuit); |
|
||||
checkSub(1,0, circuit); |
|
||||
checkSub(-1,0, circuit); |
|
||||
checkSub(2,1, circuit); |
|
||||
checkSub(2,2, circuit); |
|
||||
checkSub(2,3, circuit); |
|
||||
checkSub(2,-1, circuit); |
|
||||
checkSub(2,-2, circuit); |
|
||||
checkSub(2,-3, circuit); |
|
||||
checkSub(-2,-3, circuit); |
|
||||
checkSub(-2,-2, circuit); |
|
||||
checkSub(-2,-1, circuit); |
|
||||
checkSub(-2,0, circuit); |
|
||||
checkSub(-2,1, circuit); |
|
||||
checkSub(-2,2, circuit); |
|
||||
checkSub(-2,3, circuit); |
|
||||
|
await checkSub(0,0, circuit); |
||||
|
await checkSub(1,0, circuit); |
||||
|
await checkSub(-1,0, circuit); |
||||
|
await checkSub(2,1, circuit); |
||||
|
await checkSub(2,2, circuit); |
||||
|
await checkSub(2,3, circuit); |
||||
|
await checkSub(2,-1, circuit); |
||||
|
await checkSub(2,-2, circuit); |
||||
|
await checkSub(2,-3, circuit); |
||||
|
await checkSub(-2,-3, circuit); |
||||
|
await checkSub(-2,-2, circuit); |
||||
|
await checkSub(-2,-1, circuit); |
||||
|
await checkSub(-2,0, circuit); |
||||
|
await checkSub(-2,1, circuit); |
||||
|
await checkSub(-2,2, circuit); |
||||
|
await checkSub(-2,3, circuit); |
||||
}); |
}); |
||||
|
|
||||
|
|
||||
|
@ -1,35 +1,36 @@ |
|||||
const chai = require("chai"); |
const chai = require("chai"); |
||||
const path = require("path"); |
const path = require("path"); |
||||
const snarkjs = require("snarkjs"); |
|
||||
const crypto = require("crypto"); |
|
||||
|
|
||||
const compiler = require("circom"); |
|
||||
|
const tester = require("circom").tester; |
||||
|
|
||||
|
const bigInt = require("big-integer"); |
||||
|
|
||||
const assert = chai.assert; |
const assert = chai.assert; |
||||
|
|
||||
describe("Sum test", () => { |
|
||||
it("Should create a constant circuit", async () => { |
|
||||
|
describe("Sum test", function () { |
||||
|
|
||||
const cirDef = await compiler(path.join(__dirname, "circuits", "constants_test.circom")); |
|
||||
assert.equal(cirDef.nVars, 2); |
|
||||
|
this.timeout(100000); |
||||
|
|
||||
const circuit = new snarkjs.Circuit(cirDef); |
|
||||
|
it("Should create a constant circuit", async () => { |
||||
|
const circuit = await tester(path.join(__dirname, "circuits", "constants_test.circom")); |
||||
|
|
||||
const witness = circuit.calculateWitness({ "in": "0xd807aa98" }); |
|
||||
|
// TODO
|
||||
|
// assert.equal(cirDef.nVars, 2);
|
||||
|
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt("0xd807aa98"))); |
|
||||
|
const witness = await circuit.calculateWitness({ "in": bigInt("d807aa98", 16)}); |
||||
|
|
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt("d807aa98", 16))); |
||||
}); |
}); |
||||
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 cirDef = await compiler(path.join(__dirname, "circuits", "sum_test.circom")); |
|
||||
assert.equal(cirDef.nVars, 97); // 32 (in1) + 32(in2) + 32(out) + 1 (carry)
|
|
||||
|
|
||||
const circuit = new snarkjs.Circuit(cirDef); |
|
||||
|
// TODO
|
||||
|
// assert.equal(cirDef.nVars, 97); // 32 (in1) + 32(in2) + 32(out) + 1 (carry)
|
||||
|
|
||||
const witness = circuit.calculateWitness({ "a": "111", "b": "222" }); |
|
||||
|
const witness = await circuit.calculateWitness({ "a": "111", "b": "222" }); |
||||
|
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt("333"))); |
|
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt("333"))); |
||||
}); |
}); |
||||
}); |
}); |
@ -1 +1 @@ |
|||||
{"in":"3876493977147089964395646989418653640709890493868463039177063670701706079087","Ax":"7544364404313686108640297486043592597084907953513982229886192880342666171487","Ay":"2721089742146723067451923493488918617350881493409568860627491866568993834336"} |
|
||||
|
{ "in": ["0", "0"]} |
@ -0,0 +1,20 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||
|
<plist version="1.0"> |
||||
|
<dict> |
||||
|
<key>CFBundleDevelopmentRegion</key> |
||||
|
<string>English</string> |
||||
|
<key>CFBundleIdentifier</key> |
||||
|
<string>com.apple.xcode.dsym.pedersen_test</string> |
||||
|
<key>CFBundleInfoDictionaryVersion</key> |
||||
|
<string>6.0</string> |
||||
|
<key>CFBundlePackageType</key> |
||||
|
<string>dSYM</string> |
||||
|
<key>CFBundleSignature</key> |
||||
|
<string>????</string> |
||||
|
<key>CFBundleShortVersionString</key> |
||||
|
<string>1.0</string> |
||||
|
<key>CFBundleVersion</key> |
||||
|
<string>1</string> |
||||
|
</dict> |
||||
|
</plist> |
@ -1,193 +1,184 @@ |
|||||
const chai = require("chai"); |
const chai = require("chai"); |
||||
const path = require("path"); |
const path = require("path"); |
||||
const snarkjs = require("snarkjs"); |
|
||||
const crypto = require("crypto"); |
|
||||
|
|
||||
const compiler = require("circom"); |
|
||||
|
const tester = require("circom").tester; |
||||
|
|
||||
|
const bigInt = require("big-integer"); |
||||
|
|
||||
const assert = chai.assert; |
const assert = chai.assert; |
||||
|
|
||||
describe("Sum test", () => { |
|
||||
it("Should create a iszero circuit", async() => { |
|
||||
const cirDef = await compiler(path.join(__dirname, "circuits", "iszero.circom")); |
|
||||
|
describe("Sum test", function () { |
||||
|
|
||||
const circuit = new snarkjs.Circuit(cirDef); |
|
||||
|
this.timeout(100000); |
||||
|
|
||||
|
it("Should create a iszero circuit", async() => { |
||||
|
const circuit = await tester(path.join(__dirname, "circuits", "iszero.circom")); |
||||
|
|
||||
let witness; |
let witness; |
||||
witness = circuit.calculateWitness({ "in": 111}); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": 111}); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in": 0 }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": 0 }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
}); |
}); |
||||
it("Should create a isequal circuit", async() => { |
it("Should create a isequal circuit", async() => { |
||||
const cirDef = await compiler(path.join(__dirname, "circuits", "isequal.circom")); |
|
||||
|
|
||||
const circuit = new snarkjs.Circuit(cirDef); |
|
||||
|
const circuit = await tester(path.join(__dirname, "circuits", "isequal.circom")); |
||||
|
|
||||
let witness; |
let witness; |
||||
witness = circuit.calculateWitness({ "in[0]": "111", "in[1]": "222" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [111,222] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "444", "in[1]": "444" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [444,444] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
}); |
}); |
||||
it("Should create a comparison lessthan", async() => { |
it("Should create a comparison lessthan", async() => { |
||||
const cirDef = await compiler(path.join(__dirname, "circuits", "lessthan.circom")); |
|
||||
|
|
||||
const circuit = new snarkjs.Circuit(cirDef); |
|
||||
|
const circuit = await tester(path.join(__dirname, "circuits", "lessthan.circom")); |
||||
|
|
||||
let witness; |
let witness; |
||||
witness = circuit.calculateWitness({ "in[0]": "333", "in[1]": "444" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [333,444] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "1", "in[1]": "1" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in":[1,1] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "661", "in[1]": "660" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [661, 660] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "0", "in[1]": "1" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [0, 1] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "0", "in[1]": "444" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [0, 444] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "1", "in[1]": "0" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [1, 0] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "555", "in[1]": "0" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [555, 0] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "0", "in[1]": "0" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [0, 0] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
}); |
}); |
||||
it("Should create a comparison lesseqthan", async() => { |
it("Should create a comparison lesseqthan", async() => { |
||||
const cirDef = await compiler(path.join(__dirname, "circuits", "lesseqthan.circom")); |
|
||||
|
|
||||
const circuit = new snarkjs.Circuit(cirDef); |
|
||||
|
const circuit = await tester(path.join(__dirname, "circuits", "lesseqthan.circom")); |
||||
|
|
||||
let witness; |
let witness; |
||||
witness = circuit.calculateWitness({ "in[0]": "333", "in[1]": "444" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [333,444] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "1", "in[1]": "1" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in":[1,1] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "661", "in[1]": "660" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [661, 660] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "0", "in[1]": "1" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [0, 1] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "0", "in[1]": "444" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [0, 444] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "1", "in[1]": "0" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [1, 0] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "555", "in[1]": "0" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [555, 0] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "0", "in[1]": "0" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [0, 0] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
}); |
}); |
||||
it("Should create a comparison greaterthan", async() => { |
it("Should create a comparison greaterthan", async() => { |
||||
const cirDef = await compiler(path.join(__dirname, "circuits", "greaterthan.circom")); |
|
||||
|
|
||||
const circuit = new snarkjs.Circuit(cirDef); |
|
||||
|
const circuit = await tester(path.join(__dirname, "circuits", "greaterthan.circom")); |
||||
|
|
||||
let witness; |
let witness; |
||||
witness = circuit.calculateWitness({ "in[0]": "333", "in[1]": "444" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [333,444] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "1", "in[1]": "1" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in":[1,1] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "661", "in[1]": "660" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [661, 660] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "0", "in[1]": "1" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [0, 1] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "0", "in[1]": "444" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [0, 444] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "1", "in[1]": "0" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [1, 0] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "555", "in[1]": "0" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [555, 0] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "0", "in[1]": "0" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [0, 0] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
}); |
}); |
||||
it("Should create a comparison greatereqthan", async() => { |
it("Should create a comparison greatereqthan", async() => { |
||||
const cirDef = await compiler(path.join(__dirname, "circuits", "greatereqthan.circom")); |
|
||||
|
|
||||
const circuit = new snarkjs.Circuit(cirDef); |
|
||||
|
|
||||
console.log("NConstraints BalancesUpdater: " + circuit.nConstraints); |
|
||||
|
const circuit = await tester(path.join(__dirname, "circuits", "greatereqthan.circom")); |
||||
|
|
||||
let witness; |
let witness; |
||||
witness = circuit.calculateWitness({ "in[0]": "333", "in[1]": "444" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [333,444] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "1", "in[1]": "1" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in":[1,1] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "661", "in[1]": "660" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [661, 660] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "0", "in[1]": "1" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [0, 1] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "0", "in[1]": "444" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(0))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [0, 444] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(0))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "1", "in[1]": "0" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [1, 0] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "555", "in[1]": "0" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [555, 0] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
|
|
||||
witness = circuit.calculateWitness({ "in[0]": "0", "in[1]": "0" }); |
|
||||
assert(witness[0].equals(snarkjs.bigInt(1))); |
|
||||
assert(witness[1].equals(snarkjs.bigInt(1))); |
|
||||
|
witness = await circuit.calculateWitness({ "in": [0, 0] }); |
||||
|
assert(witness[0].equals(bigInt(1))); |
||||
|
assert(witness[1].equals(bigInt(1))); |
||||
}); |
}); |
||||
}); |
}); |