Browse Source

Dependencies updated and publish

wasm
Jordi Baylina 6 years ago
parent
commit
89b711050d
No known key found for this signature in database GPG Key ID: 7480C80C1BE43112
31 changed files with 349 additions and 22759 deletions
  1. +0
    -0
      83
  2. +0
    -1226
      barry.js
  3. +58
    -0
      cli.js
  4. +0
    -290
      constant_test.json
  5. +0
    -3
      input.json
  6. +0
    -3
      input_barry.json
  7. +0
    -4
      input_jose.json
  8. +0
    -27
      inputmx.json
  9. +0
    -154
      jose.js
  10. +0
    -1
      jose.out
  11. +0
    -2545
      multiplexer.js
  12. +0
    -1
      outmx.js
  13. +0
    -1
      output_barry.json
  14. +191
    -60
      package-lock.json
  15. +13
    -4
      package.json
  16. +0
    -0
      parser/jaz.js
  17. +0
    -10767
      sha256.js
  18. +0
    -1
      sha256.out
  19. +0
    -27
      src/cli.js
  20. +19
    -1
      src/compiler.js
  21. +20
    -1
      src/exec.js
  22. +19
    -1
      src/gencode.js
  23. +19
    -0
      src/lcalgebra.js
  24. +0
    -27
      src/rt.js
  25. +0
    -2371
      sum.json
  26. +0
    -5050
      sum_test.js
  27. +0
    -1
      sum_test.out
  28. +0
    -1
      test.jaz
  29. +10
    -2
      test/sha256.js
  30. +0
    -189
      tobin.js
  31. +0
    -1
      tobin.w

+ 0
- 0
83


+ 0
- 1226
barry.js
File diff suppressed because it is too large
View File


+ 58
- 0
cli.js

@ -0,0 +1,58 @@
#!/usr/bin/env node
/*
Copyright 2018 0kims association
This file is part of jaz (Zero Knowlage Circuit compiler).
jaz is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
jaz is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with jaz. If not, see <https://www.gnu.org/licenses/>.
*/
/* eslint-disable no-console */
const fs = require("fs");
const path = require("path");
const compiler = require("./src/compiler");
const argv = require("yargs")
.version(function() {
return require("./package").version;
})
.usage("jaz -s [input source circuit file] -o [output definition circuit file]")
.alias("s", "source")
.alias("o", "output")
.require(["s","o"])
.help("h")
.alias("h", "help")
.epilogue(`Copyright (C) 2018 0kims association
This program comes with ABSOLUTELY NO WARRANTY;
This is free software, and you are welcome to redistribute it
under certain conditions; see the COPYING file in the official
repo directory at https://github.com/iden3/jaz `)
.argv;
const fullFileName = path.resolve(process.cwd(), argv.source);
compiler(fullFileName).then( (cir) => {
fs.writeFileSync(argv.output, JSON.stringify(cir, null, 1), "utf8");
}, (err) => {
console.error(`ERROR at ${err.errFile}:${err.pos.first_line},${err.pos.first_column}-${err.pos.last_line},${err.pos.last_column} ${err.errStr}`);
console.error(JSON.stringify(err.ast, null, 1));
process.exit(1);
});

+ 0
- 290
constant_test.json

