diff --git a/cli.js b/cli.js index 60f754e..5180846 100755 --- a/cli.js +++ b/cli.js @@ -33,6 +33,7 @@ const argv = require("yargs") .usage("circom -s [input source circuit file] -o [output definition circuit file]") .alias("s", "source") .alias("o", "output") + .alias("c", "cfile") .require(["s","o"]) .help("h") .alias("h", "help") @@ -45,7 +46,7 @@ const argv = require("yargs") const fullFileName = path.resolve(process.cwd(), argv.source); -compiler(fullFileName).then( (cir) => { +compiler(fullFileName, argv.cfile).then( (cir) => { fs.writeFileSync(argv.output, JSON.stringify(cir, null, 1), "utf8"); }, (err) => { console.log(err); diff --git a/out.c b/out.c new file mode 100644 index 0000000..2666270 --- /dev/null +++ b/out.c @@ -0,0 +1,83 @@ +// File: ../../circuits/sha256/bitify.circom +function Num2Bits(ctx) +{ + ctx.setVar("lc1", [], "0"); + for (ctx.setVar("i", [], "0");bigInt(ctx.getVar("i",[])).lt(bigInt(ctx.getVar("n",[]))) ? 1 : 0;(ctx.setVar("i", [], bigInt(ctx.getVar("i",[])).add(bigInt("1")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__)) + { + ctx.setSignal("out", [ctx.getVar("i",[])], bigInt(bigInt(ctx.getVar("i",[])).greater(bigInt(256)) ? 0 : bigInt(ctx.getSignal("in", [])).shr(bigInt(ctx.getVar("i",[]))).and(__MASK__)).and(bigInt("1")).and(__MASK__)); + ctx.assert(bigInt(ctx.getSignal("out", [ctx.getVar("i",[])])).mul(bigInt(bigInt(ctx.getSignal("out", [ctx.getVar("i",[])])).add(__P__).sub(bigInt("1")).mod(__P__))).mod(__P__), "0"); + ctx.setVar("lc1", [], bigInt(ctx.getVar("lc1",[])).add(bigInt(bigInt(ctx.getSignal("out", [ctx.getVar("i",[])])).mul(bigInt(bigInt("2").modPow(bigInt(ctx.getVar("i",[])), __P__))).mod(__P__))).mod(__P__)); + } + + ctx.assert(ctx.getVar("lc1",[]), ctx.getSignal("in", [])); +} + +function Bits2Num(ctx) +{ + ctx.setVar("lc1", [], "0"); + for (ctx.setVar("i", [], "0");bigInt(ctx.getVar("i",[])).lt(bigInt(ctx.getVar("n",[]))) ? 1 : 0;(ctx.setVar("i", [], bigInt(ctx.getVar("i",[])).add(bigInt("1")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__)) + { + ctx.setVar("lc1", [], bigInt(ctx.getVar("lc1",[])).add(bigInt(bigInt(ctx.getSignal("in", [ctx.getVar("i",[])])).mul(bigInt(bigInt("2").modPow(bigInt(ctx.getVar("i",[])), __P__))).mod(__P__))).mod(__P__)); + } + + ctx.setSignal("out", [], ctx.getVar("lc1",[])); + ctx.assert(ctx.getSignal("out", []), ctx.getVar("lc1",[])); +} + + +// File: ../../circuits/sha256/binsum.circom +function nbits(ctx) { + ctx.setVar("n", [], "1"); + ctx.setVar("r", [], "0"); + while (bigInt(bigInt(ctx.getVar("n",[])).add(__P__).sub(bigInt("1")).mod(__P__)).lt(bigInt(ctx.getVar("a",[]))) ? 1 : 0) { + (ctx.setVar("r", [], bigInt(ctx.getVar("r",[])).add(bigInt("1")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__); + ctx.setVar("n", [], bigInt(ctx.getVar("n",[])).mul(bigInt("2")).mod(__P__)); + } + + return ctx.getVar("r",[]);; +} +function BinSum(ctx) +{ + ctx.setVar("nout", [], ctx.callFunction("nbits", [bigInt(bigInt(bigInt("2").modPow(bigInt(ctx.getVar("n",[])), __P__)).add(__P__).sub(bigInt("1")).mod(__P__)).mul(bigInt(ctx.getVar("ops",[]))).mod(__P__)])); + ctx.setVar("lin", [], "0"); + ctx.setVar("lout", [], "0"); + for (ctx.setVar("k", [], "0");bigInt(ctx.getVar("k",[])).lt(bigInt(ctx.getVar("n",[]))) ? 1 : 0;(ctx.setVar("k", [], bigInt(ctx.getVar("k",[])).add(bigInt("1")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__)) + { + for (ctx.setVar("j", [], "0");bigInt(ctx.getVar("j",[])).lt(bigInt(ctx.getVar("ops",[]))) ? 1 : 0;(ctx.setVar("j", [], bigInt(ctx.getVar("j",[])).add(bigInt("1")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__)) + { + ctx.setVar("lin", [], bigInt(ctx.getVar("lin",[])).add(bigInt(bigInt(ctx.getSignal("in", [ctx.getVar("j",[]),ctx.getVar("k",[])])).mul(bigInt(bigInt("2").modPow(bigInt(ctx.getVar("k",[])), __P__))).mod(__P__))).mod(__P__)); + } + + } + + for (ctx.setVar("k", [], "0");bigInt(ctx.getVar("k",[])).lt(bigInt(ctx.getVar("nout",[]))) ? 1 : 0;(ctx.setVar("k", [], bigInt(ctx.getVar("k",[])).add(bigInt("1")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__)) + { + ctx.setSignal("out", [ctx.getVar("k",[])], bigInt(bigInt(ctx.getVar("k",[])).greater(bigInt(256)) ? 0 : bigInt(ctx.getVar("lin",[])).shr(bigInt(ctx.getVar("k",[]))).and(__MASK__)).and(bigInt("1")).and(__MASK__)); + ctx.assert(bigInt(ctx.getSignal("out", [ctx.getVar("k",[])])).mul(bigInt(bigInt(ctx.getSignal("out", [ctx.getVar("k",[])])).add(__P__).sub(bigInt("1")).mod(__P__))).mod(__P__), "0"); + ctx.setVar("lout", [], bigInt(ctx.getVar("lout",[])).add(bigInt(bigInt(ctx.getSignal("out", [ctx.getVar("k",[])])).mul(bigInt(bigInt("2").modPow(bigInt(ctx.getVar("k",[])), __P__))).mod(__P__))).mod(__P__)); + } + + ctx.assert(ctx.getVar("lin",[]), ctx.getVar("lout",[])); +} + + +function A(ctx) +{ + ctx.setPin("n2ba", [], "in", [], ctx.getSignal("a", [])); + ctx.assert(ctx.getPin("n2ba", [], "in", []), ctx.getSignal("a", [])); + ctx.setPin("n2bb", [], "in", [], ctx.getSignal("b", [])); + ctx.assert(ctx.getPin("n2bb", [], "in", []), ctx.getSignal("b", [])); + for (ctx.setVar("i", [], "0");bigInt(ctx.getVar("i",[])).lt(bigInt("32")) ? 1 : 0;(ctx.setVar("i", [], bigInt(ctx.getVar("i",[])).add(bigInt("1")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__)) + { + ctx.setPin("sum", [], "in", ["0",ctx.getVar("i",[])], ctx.getPin("n2ba", [], "out", [ctx.getVar("i",[])])); + ctx.assert(ctx.getPin("sum", [], "in", ["0",ctx.getVar("i",[])]), ctx.getPin("n2ba", [], "out", [ctx.getVar("i",[])])); + ctx.setPin("sum", [], "in", ["1",ctx.getVar("i",[])], ctx.getPin("n2bb", [], "out", [ctx.getVar("i",[])])); + ctx.assert(ctx.getPin("sum", [], "in", ["1",ctx.getVar("i",[])]), ctx.getPin("n2bb", [], "out", [ctx.getVar("i",[])])); + ctx.setPin("b2n", [], "in", [ctx.getVar("i",[])], ctx.getPin("sum", [], "out", [ctx.getVar("i",[])])); + ctx.assert(ctx.getPin("b2n", [], "in", [ctx.getVar("i",[])]), ctx.getPin("sum", [], "out", [ctx.getVar("i",[])])); + } + + ctx.setSignal("out", [], ctx.getPin("b2n", [], "out", [])); + ctx.assert(ctx.getSignal("out", []), ctx.getPin("b2n", [], "out", [])); +} + diff --git a/out.cir b/out.cir new file mode 100644 index 0000000..a60bea0 --- /dev/null +++ b/out.cir @@ -0,0 +1,2341 @@ +{ + "mainCode": "// File: ../../circuits/sha256/bitify.circom\nfunction Num2Bits(ctx)\n{\n ctx.setVar(\"lc1\", [], \"0\");\n for (ctx.setVar(\"i\", [], \"0\");bigInt(ctx.getVar(\"i\",[])).lt(bigInt(ctx.getVar(\"n\",[]))) ? 1 : 0;(ctx.setVar(\"i\", [], bigInt(ctx.getVar(\"i\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__))\n {\n ctx.setSignal(\"out\", [ctx.getVar(\"i\",[])], bigInt(bigInt(ctx.getVar(\"i\",[])).greater(bigInt(256)) ? 0 : bigInt(ctx.getSignal(\"in\", [])).shr(bigInt(ctx.getVar(\"i\",[]))).and(__MASK__)).and(bigInt(\"1\")).and(__MASK__));\n ctx.assert(bigInt(ctx.getSignal(\"out\", [ctx.getVar(\"i\",[])])).mul(bigInt(bigInt(ctx.getSignal(\"out\", [ctx.getVar(\"i\",[])])).add(__P__).sub(bigInt(\"1\")).mod(__P__))).mod(__P__), \"0\");\n ctx.setVar(\"lc1\", [], bigInt(ctx.getVar(\"lc1\",[])).add(bigInt(bigInt(ctx.getSignal(\"out\", [ctx.getVar(\"i\",[])])).mul(bigInt(bigInt(\"2\").modPow(bigInt(ctx.getVar(\"i\",[])), __P__))).mod(__P__))).mod(__P__));\n }\n\n ctx.assert(ctx.getVar(\"lc1\",[]), ctx.getSignal(\"in\", []));\n}\n\nfunction Bits2Num(ctx)\n{\n ctx.setVar(\"lc1\", [], \"0\");\n for (ctx.setVar(\"i\", [], \"0\");bigInt(ctx.getVar(\"i\",[])).lt(bigInt(ctx.getVar(\"n\",[]))) ? 1 : 0;(ctx.setVar(\"i\", [], bigInt(ctx.getVar(\"i\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__))\n {\n ctx.setVar(\"lc1\", [], bigInt(ctx.getVar(\"lc1\",[])).add(bigInt(bigInt(ctx.getSignal(\"in\", [ctx.getVar(\"i\",[])])).mul(bigInt(bigInt(\"2\").modPow(bigInt(ctx.getVar(\"i\",[])), __P__))).mod(__P__))).mod(__P__));\n }\n\n ctx.setSignal(\"out\", [], ctx.getVar(\"lc1\",[]));\n ctx.assert(ctx.getSignal(\"out\", []), ctx.getVar(\"lc1\",[]));\n}\n\n\n// File: ../../circuits/sha256/binsum.circom\nfunction nbits(ctx) {\n ctx.setVar(\"n\", [], \"1\");\n ctx.setVar(\"r\", [], \"0\");\n while (bigInt(bigInt(ctx.getVar(\"n\",[])).add(__P__).sub(bigInt(\"1\")).mod(__P__)).lt(bigInt(ctx.getVar(\"a\",[]))) ? 1 : 0) {\n (ctx.setVar(\"r\", [], bigInt(ctx.getVar(\"r\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__);\n ctx.setVar(\"n\", [], bigInt(ctx.getVar(\"n\",[])).mul(bigInt(\"2\")).mod(__P__));\n }\n\n return ctx.getVar(\"r\",[]);;\n}\nfunction BinSum(ctx)\n{\n ctx.setVar(\"nout\", [], ctx.callFunction(\"nbits\", [bigInt(bigInt(bigInt(\"2\").modPow(bigInt(ctx.getVar(\"n\",[])), __P__)).add(__P__).sub(bigInt(\"1\")).mod(__P__)).mul(bigInt(ctx.getVar(\"ops\",[]))).mod(__P__)]));\n ctx.setVar(\"lin\", [], \"0\");\n ctx.setVar(\"lout\", [], \"0\");\n for (ctx.setVar(\"k\", [], \"0\");bigInt(ctx.getVar(\"k\",[])).lt(bigInt(ctx.getVar(\"n\",[]))) ? 1 : 0;(ctx.setVar(\"k\", [], bigInt(ctx.getVar(\"k\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__))\n {\n for (ctx.setVar(\"j\", [], \"0\");bigInt(ctx.getVar(\"j\",[])).lt(bigInt(ctx.getVar(\"ops\",[]))) ? 1 : 0;(ctx.setVar(\"j\", [], bigInt(ctx.getVar(\"j\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__))\n {\n ctx.setVar(\"lin\", [], bigInt(ctx.getVar(\"lin\",[])).add(bigInt(bigInt(ctx.getSignal(\"in\", [ctx.getVar(\"j\",[]),ctx.getVar(\"k\",[])])).mul(bigInt(bigInt(\"2\").modPow(bigInt(ctx.getVar(\"k\",[])), __P__))).mod(__P__))).mod(__P__));\n }\n\n }\n\n for (ctx.setVar(\"k\", [], \"0\");bigInt(ctx.getVar(\"k\",[])).lt(bigInt(ctx.getVar(\"nout\",[]))) ? 1 : 0;(ctx.setVar(\"k\", [], bigInt(ctx.getVar(\"k\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__))\n {\n ctx.setSignal(\"out\", [ctx.getVar(\"k\",[])], bigInt(bigInt(ctx.getVar(\"k\",[])).greater(bigInt(256)) ? 0 : bigInt(ctx.getVar(\"lin\",[])).shr(bigInt(ctx.getVar(\"k\",[]))).and(__MASK__)).and(bigInt(\"1\")).and(__MASK__));\n ctx.assert(bigInt(ctx.getSignal(\"out\", [ctx.getVar(\"k\",[])])).mul(bigInt(bigInt(ctx.getSignal(\"out\", [ctx.getVar(\"k\",[])])).add(__P__).sub(bigInt(\"1\")).mod(__P__))).mod(__P__), \"0\");\n ctx.setVar(\"lout\", [], bigInt(ctx.getVar(\"lout\",[])).add(bigInt(bigInt(ctx.getSignal(\"out\", [ctx.getVar(\"k\",[])])).mul(bigInt(bigInt(\"2\").modPow(bigInt(ctx.getVar(\"k\",[])), __P__))).mod(__P__))).mod(__P__));\n }\n\n ctx.assert(ctx.getVar(\"lin\",[]), ctx.getVar(\"lout\",[]));\n}\n\n\nfunction A(ctx)\n{\n ctx.setPin(\"n2ba\", [], \"in\", [], ctx.getSignal(\"a\", []));\n ctx.assert(ctx.getPin(\"n2ba\", [], \"in\", []), ctx.getSignal(\"a\", []));\n ctx.setPin(\"n2bb\", [], \"in\", [], ctx.getSignal(\"b\", []));\n ctx.assert(ctx.getPin(\"n2bb\", [], \"in\", []), ctx.getSignal(\"b\", []));\n for (ctx.setVar(\"i\", [], \"0\");bigInt(ctx.getVar(\"i\",[])).lt(bigInt(\"32\")) ? 1 : 0;(ctx.setVar(\"i\", [], bigInt(ctx.getVar(\"i\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__))\n {\n ctx.setPin(\"sum\", [], \"in\", [\"0\",ctx.getVar(\"i\",[])], ctx.getPin(\"n2ba\", [], \"out\", [ctx.getVar(\"i\",[])]));\n ctx.assert(ctx.getPin(\"sum\", [], \"in\", [\"0\",ctx.getVar(\"i\",[])]), ctx.getPin(\"n2ba\", [], \"out\", [ctx.getVar(\"i\",[])]));\n ctx.setPin(\"sum\", [], \"in\", [\"1\",ctx.getVar(\"i\",[])], ctx.getPin(\"n2bb\", [], \"out\", [ctx.getVar(\"i\",[])]));\n ctx.assert(ctx.getPin(\"sum\", [], \"in\", [\"1\",ctx.getVar(\"i\",[])]), ctx.getPin(\"n2bb\", [], \"out\", [ctx.getVar(\"i\",[])]));\n ctx.setPin(\"b2n\", [], \"in\", [ctx.getVar(\"i\",[])], ctx.getPin(\"sum\", [], \"out\", [ctx.getVar(\"i\",[])]));\n ctx.assert(ctx.getPin(\"b2n\", [], \"in\", [ctx.getVar(\"i\",[])]), ctx.getPin(\"sum\", [], \"out\", [ctx.getVar(\"i\",[])]));\n }\n\n ctx.setSignal(\"out\", [], ctx.getPin(\"b2n\", [], \"out\", []));\n ctx.assert(ctx.getSignal(\"out\", []), ctx.getPin(\"b2n\", [], \"out\", []));\n}\n\n", + "signalName2Idx": { + "one": 0, + "main.a": 3, + "main.b": 2, + "main.out": 1, + "main.n2ba.in": 3, + "main.n2ba.out[0]": 4, + "main.n2ba.out[1]": 5, + "main.n2ba.out[2]": 6, + "main.n2ba.out[3]": 7, + "main.n2ba.out[4]": 8, + "main.n2ba.out[5]": 9, + "main.n2ba.out[6]": 10, + "main.n2ba.out[7]": 11, + "main.n2ba.out[8]": 12, + "main.n2ba.out[9]": 13, + "main.n2ba.out[10]": 14, + "main.n2ba.out[11]": 15, + "main.n2ba.out[12]": 16, + "main.n2ba.out[13]": 17, + "main.n2ba.out[14]": 18, + "main.n2ba.out[15]": 19, + "main.n2ba.out[16]": 20, + "main.n2ba.out[17]": 21, + "main.n2ba.out[18]": 22, + "main.n2ba.out[19]": 23, + "main.n2ba.out[20]": 24, + "main.n2ba.out[21]": 25, + "main.n2ba.out[22]": 26, + "main.n2ba.out[23]": 27, + "main.n2ba.out[24]": 28, + "main.n2ba.out[25]": 29, + "main.n2ba.out[26]": 30, + "main.n2ba.out[27]": 31, + "main.n2ba.out[28]": 32, + "main.n2ba.out[29]": 33, + "main.n2ba.out[30]": 34, + "main.n2ba.out[31]": 35, + "main.n2bb.in": 2, + "main.n2bb.out[0]": 36, + "main.n2bb.out[1]": 37, + "main.n2bb.out[2]": 38, + "main.n2bb.out[3]": 39, + "main.n2bb.out[4]": 40, + "main.n2bb.out[5]": 41, + "main.n2bb.out[6]": 42, + "main.n2bb.out[7]": 43, + "main.n2bb.out[8]": 44, + "main.n2bb.out[9]": 45, + "main.n2bb.out[10]": 46, + "main.n2bb.out[11]": 47, + "main.n2bb.out[12]": 48, + "main.n2bb.out[13]": 49, + "main.n2bb.out[14]": 50, + "main.n2bb.out[15]": 51, + "main.n2bb.out[16]": 52, + "main.n2bb.out[17]": 53, + "main.n2bb.out[18]": 54, + "main.n2bb.out[19]": 55, + "main.n2bb.out[20]": 56, + "main.n2bb.out[21]": 57, + "main.n2bb.out[22]": 58, + "main.n2bb.out[23]": 59, + "main.n2bb.out[24]": 60, + "main.n2bb.out[25]": 61, + "main.n2bb.out[26]": 62, + "main.n2bb.out[27]": 63, + "main.n2bb.out[28]": 64, + "main.n2bb.out[29]": 65, + "main.n2bb.out[30]": 66, + "main.n2bb.out[31]": 67, + "main.sum.in[0][0]": 4, + "main.sum.in[0][1]": 5, + "main.sum.in[0][2]": 6, + "main.sum.in[0][3]": 7, + "main.sum.in[0][4]": 8, + "main.sum.in[0][5]": 9, + "main.sum.in[0][6]": 10, + "main.sum.in[0][7]": 11, + "main.sum.in[0][8]": 12, + "main.sum.in[0][9]": 13, + "main.sum.in[0][10]": 14, + "main.sum.in[0][11]": 15, + "main.sum.in[0][12]": 16, + "main.sum.in[0][13]": 17, + "main.sum.in[0][14]": 18, + "main.sum.in[0][15]": 19, + "main.sum.in[0][16]": 20, + "main.sum.in[0][17]": 21, + "main.sum.in[0][18]": 22, + "main.sum.in[0][19]": 23, + "main.sum.in[0][20]": 24, + "main.sum.in[0][21]": 25, + "main.sum.in[0][22]": 26, + "main.sum.in[0][23]": 27, + "main.sum.in[0][24]": 28, + "main.sum.in[0][25]": 29, + "main.sum.in[0][26]": 30, + "main.sum.in[0][27]": 31, + "main.sum.in[0][28]": 32, + "main.sum.in[0][29]": 33, + "main.sum.in[0][30]": 34, + "main.sum.in[0][31]": 35, + "main.sum.in[1][0]": 36, + "main.sum.in[1][1]": 37, + "main.sum.in[1][2]": 38, + "main.sum.in[1][3]": 39, + "main.sum.in[1][4]": 40, + "main.sum.in[1][5]": 41, + "main.sum.in[1][6]": 42, + "main.sum.in[1][7]": 43, + "main.sum.in[1][8]": 44, + "main.sum.in[1][9]": 45, + "main.sum.in[1][10]": 46, + "main.sum.in[1][11]": 47, + "main.sum.in[1][12]": 48, + "main.sum.in[1][13]": 49, + "main.sum.in[1][14]": 50, + "main.sum.in[1][15]": 51, + "main.sum.in[1][16]": 52, + "main.sum.in[1][17]": 53, + "main.sum.in[1][18]": 54, + "main.sum.in[1][19]": 55, + "main.sum.in[1][20]": 56, + "main.sum.in[1][21]": 57, + "main.sum.in[1][22]": 58, + "main.sum.in[1][23]": 59, + "main.sum.in[1][24]": 60, + "main.sum.in[1][25]": 61, + "main.sum.in[1][26]": 62, + "main.sum.in[1][27]": 63, + "main.sum.in[1][28]": 64, + "main.sum.in[1][29]": 65, + "main.sum.in[1][30]": 66, + "main.sum.in[1][31]": 67, + "main.sum.out[0]": 68, + "main.sum.out[1]": 69, + "main.sum.out[2]": 70, + "main.sum.out[3]": 71, + "main.sum.out[4]": 72, + "main.sum.out[5]": 73, + "main.sum.out[6]": 74, + "main.sum.out[7]": 75, + "main.sum.out[8]": 76, + "main.sum.out[9]": 77, + "main.sum.out[10]": 78, + "main.sum.out[11]": 79, + "main.sum.out[12]": 80, + "main.sum.out[13]": 81, + "main.sum.out[14]": 82, + "main.sum.out[15]": 83, + "main.sum.out[16]": 84, + "main.sum.out[17]": 85, + "main.sum.out[18]": 86, + "main.sum.out[19]": 87, + "main.sum.out[20]": 88, + "main.sum.out[21]": 89, + "main.sum.out[22]": 90, + "main.sum.out[23]": 91, + "main.sum.out[24]": 92, + "main.sum.out[25]": 93, + "main.sum.out[26]": 94, + "main.sum.out[27]": 95, + "main.sum.out[28]": 96, + "main.sum.out[29]": 97, + "main.sum.out[30]": 98, + "main.sum.out[31]": 99, + "main.sum.out[32]": 100, + "main.b2n.in[0]": 68, + "main.b2n.in[1]": 69, + "main.b2n.in[2]": 70, + "main.b2n.in[3]": 71, + "main.b2n.in[4]": 72, + "main.b2n.in[5]": 73, + "main.b2n.in[6]": 74, + "main.b2n.in[7]": 75, + "main.b2n.in[8]": 76, + "main.b2n.in[9]": 77, + "main.b2n.in[10]": 78, + "main.b2n.in[11]": 79, + "main.b2n.in[12]": 80, + "main.b2n.in[13]": 81, + "main.b2n.in[14]": 82, + "main.b2n.in[15]": 83, + "main.b2n.in[16]": 84, + "main.b2n.in[17]": 85, + "main.b2n.in[18]": 86, + "main.b2n.in[19]": 87, + "main.b2n.in[20]": 88, + "main.b2n.in[21]": 89, + "main.b2n.in[22]": 90, + "main.b2n.in[23]": 91, + "main.b2n.in[24]": 92, + "main.b2n.in[25]": 93, + "main.b2n.in[26]": 94, + "main.b2n.in[27]": 95, + "main.b2n.in[28]": 96, + "main.b2n.in[29]": 97, + "main.b2n.in[30]": 98, + "main.b2n.in[31]": 99, + "main.b2n.out": 1 + }, + "components": [ + { + "name": "main", + "params": {}, + "template": "A", + "inputSignals": 2 + }, + { + "name": "main.n2ba", + "params": { + "n": "32" + }, + "template": "Num2Bits", + "inputSignals": 1 + }, + { + "name": "main.n2bb", + "params": { + "n": "32" + }, + "template": "Num2Bits", + "inputSignals": 1 + }, + { + "name": "main.sum", + "params": { + "n": "32", + "ops": "2" + }, + "template": "BinSum", + "inputSignals": 64 + }, + { + "name": "main.b2n", + "params": { + "n": "32" + }, + "template": "Bits2Num", + "inputSignals": 32 + } + ], + "componentName2Idx": { + "main": 0, + "main.n2ba": 1, + "main.n2bb": 2, + "main.sum": 3, + "main.b2n": 4 + }, + "signals": [ + { + "names": [ + "one" + ], + "triggerComponents": [] + }, + { + "names": [ + "main.out", + "main.b2n.out" + ], + "triggerComponents": [] + }, + { + "names": [ + "main.b", + "main.n2bb.in" + ], + "triggerComponents": [ + 0, + 2 + ] + }, + { + "names": [ + "main.a", + "main.n2ba.in" + ], + "triggerComponents": [ + 0, + 1 + ] + }, + { + "names": [ + "main.n2ba.out[0]", + "main.sum.in[0][0]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[1]", + "main.sum.in[0][1]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[2]", + "main.sum.in[0][2]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[3]", + "main.sum.in[0][3]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[4]", + "main.sum.in[0][4]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[5]", + "main.sum.in[0][5]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[6]", + "main.sum.in[0][6]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[7]", + "main.sum.in[0][7]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[8]", + "main.sum.in[0][8]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[9]", + "main.sum.in[0][9]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[10]", + "main.sum.in[0][10]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[11]", + "main.sum.in[0][11]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[12]", + "main.sum.in[0][12]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[13]", + "main.sum.in[0][13]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[14]", + "main.sum.in[0][14]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[15]", + "main.sum.in[0][15]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[16]", + "main.sum.in[0][16]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[17]", + "main.sum.in[0][17]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[18]", + "main.sum.in[0][18]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[19]", + "main.sum.in[0][19]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[20]", + "main.sum.in[0][20]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[21]", + "main.sum.in[0][21]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[22]", + "main.sum.in[0][22]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[23]", + "main.sum.in[0][23]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[24]", + "main.sum.in[0][24]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[25]", + "main.sum.in[0][25]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[26]", + "main.sum.in[0][26]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[27]", + "main.sum.in[0][27]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[28]", + "main.sum.in[0][28]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[29]", + "main.sum.in[0][29]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[30]", + "main.sum.in[0][30]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2ba.out[31]", + "main.sum.in[0][31]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[0]", + "main.sum.in[1][0]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[1]", + "main.sum.in[1][1]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[2]", + "main.sum.in[1][2]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[3]", + "main.sum.in[1][3]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[4]", + "main.sum.in[1][4]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[5]", + "main.sum.in[1][5]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[6]", + "main.sum.in[1][6]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[7]", + "main.sum.in[1][7]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[8]", + "main.sum.in[1][8]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[9]", + "main.sum.in[1][9]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[10]", + "main.sum.in[1][10]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[11]", + "main.sum.in[1][11]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[12]", + "main.sum.in[1][12]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[13]", + "main.sum.in[1][13]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[14]", + "main.sum.in[1][14]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[15]", + "main.sum.in[1][15]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[16]", + "main.sum.in[1][16]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[17]", + "main.sum.in[1][17]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[18]", + "main.sum.in[1][18]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[19]", + "main.sum.in[1][19]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[20]", + "main.sum.in[1][20]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[21]", + "main.sum.in[1][21]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[22]", + "main.sum.in[1][22]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[23]", + "main.sum.in[1][23]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[24]", + "main.sum.in[1][24]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[25]", + "main.sum.in[1][25]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[26]", + "main.sum.in[1][26]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[27]", + "main.sum.in[1][27]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[28]", + "main.sum.in[1][28]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[29]", + "main.sum.in[1][29]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[30]", + "main.sum.in[1][30]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.n2bb.out[31]", + "main.sum.in[1][31]" + ], + "triggerComponents": [ + 3 + ] + }, + { + "names": [ + "main.sum.out[0]", + "main.b2n.in[0]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[1]", + "main.b2n.in[1]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[2]", + "main.b2n.in[2]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[3]", + "main.b2n.in[3]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[4]", + "main.b2n.in[4]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[5]", + "main.b2n.in[5]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[6]", + "main.b2n.in[6]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[7]", + "main.b2n.in[7]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[8]", + "main.b2n.in[8]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[9]", + "main.b2n.in[9]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[10]", + "main.b2n.in[10]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[11]", + "main.b2n.in[11]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[12]", + "main.b2n.in[12]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[13]", + "main.b2n.in[13]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[14]", + "main.b2n.in[14]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[15]", + "main.b2n.in[15]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[16]", + "main.b2n.in[16]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[17]", + "main.b2n.in[17]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[18]", + "main.b2n.in[18]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[19]", + "main.b2n.in[19]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[20]", + "main.b2n.in[20]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[21]", + "main.b2n.in[21]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[22]", + "main.b2n.in[22]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[23]", + "main.b2n.in[23]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[24]", + "main.b2n.in[24]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[25]", + "main.b2n.in[25]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[26]", + "main.b2n.in[26]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[27]", + "main.b2n.in[27]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[28]", + "main.b2n.in[28]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[29]", + "main.b2n.in[29]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[30]", + "main.b2n.in[30]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[31]", + "main.b2n.in[31]" + ], + "triggerComponents": [ + 4 + ] + }, + { + "names": [ + "main.sum.out[32]" + ], + "triggerComponents": [] + } + ], + "constraints": [ + [ + { + "3": "1", + "5": "21888242871839275222246405745257275088548364400416034343698204186575808495615", + "6": "21888242871839275222246405745257275088548364400416034343698204186575808495613", + "7": "21888242871839275222246405745257275088548364400416034343698204186575808495609", + "8": "21888242871839275222246405745257275088548364400416034343698204186575808495601", + "9": "21888242871839275222246405745257275088548364400416034343698204186575808495585", + "10": "21888242871839275222246405745257275088548364400416034343698204186575808495553", + "11": "21888242871839275222246405745257275088548364400416034343698204186575808495489", + "12": "21888242871839275222246405745257275088548364400416034343698204186575808495361", + "13": "21888242871839275222246405745257275088548364400416034343698204186575808495105", + "14": "21888242871839275222246405745257275088548364400416034343698204186575808494593", + "15": "21888242871839275222246405745257275088548364400416034343698204186575808493569", + "16": "21888242871839275222246405745257275088548364400416034343698204186575808491521", + "17": "21888242871839275222246405745257275088548364400416034343698204186575808487425", + "18": "21888242871839275222246405745257275088548364400416034343698204186575808479233", + "19": "21888242871839275222246405745257275088548364400416034343698204186575808462849", + "20": "21888242871839275222246405745257275088548364400416034343698204186575808430081", + "21": "21888242871839275222246405745257275088548364400416034343698204186575808364545", + "22": "21888242871839275222246405745257275088548364400416034343698204186575808233473", + "23": "21888242871839275222246405745257275088548364400416034343698204186575807971329", + "24": "21888242871839275222246405745257275088548364400416034343698204186575807447041", + "25": "21888242871839275222246405745257275088548364400416034343698204186575806398465", + "26": "21888242871839275222246405745257275088548364400416034343698204186575804301313", + "27": "21888242871839275222246405745257275088548364400416034343698204186575800107009", + "28": "21888242871839275222246405745257275088548364400416034343698204186575791718401", + "29": "21888242871839275222246405745257275088548364400416034343698204186575774941185", + "30": "21888242871839275222246405745257275088548364400416034343698204186575741386753", + "31": "21888242871839275222246405745257275088548364400416034343698204186575674277889", + "32": "21888242871839275222246405745257275088548364400416034343698204186575540060161", + "33": "21888242871839275222246405745257275088548364400416034343698204186575271624705", + "34": "21888242871839275222246405745257275088548364400416034343698204186574734753793", + "35": "21888242871839275222246405745257275088548364400416034343698204186573661011969" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "3": "1", + "5": "21888242871839275222246405745257275088548364400416034343698204186575808495615", + "6": "21888242871839275222246405745257275088548364400416034343698204186575808495613", + "7": "21888242871839275222246405745257275088548364400416034343698204186575808495609", + "8": "21888242871839275222246405745257275088548364400416034343698204186575808495601", + "9": "21888242871839275222246405745257275088548364400416034343698204186575808495585", + "10": "21888242871839275222246405745257275088548364400416034343698204186575808495553", + "11": "21888242871839275222246405745257275088548364400416034343698204186575808495489", + "12": "21888242871839275222246405745257275088548364400416034343698204186575808495361", + "13": "21888242871839275222246405745257275088548364400416034343698204186575808495105", + "14": "21888242871839275222246405745257275088548364400416034343698204186575808494593", + "15": "21888242871839275222246405745257275088548364400416034343698204186575808493569", + "16": "21888242871839275222246405745257275088548364400416034343698204186575808491521", + "17": "21888242871839275222246405745257275088548364400416034343698204186575808487425", + "18": "21888242871839275222246405745257275088548364400416034343698204186575808479233", + "19": "21888242871839275222246405745257275088548364400416034343698204186575808462849", + "20": "21888242871839275222246405745257275088548364400416034343698204186575808430081", + "21": "21888242871839275222246405745257275088548364400416034343698204186575808364545", + "22": "21888242871839275222246405745257275088548364400416034343698204186575808233473", + "23": "21888242871839275222246405745257275088548364400416034343698204186575807971329", + "24": "21888242871839275222246405745257275088548364400416034343698204186575807447041", + "25": "21888242871839275222246405745257275088548364400416034343698204186575806398465", + "26": "21888242871839275222246405745257275088548364400416034343698204186575804301313", + "27": "21888242871839275222246405745257275088548364400416034343698204186575800107009", + "28": "21888242871839275222246405745257275088548364400416034343698204186575791718401", + "29": "21888242871839275222246405745257275088548364400416034343698204186575774941185", + "30": "21888242871839275222246405745257275088548364400416034343698204186575741386753", + "31": "21888242871839275222246405745257275088548364400416034343698204186575674277889", + "32": "21888242871839275222246405745257275088548364400416034343698204186575540060161", + "33": "21888242871839275222246405745257275088548364400416034343698204186575271624705", + "34": "21888242871839275222246405745257275088548364400416034343698204186574734753793", + "35": "21888242871839275222246405745257275088548364400416034343698204186573661011969" + }, + {} + ], + [ + { + "5": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "5": "1" + }, + {} + ], + [ + { + "6": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "6": "1" + }, + {} + ], + [ + { + "7": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "7": "1" + }, + {} + ], + [ + { + "8": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "8": "1" + }, + {} + ], + [ + { + "9": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "9": "1" + }, + {} + ], + [ + { + "10": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "10": "1" + }, + {} + ], + [ + { + "11": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "11": "1" + }, + {} + ], + [ + { + "12": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "12": "1" + }, + {} + ], + [ + { + "13": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "13": "1" + }, + {} + ], + [ + { + "14": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "14": "1" + }, + {} + ], + [ + { + "15": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "15": "1" + }, + {} + ], + [ + { + "16": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "16": "1" + }, + {} + ], + [ + { + "17": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "17": "1" + }, + {} + ], + [ + { + "18": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "18": "1" + }, + {} + ], + [ + { + "19": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "19": "1" + }, + {} + ], + [ + { + "20": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "20": "1" + }, + {} + ], + [ + { + "21": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "21": "1" + }, + {} + ], + [ + { + "22": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "22": "1" + }, + {} + ], + [ + { + "23": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "23": "1" + }, + {} + ], + [ + { + "24": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "24": "1" + }, + {} + ], + [ + { + "25": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "25": "1" + }, + {} + ], + [ + { + "26": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "26": "1" + }, + {} + ], + [ + { + "27": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "27": "1" + }, + {} + ], + [ + { + "28": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "28": "1" + }, + {} + ], + [ + { + "29": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "29": "1" + }, + {} + ], + [ + { + "30": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "30": "1" + }, + {} + ], + [ + { + "31": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "31": "1" + }, + {} + ], + [ + { + "32": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "32": "1" + }, + {} + ], + [ + { + "33": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "33": "1" + }, + {} + ], + [ + { + "34": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "34": "1" + }, + {} + ], + [ + { + "35": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "35": "1" + }, + {} + ], + [ + { + "2": "1", + "37": "21888242871839275222246405745257275088548364400416034343698204186575808495615", + "38": "21888242871839275222246405745257275088548364400416034343698204186575808495613", + "39": "21888242871839275222246405745257275088548364400416034343698204186575808495609", + "40": "21888242871839275222246405745257275088548364400416034343698204186575808495601", + "41": "21888242871839275222246405745257275088548364400416034343698204186575808495585", + "42": "21888242871839275222246405745257275088548364400416034343698204186575808495553", + "43": "21888242871839275222246405745257275088548364400416034343698204186575808495489", + "44": "21888242871839275222246405745257275088548364400416034343698204186575808495361", + "45": "21888242871839275222246405745257275088548364400416034343698204186575808495105", + "46": "21888242871839275222246405745257275088548364400416034343698204186575808494593", + "47": "21888242871839275222246405745257275088548364400416034343698204186575808493569", + "48": "21888242871839275222246405745257275088548364400416034343698204186575808491521", + "49": "21888242871839275222246405745257275088548364400416034343698204186575808487425", + "50": "21888242871839275222246405745257275088548364400416034343698204186575808479233", + "51": "21888242871839275222246405745257275088548364400416034343698204186575808462849", + "52": "21888242871839275222246405745257275088548364400416034343698204186575808430081", + "53": "21888242871839275222246405745257275088548364400416034343698204186575808364545", + "54": "21888242871839275222246405745257275088548364400416034343698204186575808233473", + "55": "21888242871839275222246405745257275088548364400416034343698204186575807971329", + "56": "21888242871839275222246405745257275088548364400416034343698204186575807447041", + "57": "21888242871839275222246405745257275088548364400416034343698204186575806398465", + "58": "21888242871839275222246405745257275088548364400416034343698204186575804301313", + "59": "21888242871839275222246405745257275088548364400416034343698204186575800107009", + "60": "21888242871839275222246405745257275088548364400416034343698204186575791718401", + "61": "21888242871839275222246405745257275088548364400416034343698204186575774941185", + "62": "21888242871839275222246405745257275088548364400416034343698204186575741386753", + "63": "21888242871839275222246405745257275088548364400416034343698204186575674277889", + "64": "21888242871839275222246405745257275088548364400416034343698204186575540060161", + "65": "21888242871839275222246405745257275088548364400416034343698204186575271624705", + "66": "21888242871839275222246405745257275088548364400416034343698204186574734753793", + "67": "21888242871839275222246405745257275088548364400416034343698204186573661011969" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "2": "1", + "37": "21888242871839275222246405745257275088548364400416034343698204186575808495615", + "38": "21888242871839275222246405745257275088548364400416034343698204186575808495613", + "39": "21888242871839275222246405745257275088548364400416034343698204186575808495609", + "40": "21888242871839275222246405745257275088548364400416034343698204186575808495601", + "41": "21888242871839275222246405745257275088548364400416034343698204186575808495585", + "42": "21888242871839275222246405745257275088548364400416034343698204186575808495553", + "43": "21888242871839275222246405745257275088548364400416034343698204186575808495489", + "44": "21888242871839275222246405745257275088548364400416034343698204186575808495361", + "45": "21888242871839275222246405745257275088548364400416034343698204186575808495105", + "46": "21888242871839275222246405745257275088548364400416034343698204186575808494593", + "47": "21888242871839275222246405745257275088548364400416034343698204186575808493569", + "48": "21888242871839275222246405745257275088548364400416034343698204186575808491521", + "49": "21888242871839275222246405745257275088548364400416034343698204186575808487425", + "50": "21888242871839275222246405745257275088548364400416034343698204186575808479233", + "51": "21888242871839275222246405745257275088548364400416034343698204186575808462849", + "52": "21888242871839275222246405745257275088548364400416034343698204186575808430081", + "53": "21888242871839275222246405745257275088548364400416034343698204186575808364545", + "54": "21888242871839275222246405745257275088548364400416034343698204186575808233473", + "55": "21888242871839275222246405745257275088548364400416034343698204186575807971329", + "56": "21888242871839275222246405745257275088548364400416034343698204186575807447041", + "57": "21888242871839275222246405745257275088548364400416034343698204186575806398465", + "58": "21888242871839275222246405745257275088548364400416034343698204186575804301313", + "59": "21888242871839275222246405745257275088548364400416034343698204186575800107009", + "60": "21888242871839275222246405745257275088548364400416034343698204186575791718401", + "61": "21888242871839275222246405745257275088548364400416034343698204186575774941185", + "62": "21888242871839275222246405745257275088548364400416034343698204186575741386753", + "63": "21888242871839275222246405745257275088548364400416034343698204186575674277889", + "64": "21888242871839275222246405745257275088548364400416034343698204186575540060161", + "65": "21888242871839275222246405745257275088548364400416034343698204186575271624705", + "66": "21888242871839275222246405745257275088548364400416034343698204186574734753793", + "67": "21888242871839275222246405745257275088548364400416034343698204186573661011969" + }, + {} + ], + [ + { + "37": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "37": "1" + }, + {} + ], + [ + { + "38": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "38": "1" + }, + {} + ], + [ + { + "39": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "39": "1" + }, + {} + ], + [ + { + "40": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "40": "1" + }, + {} + ], + [ + { + "41": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "41": "1" + }, + {} + ], + [ + { + "42": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "42": "1" + }, + {} + ], + [ + { + "43": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "43": "1" + }, + {} + ], + [ + { + "44": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "44": "1" + }, + {} + ], + [ + { + "45": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "45": "1" + }, + {} + ], + [ + { + "46": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "46": "1" + }, + {} + ], + [ + { + "47": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "47": "1" + }, + {} + ], + [ + { + "48": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "48": "1" + }, + {} + ], + [ + { + "49": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "49": "1" + }, + {} + ], + [ + { + "50": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "50": "1" + }, + {} + ], + [ + { + "51": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "51": "1" + }, + {} + ], + [ + { + "52": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "52": "1" + }, + {} + ], + [ + { + "53": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "53": "1" + }, + {} + ], + [ + { + "54": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "54": "1" + }, + {} + ], + [ + { + "55": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "55": "1" + }, + {} + ], + [ + { + "56": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "56": "1" + }, + {} + ], + [ + { + "57": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "57": "1" + }, + {} + ], + [ + { + "58": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "58": "1" + }, + {} + ], + [ + { + "59": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "59": "1" + }, + {} + ], + [ + { + "60": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "60": "1" + }, + {} + ], + [ + { + "61": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "61": "1" + }, + {} + ], + [ + { + "62": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "62": "1" + }, + {} + ], + [ + { + "63": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "63": "1" + }, + {} + ], + [ + { + "64": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "64": "1" + }, + {} + ], + [ + { + "65": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "65": "1" + }, + {} + ], + [ + { + "66": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "66": "1" + }, + {} + ], + [ + { + "67": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "67": "1" + }, + {} + ], + [ + { + "1": "1", + "69": "21888242871839275222246405745257275088548364400416034343698204186575808495615", + "70": "21888242871839275222246405745257275088548364400416034343698204186575808495613", + "71": "21888242871839275222246405745257275088548364400416034343698204186575808495609", + "72": "21888242871839275222246405745257275088548364400416034343698204186575808495601", + "73": "21888242871839275222246405745257275088548364400416034343698204186575808495585", + "74": "21888242871839275222246405745257275088548364400416034343698204186575808495553", + "75": "21888242871839275222246405745257275088548364400416034343698204186575808495489", + "76": "21888242871839275222246405745257275088548364400416034343698204186575808495361", + "77": "21888242871839275222246405745257275088548364400416034343698204186575808495105", + "78": "21888242871839275222246405745257275088548364400416034343698204186575808494593", + "79": "21888242871839275222246405745257275088548364400416034343698204186575808493569", + "80": "21888242871839275222246405745257275088548364400416034343698204186575808491521", + "81": "21888242871839275222246405745257275088548364400416034343698204186575808487425", + "82": "21888242871839275222246405745257275088548364400416034343698204186575808479233", + "83": "21888242871839275222246405745257275088548364400416034343698204186575808462849", + "84": "21888242871839275222246405745257275088548364400416034343698204186575808430081", + "85": "21888242871839275222246405745257275088548364400416034343698204186575808364545", + "86": "21888242871839275222246405745257275088548364400416034343698204186575808233473", + "87": "21888242871839275222246405745257275088548364400416034343698204186575807971329", + "88": "21888242871839275222246405745257275088548364400416034343698204186575807447041", + "89": "21888242871839275222246405745257275088548364400416034343698204186575806398465", + "90": "21888242871839275222246405745257275088548364400416034343698204186575804301313", + "91": "21888242871839275222246405745257275088548364400416034343698204186575800107009", + "92": "21888242871839275222246405745257275088548364400416034343698204186575791718401", + "93": "21888242871839275222246405745257275088548364400416034343698204186575774941185", + "94": "21888242871839275222246405745257275088548364400416034343698204186575741386753", + "95": "21888242871839275222246405745257275088548364400416034343698204186575674277889", + "96": "21888242871839275222246405745257275088548364400416034343698204186575540060161", + "97": "21888242871839275222246405745257275088548364400416034343698204186575271624705", + "98": "21888242871839275222246405745257275088548364400416034343698204186574734753793", + "99": "21888242871839275222246405745257275088548364400416034343698204186573661011969" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "1": "1", + "69": "21888242871839275222246405745257275088548364400416034343698204186575808495615", + "70": "21888242871839275222246405745257275088548364400416034343698204186575808495613", + "71": "21888242871839275222246405745257275088548364400416034343698204186575808495609", + "72": "21888242871839275222246405745257275088548364400416034343698204186575808495601", + "73": "21888242871839275222246405745257275088548364400416034343698204186575808495585", + "74": "21888242871839275222246405745257275088548364400416034343698204186575808495553", + "75": "21888242871839275222246405745257275088548364400416034343698204186575808495489", + "76": "21888242871839275222246405745257275088548364400416034343698204186575808495361", + "77": "21888242871839275222246405745257275088548364400416034343698204186575808495105", + "78": "21888242871839275222246405745257275088548364400416034343698204186575808494593", + "79": "21888242871839275222246405745257275088548364400416034343698204186575808493569", + "80": "21888242871839275222246405745257275088548364400416034343698204186575808491521", + "81": "21888242871839275222246405745257275088548364400416034343698204186575808487425", + "82": "21888242871839275222246405745257275088548364400416034343698204186575808479233", + "83": "21888242871839275222246405745257275088548364400416034343698204186575808462849", + "84": "21888242871839275222246405745257275088548364400416034343698204186575808430081", + "85": "21888242871839275222246405745257275088548364400416034343698204186575808364545", + "86": "21888242871839275222246405745257275088548364400416034343698204186575808233473", + "87": "21888242871839275222246405745257275088548364400416034343698204186575807971329", + "88": "21888242871839275222246405745257275088548364400416034343698204186575807447041", + "89": "21888242871839275222246405745257275088548364400416034343698204186575806398465", + "90": "21888242871839275222246405745257275088548364400416034343698204186575804301313", + "91": "21888242871839275222246405745257275088548364400416034343698204186575800107009", + "92": "21888242871839275222246405745257275088548364400416034343698204186575791718401", + "93": "21888242871839275222246405745257275088548364400416034343698204186575774941185", + "94": "21888242871839275222246405745257275088548364400416034343698204186575741386753", + "95": "21888242871839275222246405745257275088548364400416034343698204186575674277889", + "96": "21888242871839275222246405745257275088548364400416034343698204186575540060161", + "97": "21888242871839275222246405745257275088548364400416034343698204186575271624705", + "98": "21888242871839275222246405745257275088548364400416034343698204186574734753793", + "99": "21888242871839275222246405745257275088548364400416034343698204186573661011969" + }, + {} + ], + [ + { + "69": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "69": "1" + }, + {} + ], + [ + { + "70": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "70": "1" + }, + {} + ], + [ + { + "71": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "71": "1" + }, + {} + ], + [ + { + "72": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "72": "1" + }, + {} + ], + [ + { + "73": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "73": "1" + }, + {} + ], + [ + { + "74": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "74": "1" + }, + {} + ], + [ + { + "75": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "75": "1" + }, + {} + ], + [ + { + "76": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "76": "1" + }, + {} + ], + [ + { + "77": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "77": "1" + }, + {} + ], + [ + { + "78": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "78": "1" + }, + {} + ], + [ + { + "79": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "79": "1" + }, + {} + ], + [ + { + "80": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "80": "1" + }, + {} + ], + [ + { + "81": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "81": "1" + }, + {} + ], + [ + { + "82": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "82": "1" + }, + {} + ], + [ + { + "83": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "83": "1" + }, + {} + ], + [ + { + "84": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "84": "1" + }, + {} + ], + [ + { + "85": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "85": "1" + }, + {} + ], + [ + { + "86": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "86": "1" + }, + {} + ], + [ + { + "87": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "87": "1" + }, + {} + ], + [ + { + "88": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "88": "1" + }, + {} + ], + [ + { + "89": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "89": "1" + }, + {} + ], + [ + { + "90": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "90": "1" + }, + {} + ], + [ + { + "91": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "91": "1" + }, + {} + ], + [ + { + "92": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "92": "1" + }, + {} + ], + [ + { + "93": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "93": "1" + }, + {} + ], + [ + { + "94": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "94": "1" + }, + {} + ], + [ + { + "95": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "95": "1" + }, + {} + ], + [ + { + "96": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "96": "1" + }, + {} + ], + [ + { + "97": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "97": "1" + }, + {} + ], + [ + { + "98": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "98": "1" + }, + {} + ], + [ + { + "99": "1" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "99": "1" + }, + {} + ], + [ + { + "1": "1368015184586208377692962645747596915105636153469842199510504144919754569108", + "2": "20520227687253066844553443099509678173442728246946192144187700041656053926509", + "3": "20520227687253066844553443099509678173442728246946192144187700041656053926509" + }, + { + "0": "21888242871839275222246405745257275088548364400416034343698204186575808495616", + "1": "1368015184586208377692962645747596915105636153469842199510504144919754569108", + "2": "20520227687253066844553443099509678173442728246946192144187700041656053926509", + "3": "20520227687253066844553443099509678173442728246946192144187700041656053926509" + }, + {} + ] + ], + "templates": { + "Num2Bits": "function Num2Bits(ctx)\n{\n ctx.setVar(\"lc1\", [], \"0\");\n for (ctx.setVar(\"i\", [], \"0\");bigInt(ctx.getVar(\"i\",[])).lt(bigInt(ctx.getVar(\"n\",[]))) ? 1 : 0;(ctx.setVar(\"i\", [], bigInt(ctx.getVar(\"i\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__))\n {\n ctx.setSignal(\"out\", [ctx.getVar(\"i\",[])], bigInt(bigInt(ctx.getVar(\"i\",[])).greater(bigInt(256)) ? 0 : bigInt(ctx.getSignal(\"in\", [])).shr(bigInt(ctx.getVar(\"i\",[]))).and(__MASK__)).and(bigInt(\"1\")).and(__MASK__));\n ctx.assert(bigInt(ctx.getSignal(\"out\", [ctx.getVar(\"i\",[])])).mul(bigInt(bigInt(ctx.getSignal(\"out\", [ctx.getVar(\"i\",[])])).add(__P__).sub(bigInt(\"1\")).mod(__P__))).mod(__P__), \"0\");\n ctx.setVar(\"lc1\", [], bigInt(ctx.getVar(\"lc1\",[])).add(bigInt(bigInt(ctx.getSignal(\"out\", [ctx.getVar(\"i\",[])])).mul(bigInt(bigInt(\"2\").modPow(bigInt(ctx.getVar(\"i\",[])), __P__))).mod(__P__))).mod(__P__));\n }\n\n ctx.assert(ctx.getVar(\"lc1\",[]), ctx.getSignal(\"in\", []));\n}\n\n", + "Bits2Num": "function Bits2Num(ctx)\n{\n ctx.setVar(\"lc1\", [], \"0\");\n for (ctx.setVar(\"i\", [], \"0\");bigInt(ctx.getVar(\"i\",[])).lt(bigInt(ctx.getVar(\"n\",[]))) ? 1 : 0;(ctx.setVar(\"i\", [], bigInt(ctx.getVar(\"i\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__))\n {\n ctx.setVar(\"lc1\", [], bigInt(ctx.getVar(\"lc1\",[])).add(bigInt(bigInt(ctx.getSignal(\"in\", [ctx.getVar(\"i\",[])])).mul(bigInt(bigInt(\"2\").modPow(bigInt(ctx.getVar(\"i\",[])), __P__))).mod(__P__))).mod(__P__));\n }\n\n ctx.setSignal(\"out\", [], ctx.getVar(\"lc1\",[]));\n ctx.assert(ctx.getSignal(\"out\", []), ctx.getVar(\"lc1\",[]));\n}\n\n", + "BinSum": "function BinSum(ctx)\n{\n ctx.setVar(\"nout\", [], ctx.callFunction(\"nbits\", [bigInt(bigInt(bigInt(\"2\").modPow(bigInt(ctx.getVar(\"n\",[])), __P__)).add(__P__).sub(bigInt(\"1\")).mod(__P__)).mul(bigInt(ctx.getVar(\"ops\",[]))).mod(__P__)]));\n ctx.setVar(\"lin\", [], \"0\");\n ctx.setVar(\"lout\", [], \"0\");\n for (ctx.setVar(\"k\", [], \"0\");bigInt(ctx.getVar(\"k\",[])).lt(bigInt(ctx.getVar(\"n\",[]))) ? 1 : 0;(ctx.setVar(\"k\", [], bigInt(ctx.getVar(\"k\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__))\n {\n for (ctx.setVar(\"j\", [], \"0\");bigInt(ctx.getVar(\"j\",[])).lt(bigInt(ctx.getVar(\"ops\",[]))) ? 1 : 0;(ctx.setVar(\"j\", [], bigInt(ctx.getVar(\"j\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__))\n {\n ctx.setVar(\"lin\", [], bigInt(ctx.getVar(\"lin\",[])).add(bigInt(bigInt(ctx.getSignal(\"in\", [ctx.getVar(\"j\",[]),ctx.getVar(\"k\",[])])).mul(bigInt(bigInt(\"2\").modPow(bigInt(ctx.getVar(\"k\",[])), __P__))).mod(__P__))).mod(__P__));\n }\n\n }\n\n for (ctx.setVar(\"k\", [], \"0\");bigInt(ctx.getVar(\"k\",[])).lt(bigInt(ctx.getVar(\"nout\",[]))) ? 1 : 0;(ctx.setVar(\"k\", [], bigInt(ctx.getVar(\"k\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__))\n {\n ctx.setSignal(\"out\", [ctx.getVar(\"k\",[])], bigInt(bigInt(ctx.getVar(\"k\",[])).greater(bigInt(256)) ? 0 : bigInt(ctx.getVar(\"lin\",[])).shr(bigInt(ctx.getVar(\"k\",[]))).and(__MASK__)).and(bigInt(\"1\")).and(__MASK__));\n ctx.assert(bigInt(ctx.getSignal(\"out\", [ctx.getVar(\"k\",[])])).mul(bigInt(bigInt(ctx.getSignal(\"out\", [ctx.getVar(\"k\",[])])).add(__P__).sub(bigInt(\"1\")).mod(__P__))).mod(__P__), \"0\");\n ctx.setVar(\"lout\", [], bigInt(ctx.getVar(\"lout\",[])).add(bigInt(bigInt(ctx.getSignal(\"out\", [ctx.getVar(\"k\",[])])).mul(bigInt(bigInt(\"2\").modPow(bigInt(ctx.getVar(\"k\",[])), __P__))).mod(__P__))).mod(__P__));\n }\n\n ctx.assert(ctx.getVar(\"lin\",[]), ctx.getVar(\"lout\",[]));\n}\n\n", + "A": "function A(ctx)\n{\n ctx.setPin(\"n2ba\", [], \"in\", [], ctx.getSignal(\"a\", []));\n ctx.assert(ctx.getPin(\"n2ba\", [], \"in\", []), ctx.getSignal(\"a\", []));\n ctx.setPin(\"n2bb\", [], \"in\", [], ctx.getSignal(\"b\", []));\n ctx.assert(ctx.getPin(\"n2bb\", [], \"in\", []), ctx.getSignal(\"b\", []));\n for (ctx.setVar(\"i\", [], \"0\");bigInt(ctx.getVar(\"i\",[])).lt(bigInt(\"32\")) ? 1 : 0;(ctx.setVar(\"i\", [], bigInt(ctx.getVar(\"i\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__))\n {\n ctx.setPin(\"sum\", [], \"in\", [\"0\",ctx.getVar(\"i\",[])], ctx.getPin(\"n2ba\", [], \"out\", [ctx.getVar(\"i\",[])]));\n ctx.assert(ctx.getPin(\"sum\", [], \"in\", [\"0\",ctx.getVar(\"i\",[])]), ctx.getPin(\"n2ba\", [], \"out\", [ctx.getVar(\"i\",[])]));\n ctx.setPin(\"sum\", [], \"in\", [\"1\",ctx.getVar(\"i\",[])], ctx.getPin(\"n2bb\", [], \"out\", [ctx.getVar(\"i\",[])]));\n ctx.assert(ctx.getPin(\"sum\", [], \"in\", [\"1\",ctx.getVar(\"i\",[])]), ctx.getPin(\"n2bb\", [], \"out\", [ctx.getVar(\"i\",[])]));\n ctx.setPin(\"b2n\", [], \"in\", [ctx.getVar(\"i\",[])], ctx.getPin(\"sum\", [], \"out\", [ctx.getVar(\"i\",[])]));\n ctx.assert(ctx.getPin(\"b2n\", [], \"in\", [ctx.getVar(\"i\",[])]), ctx.getPin(\"sum\", [], \"out\", [ctx.getVar(\"i\",[])]));\n }\n\n ctx.setSignal(\"out\", [], ctx.getPin(\"b2n\", [], \"out\", []));\n ctx.assert(ctx.getSignal(\"out\", []), ctx.getPin(\"b2n\", [], \"out\", []));\n}\n\n" + }, + "functions": { + "nbits": { + "params": [ + "a" + ], + "func": "function nbits(ctx) {\n ctx.setVar(\"n\", [], \"1\");\n ctx.setVar(\"r\", [], \"0\");\n while (bigInt(bigInt(ctx.getVar(\"n\",[])).add(__P__).sub(bigInt(\"1\")).mod(__P__)).lt(bigInt(ctx.getVar(\"a\",[]))) ? 1 : 0) {\n (ctx.setVar(\"r\", [], bigInt(ctx.getVar(\"r\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__);\n ctx.setVar(\"n\", [], bigInt(ctx.getVar(\"n\",[])).mul(bigInt(\"2\")).mod(__P__));\n }\n\n return ctx.getVar(\"r\",[]);;\n}\n" + } + }, + "nPrvInputs": 1, + "nPubInputs": 1, + "nInputs": 2, + "nOutputs": 1, + "nVars": 101, + "nConstants": 0, + "nSignals": 101 +} \ No newline at end of file diff --git a/src/compiler.js b/src/compiler.js index 33554c1..16efc33 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -23,17 +23,20 @@ const bigInt = require("big-integer"); const __P__ = new bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617"); const __MASK__ = new bigInt(2).pow(253).minus(1); const assert = require("assert"); -const gen = require("./gencode"); +const genCode = require("./gencode"); const exec = require("./exec"); const lc = require("./lcalgebra"); +const util = require("util"); +const fs_writeFile = util.promisify(fs.writeFile) + module.exports = compile; const parser = require("../parser/jaz.js").parser; const timeout = ms => new Promise(res => setTimeout(res, ms)) -async function compile(srcFile) { +async function compile(srcFile, cFile) { const fullFileName = srcFile; const fullFilePath = path.dirname(fullFileName); @@ -82,9 +85,13 @@ async function compile(srcFile) { ctx.scopes = [{}]; - const mainCode = gen(ctx,ast); + const mainCode = genCode(ctx,ast); if (ctx.error) throw(ctx.error); + if (cFile) { + await fs_writeFile(cFile, mainCode); + } + const def = buildCircuitDef(ctx, mainCode); return def; @@ -399,4 +406,9 @@ function buildConstraints(ctx) { } +function generateCCode(ctx) { + +} + + diff --git a/src/gencode.js b/src/gencode.js index 4086011..47eacce 100644 --- a/src/gencode.js +++ b/src/gencode.js @@ -19,7 +19,7 @@ const bigInt = require("big-integer"); -module.exports = gen; +module.exports = genCode; function ident(text) { let lines = text.split("\n"); @@ -170,8 +170,9 @@ function genBlock(ctx, ast) { return "{\n"+ident(body)+"}\n"; } + function genTemplateDef(ctx, ast) { - let S = "function(ctx) "; + let S = `function ${ast.name}(ctx)\n`; const newScope = {}; for (let i=0; i< ast.params.length; i++) { @@ -180,6 +181,7 @@ function genTemplateDef(ctx, ast) { ctx.scopes.push(newScope); S += genBlock(ctx, ast.block); + S += "\n"; ctx.scopes.pop(); // const scope = ctx.scopes[ctx.scopes.length-1]; @@ -190,11 +192,11 @@ function genTemplateDef(ctx, ast) { }; ctx.templates[ast.name] = S; - return ""; + return S; } function genFunctionDef(ctx, ast) { - let S = "function(ctx) "; + let S = `function ${ast.name}(ctx) `; const newScope = {}; const params = []; @@ -216,7 +218,7 @@ function genFunctionDef(ctx, ast) { ctx.functions[ast.name] = S; ctx.functionParams[ast.name] = params; - return ""; + return S; } function genFor(ctx, ast) { @@ -228,7 +230,7 @@ function genFor(ctx, ast) { if (ctx.error) return; const body = gen(ctx, ast.body); if (ctx.error) return; - return `for (${init};${condition};${step}) { \n${body}\n }\n`; + return `for (${init};${condition};${step})\n${body}\n`; } function genWhile(ctx, ast) { @@ -236,7 +238,7 @@ function genWhile(ctx, ast) { if (ctx.error) return; const body = gen(ctx, ast.body); if (ctx.error) return; - return `while (${condition}) {\n${body}\n}\n`; + return `while (${condition}) ${body}\n`; } function genIf(ctx, ast) { @@ -246,7 +248,7 @@ function genIf(ctx, ast) { if (ctx.error) return; const elseBody = gen(ctx, ast.else); if (ctx.error) return; - return `if (${condition}) {\n${thenBody}\n} else {\n${elseBody}\n}\n`; + return `if (${condition}) ${thenBody} else ${elseBody}\n`; } @@ -535,7 +537,21 @@ function genTerCon(ctx, ast) { } function genInclude(ctx, ast) { - return ast.block ? gen(ctx, ast.block) : ""; + let body = genCode(ctx, ast.block); + return `// File: ${ast.file}\n` +body+"\n"; +} + +function genCode(ctx, ast) { + let body = ""; + for (let i=0; i> i) & _0x1; + assert(out[i]*(out[i] - _0x1), _0x0); + lc1 += out[i] * (2**i); + } + + assert(lc1, in); +} diff --git a/wasm/context.h b/wasm/context.h new file mode 100644 index 0000000..e69de29 diff --git a/doc/wasmmodule.c b/wasm/wasmmodule.c similarity index 100% rename from doc/wasmmodule.c rename to wasm/wasmmodule.c