@ -1,290 +0,0 @@
{
"mainCode": "{\n {\n }\n}\n",
"signalName2Idx": {
"one": 0,
"main.in": 1,
"main.h0.out[0]": 2,
"main.h0.out[1]": 3,
"main.h0.out[2]": 4,
"main.h0.out[3]": 5,
"main.h0.out[4]": 6,
"main.h0.out[5]": 7,
"main.h0.out[6]": 8,
"main.h0.out[7]": 9,
"main.h0.out[8]": 10,
"main.h0.out[9]": 11,
"main.h0.out[10]": 12,
"main.h0.out[11]": 13,
"main.h0.out[12]": 14,
"main.h0.out[13]": 15,
"main.h0.out[14]": 16,
"main.h0.out[15]": 17,
"main.h0.out[16]": 18,
"main.h0.out[17]": 19,
"main.h0.out[18]": 20,
"main.h0.out[19]": 21,
"main.h0.out[20]": 22,
"main.h0.out[21]": 23,
"main.h0.out[22]": 24,
"main.h0.out[23]": 25,
"main.h0.out[24]": 26,
"main.h0.out[25]": 27,
"main.h0.out[26]": 28,
"main.h0.out[27]": 29,
"main.h0.out[28]": 30,
"main.h0.out[29]": 31,
"main.h0.out[30]": 32,
"main.h0.out[31]": 33
},
"components": [
{
"name": "main",
"params": {},
"template": "A",
"inputSignals": 1
},
{
"name": "main.h0",
"params": {
"x": "8"
},
"template": "K",
"inputSignals": 0
}
],
"componentName2Idx": {
"main": 0,
"main.h0": 1
},
"signals": [
{
"names": [
"one"
],
"triggerComponents": []
},
{
"names": [
"main.in"
],
"triggerComponents": [
0
]
},
{
"names": [
"main.h0.out[0]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[1]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[2]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[3]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[4]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[5]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[6]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[7]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[8]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[9]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[10]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[11]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[12]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[13]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[14]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[15]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[16]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[17]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[18]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[19]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[20]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[21]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[22]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[23]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[24]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[25]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[26]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[27]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[28]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[29]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[30]"
],
"triggerComponents": []
},
{
"names": [
"main.h0.out[31]"
],
"triggerComponents": []
}
],
"constrains": [
[
{},
{},
{
"0": "21888242871839275222246405745257275088548364400416034343698204186572184114537",
"1": "1"
}
]
],
"templates": {
"H": "function(ctx) {\n ctx.setVar(\"c\", [], [\"1779033703\",\"3144134277\",\"1013904242\",\"2773480762\",\"1359893119\",\"2600822924\",\"528734635\",\"1541459225\"]);\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.setSignal(\"out\", [ctx.getVar(\"i\",[])], bigInt(bigInt(ctx.getVar(\"i\",[])).greater(bigInt(256)) ? 0 : bigInt(ctx.getVar(\"c\",[ctx.getVar(\"x\",[])])).shr(bigInt(ctx.getVar(\"i\",[]))).and(__MASK__)).and(bigInt(\"1\")).and(__MASK__));\n ctx.assert(ctx.getSignal(\"out\", [ctx.getVar(\"i\",[])]), bigInt(bigInt(ctx.getVar(\"i\",[])).greater(bigInt(256)) ? 0 : bigInt(ctx.getVar(\"c\",[ctx.getVar(\"x\",[])])).shr(bigInt(ctx.getVar(\"i\",[]))).and(__MASK__)).and(bigInt(\"1\")).and(__MASK__));\n }\n}\n",
"K": "function(ctx) {\n ctx.setVar(\"c\", [], [\"1116352408\",\"1899447441\",\"3049323471\",\"3921009573\",\"961987163\",\"1508970993\",\"2453635748\",\"2870763221\",\"3624381080\",\"310598401\",\"607225278\",\"1426881987\",\"1925078388\",\"2162078206\",\"2614888103\",\"3248222580\",\"3835390401\",\"4022224774\",\"264347078\",\"604807628\",\"770255983\",\"1249150122\",\"1555081692\",\"1996064986\",\"2554220882\",\"2821834349\",\"2952996808\",\"3210313671\",\"3336571891\",\"3584528711\",\"113926993\",\"338241895\",\"666307205\",\"773529912\",\"1294757372\",\"1396182291\",\"1695183700\",\"1986661051\",\"2177026350\",\"2456956037\",\"2730485921\",\"2820302411\",\"3259730800\",\"3345764771\",\"3516065817\",\"3600352804\",\"4094571909\",\"275423344\",\"430227734\",\"506948616\",\"659060556\",\"883997877\",\"958139571\",\"1322822218\",\"1537002063\",\"1747873779\",\"1955562222\",\"2024104815\",\"2227730452\",\"2361852424\",\"2428436474\",\"2756734187\",\"3204031479\",\"3329325298\"]);\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.setSignal(\"out\", [ctx.getVar(\"i\",[])], bigInt(bigInt(ctx.getVar(\"i\",[])).greater(bigInt(256)) ? 0 : bigInt(ctx.getVar(\"c\",[ctx.getVar(\"x\",[])])).shr(bigInt(ctx.getVar(\"i\",[]))).and(__MASK__)).and(bigInt(\"1\")).and(__MASK__));\n ctx.assert(ctx.getSignal(\"out\", [ctx.getVar(\"i\",[])]), bigInt(bigInt(ctx.getVar(\"i\",[])).greater(bigInt(256)) ? 0 : bigInt(ctx.getVar(\"c\",[ctx.getVar(\"x\",[])])).shr(bigInt(ctx.getVar(\"i\",[]))).and(__MASK__)).and(bigInt(\"1\")).and(__MASK__));\n }\n}\n",
"A": "function(ctx) {\n ctx.setVar(\"lc\", [], \"0\");\n ctx.setVar(\"e\", [], \"1\");\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.setVar(\"lc\", [], bigInt(ctx.getVar(\"lc\",[])).add(bigInt(bigInt(ctx.getVar(\"e\",[])).mul(bigInt(ctx.getPin(\"h0\", [], \"out\", [ctx.getVar(\"i\",[])]))).mod(__P__))).mod(__P__));\n ctx.setVar(\"e\", [], bigInt(ctx.getVar(\"e\",[])).mul(bigInt(\"2\")).mod(__P__));\n }\n ctx.assert(ctx.getVar(\"lc\",[]), ctx.getSignal(\"in\", []));\n}\n"
},
"functions": {},
"nPrvInputs": 0,
"nPubInputs": 1,
"nInputs": 1,
"nOutputs": 0,
"nVars": 2,
"nConstants": 32,
"nSignals": 34
}

+ 0
- 3
input.json

@ -1,3 +0,0 @@
{
"inp": "3"
}

+ 0
- 3
input_barry.json

@ -1,3 +0,0 @@
{
"in": "10"
}

+ 0
- 4
input_jose.json

@ -1,4 +0,0 @@
{
"s1": "24",
"s2": "1"
}

+ 0
- 27
inputmx.json

@ -1,27 +0,0 @@
{
"inp[0][0]": 100,
"inp[0][1]": 101,
"inp[0][2]": 102,
"inp[0][3]": 103,
"inp[0][4]": 104,
"inp[0][5]": 105,
"inp[0][6]": 106,
"inp[0][7]": 107,
"inp[1][0]": 110,
"inp[1][1]": 111,
"inp[1][2]": 112,
"inp[1][3]": 113,
"inp[1][4]": 114,
"inp[1][5]": 115,
"inp[1][6]": 116,
"inp[1][7]": 117,
"inp[2][0]": 120,
"inp[2][1]": 121,
"inp[2][2]": 122,
"inp[2][3]": 123,
"inp[2][4]": 124,
"inp[2][5]": 125,
"inp[2][6]": 126,
"inp[2][7]": 127,
"sel": 1
}

+ 0
- 154
jose.js

@ -1,154 +0,0 @@
const bigInt = require("big-integer");
const __P__ = new bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208583");
const __MASK__ = new bigInt(2).pow(253).minus(1);
const circuit = {};
module.exports = circuit;
circuit.signals={
"one": {
"fullName": "one",
"value": "1",
"equivalence": "",
"direction": "",
"id": 0
},
"main.s1": {
"fullName": "main.s1",
"direction": "IN",
"component": "main",
"equivalence": "",
"alias": [
"main.s1"
],
"id": 1
},
"main.s2": {
"fullName": "main.s2",
"direction": "IN",
"component": "main",
"equivalence": "",
"alias": [
"main.s2"
],
"id": 2
},
"main.s3": {
"fullName": "main.s3",
"direction": "OUT",
"component": "main",
"equivalence": "",
"alias": [
"main.s3"
],
"id": 3
}
};
circuit.components={
"main": {
"signals": [
"main.s1",
"main.s2",
"main.s3"
],
"params": {},
"template": "AND",
"inputSignals": 2
}
};
circuit.signalConstrains=[
{
"type": "QEQ",
"a": {
"type": "LINEARCOMBINATION",
"values": {
"main.s1": "21888242871839275222246405745257275088696311157297823662689037894645226208582"
}
},
"b": {
"type": "LINEARCOMBINATION",
"values": {
"main.s2": "1"
}
},
"c": {
"type": "LINEARCOMBINATION",
"values": {
"main.s3": "1"
}
}
},
{
"type": "QEQ",
"a": {
"type": "LINEARCOMBINATION",
"values": {
"main.s1": "1"
}
},
"b": {
"type": "LINEARCOMBINATION",
"values": {
"main.s1": "1",
"one": "21888242871839275222246405745257275088696311157297823662689037894645226208582"
}
},
"c": {
"type": "LINEARCOMBINATION",
"values": {}
}
},
{
"type": "QEQ",
"a": {
"type": "LINEARCOMBINATION",
"values": {
"main.s2": "1"
}
},
"b": {
"type": "LINEARCOMBINATION",
"values": {
"main.s2": "1",
"one": "21888242871839275222246405745257275088696311157297823662689037894645226208582"
}
},
"c": {
"type": "LINEARCOMBINATION",
"values": {}
}
}
];
circuit.witnessNames=[
[
"one"
],
[
"main.s1"
],
[
"main.s2"
],
[
"main.s3"
]
];
{
}
circuit.templates = {};
circuit.templates["AND"] = function(ctx) {
ctx.setSignal("s3", [], bigInt(ctx.getSignal("s1", [])).times(ctx.getSignal("s2", [])).mod(__P__));
ctx.assert(ctx.getSignal("s3", []), bigInt(ctx.getSignal("s1", [])).times(ctx.getSignal("s2", [])).mod(__P__));
ctx.assert(bigInt(ctx.getSignal("s1", [])).times(bigInt(ctx.getSignal("s1", [])).add(__P__).minus("1").mod(__P__)).mod(__P__), "0");
ctx.assert(bigInt(ctx.getSignal("s2", [])).times(bigInt(ctx.getSignal("s2", [])).add(__P__).minus("1").mod(__P__)).mod(__P__), "0");
}
;
circuit.functionParams={};
circuit.functions = {};

+ 0
- 1
jose.out

@ -1 +0,0 @@
["1","0","1","0"]

+ 0
- 2545
multiplexer.js
File diff suppressed because it is too large
View File


+ 0
- 1
outmx.js

@ -1 +0,0 @@
["1","100","101","102","103","104","105","106","107","110","111","112","113","114","115","116","117","120","121","122","123","124","125","126","127","1","110","111","112","113","114","115","116","117","0","1","0","1","0","110","0","0","111","0","0","112","0","0","113","0","0","114","0","0","115","0","0","116","0","0","117","0"]

+ 0
- 1
output_barry.json

@ -1 +0,0 @@
["1","10","0","1","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]

+ 191
- 60
package-lock.json

@ -4,6 +4,34 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@babel/code-frame": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz",
"integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==",
"dev": true,
"requires": {
"@babel/highlight": "^7.0.0"
}
},
"@babel/highlight": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz",
"integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==",
"dev": true,
"requires": {
"chalk": "^2.0.0",
"esutils": "^2.0.2",
"js-tokens": "^4.0.0"
},
"dependencies": {
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"dev": true
}
}
},
"JSONSelect": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/JSONSelect/-/JSONSelect-0.4.0.tgz",
@ -166,12 +194,6 @@
"concat-map": "0.0.1"
}
},
"browser-stdout": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz",
"integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
"dev": true
},
"caller-path": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz",
@ -295,12 +317,6 @@
"integrity": "sha1-fQAj6usVTo7p/Oddy5I9DtFmd3Q=",
"dev": true
},
"commander": {
"version": "2.15.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
"dev": true
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@ -369,12 +385,6 @@
"rimraf": "^2.2.8"
}
},
"diff": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz",
"integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==",
"dev": true
},
"doctrine": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz",
@ -517,6 +527,12 @@
"estraverse": "^4.1.1"
}
},
"eslint-utils": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz",
"integrity": "sha512-Z7YjnIldX+2XMcjr7ZkgEsOj/bREONV60qYeB/bjMAqqqZ4zxKyWX+BOUkdmRmA9riiIPVvo5x86m5elviOk0Q==",
"dev": true
},
"eslint-visitor-keys": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
@ -699,12 +715,6 @@
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
"dev": true
},
"growl": {
"version": "1.10.5",
"resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz",
"integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==",
"dev": true
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
@ -735,12 +745,6 @@
"integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=",
"dev": true
},
"he": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
"integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=",
"dev": true
},
"iconv-lite": {
"version": "0.4.23",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz",
@ -1005,36 +1009,6 @@
}
}
},
"mocha": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz",
"integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==",
"dev": true,
"requires": {
"browser-stdout": "1.3.1",
"commander": "2.15.1",
"debug": "3.1.0",
"diff": "3.5.0",
"escape-string-regexp": "1.0.5",
"glob": "7.1.2",
"growl": "1.10.5",
"he": "1.1.1",
"minimatch": "3.0.4",
"mkdirp": "0.5.1",
"supports-color": "5.4.0"
},
"dependencies": {
"supports-color": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz",
"integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==",
"dev": true,
"requires": {
"has-flag": "^3.0.0"
}
}
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
@ -1430,6 +1404,12 @@
"os-tmpdir": "~1.0.2"
}
},
"tslib": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==",
"dev": true
},
"type-check": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
@ -1488,6 +1468,157 @@
"requires": {
"mkdirp": "^0.5.1"
}
},
"zksnark": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/zksnark/-/zksnark-0.0.1.tgz",
"integrity": "sha512-DppjGsfSwcd4M0tBP3DsxnUcWjLsvyXSQWm1Pexpcxdu6J7mgFjrMPskC/NgkOUBJda1Eyd4RKKm752nP69Njg==",
"dev": true,
"requires": {
"big-integer": "^1.6.34",
"chai": "^4.1.2",
"eslint": "^5.3.0"
},
"dependencies": {
"ajv": {
"version": "6.5.3",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.3.tgz",
"integrity": "sha512-LqZ9wY+fx3UMiiPd741yB2pj3hhil+hQc8taf4o2QGRFpWgZ2V5C8HA165DY9sS3fJwsk7uT7ZlFEyC3Ig3lLg==",
"dev": true,
"requires": {
"fast-deep-equal": "^2.0.1",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
}
},
"big-integer": {
"version": "1.6.35",
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.35.tgz",
"integrity": "sha512-jqLsX6dzmPHOhApAUyGwrpzqn3DXpdTqbOM6baPys7A423ys7IsTpcucDVGP0PmzxGsPYbW3xVOJ4SxAzI0vqQ==",
"dev": true
},
"chardet": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz",
"integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==",
"dev": true
},
"eslint": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-5.5.0.tgz",
"integrity": "sha512-m+az4vYehIJgl1Z0gb25KnFXeqQRdNreYsei1jdvkd9bB+UNQD3fsuiC2AWSQ56P+/t++kFSINZXFbfai+krOw==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
"ajv": "^6.5.3",
"chalk": "^2.1.0",
"cross-spawn": "^6.0.5",
"debug": "^3.1.0",
"doctrine": "^2.1.0",
"eslint-scope": "^4.0.0",
"eslint-utils": "^1.3.1",
"eslint-visitor-keys": "^1.0.0",
"espree": "^4.0.0",
"esquery": "^1.0.1",
"esutils": "^2.0.2",
"file-entry-cache": "^2.0.0",
"functional-red-black-tree": "^1.0.1",
"glob": "^7.1.2",
"globals": "^11.7.0",
"ignore": "^4.0.6",
"imurmurhash": "^0.1.4",
"inquirer": "^6.1.0",
"is-resolvable": "^1.1.0",
"js-yaml": "^3.12.0",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.3.0",
"lodash": "^4.17.5",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"natural-compare": "^1.4.0",
"optionator": "^0.8.2",
"path-is-inside": "^1.0.2",
"pluralize": "^7.0.0",
"progress": "^2.0.0",
"regexpp": "^2.0.0",
"require-uncached": "^1.0.3",
"semver": "^5.5.1",
"strip-ansi": "^4.0.0",
"strip-json-comments": "^2.0.1",
"table": "^4.0.3",
"text-table": "^0.2.0"
}
},
"external-editor": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz",
"integrity": "sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA==",
"dev": true,
"requires": {
"chardet": "^0.7.0",
"iconv-lite": "^0.4.24",
"tmp": "^0.0.33"
}
},
"iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"dev": true,
"requires": {
"safer-buffer": ">= 2.1.2 < 3"
}
},
"ignore": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
"integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
"dev": true
},
"inquirer": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.2.0.tgz",
"integrity": "sha512-QIEQG4YyQ2UYZGDC4srMZ7BjHOmNk1lR2JQj5UknBapklm6WHA+VVH7N+sUdX3A7NeCfGF8o4X1S3Ao7nAcIeg==",
"dev": true,
"requires": {
"ansi-escapes": "^3.0.0",
"chalk": "^2.0.0",
"cli-cursor": "^2.1.0",
"cli-width": "^2.0.0",
"external-editor": "^3.0.0",
"figures": "^2.0.0",
"lodash": "^4.17.10",
"mute-stream": "0.0.7",
"run-async": "^2.2.0",
"rxjs": "^6.1.0",
"string-width": "^2.1.0",
"strip-ansi": "^4.0.0",
"through": "^2.3.6"
}
},
"regexpp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.0.tgz",
"integrity": "sha512-g2FAVtR8Uh8GO1Nv5wpxW7VFVwHcCEr4wyA8/MHiRkO8uHoR5ntAA8Uq3P1vvMTX/BeQiRVSpDGLd+Wn5HNOTA==",
"dev": true
},
"rxjs": {
"version": "6.3.2",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.2.tgz",
"integrity": "sha512-hV7criqbR0pe7EeL3O66UYVg92IR0XsA97+9y+BWTePK9SKmEI5Qd3Zj6uPnGkNzXsBywBQWTvujPl+1Kn9Zjw==",
"dev": true,
"requires": {
"tslib": "^1.9.0"
}
},
"semver": {
"version": "5.5.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz",
"integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw==",
"dev": true
}
}
}
}
}

+ 13
- 4
package.json

@ -1,6 +1,6 @@
{
"name": "jaz",
"version": "0.0.1",
"version": "0.0.2",
"description": "Language to generate logica circuits",
"main": "index.js",
"directories": {
@ -8,7 +8,10 @@
},
"scripts": {
"test": "mocha",
"buildParser": "jison parser/jaz.jison"
"buildParser": "jison parser/jaz.jison -o parser/jaz.js"
},
"bin": {
"jaz": "cli.js"
},
"keywords": [
"zkSnarks",
@ -19,8 +22,12 @@
"ethereum",
"zcash"
],
"author": "Jordi Baylina",
"author": "0kims",
"license": "GPL-3.0",
"repository": {
"type": "git",
"url": "git+https://github.com/iden3/jaz.git"
},
"dependencies": {
"big-integer": "^1.6.32",
"optimist": "^0.6.1"
@ -28,6 +35,8 @@
"devDependencies": {
"chai": "^4.1.2",
"eslint": "^5.0.1",
"eslint-plugin-mocha": "^5.0.0"
"eslint-plugin-mocha": "^5.0.0",
"jison": "^0.4.18",
"zksnark": "0.0.2"
}
}

jaz.js → parser/jaz.js


+ 0
- 10767
sha256.js
File diff suppressed because it is too large
View File


+ 0
- 1
sha256.out

@ -1 +0,0 @@
["1","3624381080","3624381080","0","0","0","1","1","0","0","1","0","1","0","1","0","1","0","1","1","1","1","0","0","0","0","0","0","0","0","1","1","0","1","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]

+ 0
- 27
src/cli.js

@ -1,27 +0,0 @@
/* eslint-disable no-console */
const fs = require("fs");
const path = require("path");
const compiler = require("./compiler");
const argv = require("yargs")
.usage("jaz -s [input source circuit file] -o [output definition circuit file]")
.alias("s", "source")
.alias("o", "output")
.require(["s","o"])
.argv;
const fullFileName = path.resolve(process.cwd(), argv.source);
compiler(fullFileName).then( (cir) => {
fs.writeFileSync(argv.output, JSON.stringify(cir, null, 1), "utf8");
}, (err) => {
console.error(`ERROR at ${err.errFile}:${err.pos.first_line},${err.pos.first_column}-${err.pos.last_line},${err.pos.last_column} ${err.errStr}`);
console.error(JSON.stringify(err.ast, null, 1));
process.exit(1);
});

+ 19
- 1
src/compiler.js

@ -1,3 +1,21 @@
/*
Copyright 2018 0kims association
This file is part of jaz (Zero Knowlage Circuit compiler).
jaz is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
jaz is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with jaz. If not, see <https://www.gnu.org/licenses/>.
*/
const fs = require("fs");
const path = require("path");
@ -11,7 +29,7 @@ const lc = require("./lcalgebra");
module.exports = compile;
const parser = require("../jaz.js").parser;
const parser = require("../parser/jaz.js").parser;
function compile(srcFile) {

+ 20
- 1
src/exec.js

@ -1,3 +1,22 @@
/*
Copyright 2018 0kims association
This file is part of jaz (Zero Knowlage Circuit compiler).
jaz is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
jaz is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with jaz. If not, see <https://www.gnu.org/licenses/>.
*/
const path = require("path");
const fs = require("fs");
@ -6,7 +25,7 @@ const __P__ = new bigInt("218882428718392752222464057452572750885483644004160343
const __MASK__ = new bigInt(2).pow(253).minus(1);
const lc = require("./lcalgebra");
const parser = require("../jaz.js").parser;
const parser = require("../parser/jaz.js").parser;
/* TODO: Add lines information

+ 19
- 1
src/gencode.js

@ -1,8 +1,26 @@
/*
Copyright 2018 0kims association
This file is part of jaz (Zero Knowlage Circuit compiler).
jaz is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
jaz is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with jaz. If not, see <https://www.gnu.org/licenses/>.
*/
const bigInt = require("big-integer");
module.exports = gen;
function ident(text) {
let lines = text.split("\n");
for (let i=0; i<lines.length; i++) {

+ 19
- 0
src/lcalgebra.js

@ -1,3 +1,22 @@
/*
Copyright 2018 0kims association
This file is part of jaz (Zero Knowlage Circuit compiler).
jaz is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
jaz is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with jaz. If not, see <https://www.gnu.org/licenses/>.
*/
/*
NUMBER: a

+ 0
- 27
src/rt.js

@ -1,27 +0,0 @@
const fs = require("fs");
const path = require("path");
const calculateWitness = require("./calculateWitness.js");
const argv = require("optimist")
.alias("i", "input")
.alias("o", "output")
.alias("c", "circuit")
.argv;
const circuit = require(path.resolve(argv.circuit));
const inputSignals = JSON.parse(fs.readFileSync(argv.input, "utf8"));
try {
const w = calculateWitness(circuit, inputSignals);
fs.writeFileSync(argv.output, JSON.stringify(w), "utf8");
} catch(err) {
console.log("ERROR: " + err);
console.log(err.stack);
}

+ 0
- 2371
sum.json
File diff suppressed because it is too large
View File


+ 0
- 5050
sum_test.js
File diff suppressed because it is too large
View File


+ 0
- 1
sum_test.out

@ -1 +0,0 @@
["1","111","222","333","1","1","1","1","0","1","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","1","1","1","0","1","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","0","1","1","0","0","1","0","1","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]

+ 0
- 1
test.jaz

@ -1 +0,0 @@
a[1][2].b[3][4] <== c[5][6].d[7][8]

+ 10
- 2
test/sha256.js

@ -1,5 +1,6 @@
const chai = require("chai");
const path = require("path");
const zkSnark = require("zksnark");
const compiler = require("../index.js");
@ -8,7 +9,14 @@ const assert = chai.assert;
describe("SHA256 test", () => {
it("Should create a constant circuit", async () => {
const cir = await compiler(path.join(__dirname, "circuits", "constants_test.jaz"));
assert.equal(cir.nVars, 2);
const cirDef = await compiler(path.join(__dirname, "circuits", "constants_test.jaz"));
assert.equal(cirDef.nVars, 2);
const circuit = new zkSnark.Circuit(cirDef);
const witness = circuit.calculateWitness({ "in": "0xd807aa98" });
assert(witness[0].equals(zkSnark.bigInt(1)));
assert(witness[1].equals(zkSnark.bigInt("0xd807aa98")));
});
});

+ 0
- 189
tobin.js

@ -1,189 +0,0 @@
const bigInt = require("big-integer");
const __P__ = new bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208583");
const __MASK__ = new bigInt(2).pow(253).minus(1);
const circuit = {};
module.exports = circuit;
circuit.signals={
"one": {
"fullName": "one",
"value": "1",
"equivalence": "",
"direction": "",
"id": 0
},
"main.inp": {
"fullName": "main.inp",
"direction": "IN",
"component": "main",
"equivalence": "",
"alias": [
"main.inp"
],
"id": 1
},
"main.out[0]": {
"fullName": "main.out[0]",
"direction": "OUT",
"component": "main",
"equivalence": "",
"alias": [
"main.out[0]"
],
"id": 2
},
"main.out[1]": {
"fullName": "main.out[1]",
"direction": "OUT",
"component": "main",
"equivalence": "",
"alias": [
"main.out[1]"
],
"id": 3
},
"main.out[2]": {
"fullName": "main.out[2]",
"direction": "OUT",
"component": "main",
"equivalence": "",
"alias": [
"main.out[2]"
],
"id": 4
}
};
circuit.components={
"main": {
"signals": [
"main.inp",
"main.out[0]",
"main.out[1]",
"main.out[2]"
],
"params": {
"n": "3"
},
"template": "toBin",
"inputSignals": 1
}
};
circuit.signalConstrains=[
{
"type": "QEQ",
"a": {
"type": "LINEARCOMBINATION",
"values": {
"main.out[0]": "1"
}
},
"b": {
"type": "LINEARCOMBINATION",
"values": {
"main.out[0]": "1",
"one": "21888242871839275222246405745257275088696311157297823662689037894645226208582"
}
},
"c": {
"type": "LINEARCOMBINATION",
"values": {}
}
},
{
"type": "QEQ",
"a": {
"type": "LINEARCOMBINATION",
"values": {
"main.out[1]": "1"
}
},
"b": {
"type": "LINEARCOMBINATION",
"values": {
"main.out[1]": "1",
"one": "21888242871839275222246405745257275088696311157297823662689037894645226208582"
}
},
"c": {
"type": "LINEARCOMBINATION",
"values": {}
}
},
{
"type": "QEQ",
"a": {
"type": "LINEARCOMBINATION",
"values": {
"main.out[2]": "1"
}
},
"b": {
"type": "LINEARCOMBINATION",
"values": {
"main.out[2]": "1",
"one": "21888242871839275222246405745257275088696311157297823662689037894645226208582"
}
},
"c": {
"type": "LINEARCOMBINATION",
"values": {}
}
},
{
"type": "QEQ",
"a": {
"type": "LINEARCOMBINATION",
"values": {}
},
"b": {
"type": "LINEARCOMBINATION",
"values": {}
},
"c": {
"type": "LINEARCOMBINATION",
"values": {
"main.out[0]": "1",
"main.out[1]": "2",
"main.out[2]": "4",
"main.inp": "21888242871839275222246405745257275088696311157297823662689037894645226208582"
}
}
}
];
circuit.witnessNames=[
[
"one"
],
[
"main.inp"
],
[
"main.out[0]"
],
[
"main.out[1]"
],
[
"main.out[2]"
]
];
{
}
circuit.templates = [];
circuit.templates["toBin"] = function(ctx) {
ctx.setVar("lc1", [], "0");
for (ctx.setVar("i", [], "0");bigInt(ctx.getVar("i",[])).lt(ctx.getVar("n",[])) ? 1 : 0;(ctx.setVar("i", [], bigInt(ctx.getVar("i",[])).add("1").mod(__P__))).add(__P__).minus(1).mod(__P__))
{
ctx.setSignal("out", [ctx.getVar("i",[])], bigInt(bigInt(ctx.getVar("i",[])).greater(256) ? 0 : bigInt(ctx.getSignal("inp", [])).shiftRight(bigInt(ctx.getVar("i",[])).value).and(__MASK__)).and("1").and(__MASK__));
ctx.assert(bigInt(bigInt(ctx.getSignal("out", [ctx.getVar("i",[])])).times(bigInt(ctx.getSignal("out", [ctx.getVar("i",[])])).add(__P__).minus("1").mod(__P__)).mod(__P__)).equals("0"));
ctx.setVar("lc1", [], bigInt(ctx.getVar("lc1",[])).add(bigInt(ctx.getSignal("out", [ctx.getVar("i",[])])).times(bigInt("2").modPow(ctx.getVar("i",[]), __P__)).mod(__P__)).mod(__P__));
}
ctx.assert(bigInt(ctx.getVar("lc1",[])).equals(ctx.getSignal("inp", [])));
}
;

+ 0
- 1
tobin.w

@ -1 +0,0 @@
["1","3","1","1","0"]

Loading…
Cancel
Save