From 99a7489fa2e57d00df86baba0bdc6497fe20554e Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Sun, 21 Oct 2018 19:44:19 +0200 Subject: [PATCH] Some fixes and new version --- circuits/gates.circom | 18 ++ circuits/multiplexer.circom | 19 ++ circuits/sha256/binsum.circom | 19 ++ circuits/sha256/bitify.circom | 17 ++ circuits/sha256/ch.circom | 19 ++ circuits/sha256/constants.circom | 17 ++ circuits/sha256/gates.circom | 18 ++ circuits/sha256/main.circom | 19 ++ circuits/sha256/maj.circom | 19 ++ circuits/sha256/rotate.circom | 17 ++ circuits/sha256/sha256_2.circom | 18 ++ circuits/sha256/sha256compression.circom | 18 ++ circuits/sha256/shift.circom | 18 ++ circuits/sha256/sigma.circom | 19 ++ circuits/sha256/sigmaplus.circom | 19 ++ circuits/sha256/t1.circom | 19 ++ circuits/sha256/t2.circom | 19 ++ circuits/sha256/xor3.circom | 19 ++ circuits/tobin.circom | 17 ++ cli.js | 8 +- package-lock.json | 358 +++++++++++------------ package.json | 4 +- parser/jaz.jison | 19 ++ src/compiler.js | 18 +- src/exec.js | 43 ++- src/gencode.js | 19 +- src/lcalgebra.js | 72 +++-- test/sha256.js | 18 +- 28 files changed, 660 insertions(+), 247 deletions(-) diff --git a/circuits/gates.circom b/circuits/gates.circom index 0eccda0..a1fe69a 100644 --- a/circuits/gates.circom +++ b/circuits/gates.circom @@ -1,3 +1,21 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ template XOR() { signal input a; diff --git a/circuits/multiplexer.circom b/circuits/multiplexer.circom index 8925709..fc66406 100644 --- a/circuits/multiplexer.circom +++ b/circuits/multiplexer.circom @@ -1,3 +1,22 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ + // --> Assignation without constraint // <-- Assignation without constraint // === Constraint diff --git a/circuits/sha256/binsum.circom b/circuits/sha256/binsum.circom index b72fea7..3783e26 100644 --- a/circuits/sha256/binsum.circom +++ b/circuits/sha256/binsum.circom @@ -1,3 +1,22 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ + /* Binary Sum diff --git a/circuits/sha256/bitify.circom b/circuits/sha256/bitify.circom index 539131c..b22b59d 100644 --- a/circuits/sha256/bitify.circom +++ b/circuits/sha256/bitify.circom @@ -1,4 +1,21 @@ +/* + Copyright 2018 0KIMS association. + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ template Num2Bits(n) { signal input in; diff --git a/circuits/sha256/ch.circom b/circuits/sha256/ch.circom index d4e5a23..5804ae8 100644 --- a/circuits/sha256/ch.circom +++ b/circuits/sha256/ch.circom @@ -1,3 +1,22 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ + /* Ch 000 0 diff --git a/circuits/sha256/constants.circom b/circuits/sha256/constants.circom index 04cba45..bf69598 100644 --- a/circuits/sha256/constants.circom +++ b/circuits/sha256/constants.circom @@ -1,4 +1,21 @@ +/* + Copyright 2018 0KIMS association. + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ template H(x) { signal output out[32]; diff --git a/circuits/sha256/gates.circom b/circuits/sha256/gates.circom index 0eccda0..a1fe69a 100644 --- a/circuits/sha256/gates.circom +++ b/circuits/sha256/gates.circom @@ -1,3 +1,21 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ template XOR() { signal input a; diff --git a/circuits/sha256/main.circom b/circuits/sha256/main.circom index 6404333..fbf2434 100644 --- a/circuits/sha256/main.circom +++ b/circuits/sha256/main.circom @@ -1,3 +1,22 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ + include "sha256_2.jaz"; template Main() { diff --git a/circuits/sha256/maj.circom b/circuits/sha256/maj.circom index 85d3f90..ee53687 100644 --- a/circuits/sha256/maj.circom +++ b/circuits/sha256/maj.circom @@ -1,3 +1,22 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ + /* Maj function for sha256 out = a&b ^ a&c ^ b&c => diff --git a/circuits/sha256/rotate.circom b/circuits/sha256/rotate.circom index 567d4e9..b05df40 100644 --- a/circuits/sha256/rotate.circom +++ b/circuits/sha256/rotate.circom @@ -1,4 +1,21 @@ +/* + Copyright 2018 0KIMS association. + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ template RotR(n, r) { signal input in[n]; diff --git a/circuits/sha256/sha256_2.circom b/circuits/sha256/sha256_2.circom index c26df2b..c061855 100644 --- a/circuits/sha256/sha256_2.circom +++ b/circuits/sha256/sha256_2.circom @@ -1,3 +1,21 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ include "sha256compression.circom"; include "bitify.circom" diff --git a/circuits/sha256/sha256compression.circom b/circuits/sha256/sha256compression.circom index 855fc1d..33baf1c 100644 --- a/circuits/sha256/sha256compression.circom +++ b/circuits/sha256/sha256compression.circom @@ -1,3 +1,21 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ include "constants.circom"; include "t1.circom"; diff --git a/circuits/sha256/shift.circom b/circuits/sha256/shift.circom index 411654a..bdff3fd 100644 --- a/circuits/sha256/shift.circom +++ b/circuits/sha256/shift.circom @@ -1,3 +1,21 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ template ShR(n, r) { signal input in[n]; diff --git a/circuits/sha256/sigma.circom b/circuits/sha256/sigma.circom index fcfeb4b..3baa646 100644 --- a/circuits/sha256/sigma.circom +++ b/circuits/sha256/sigma.circom @@ -1,3 +1,22 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ + include "xor3.circom"; include "rotate.circom"; include "shift.circom"; diff --git a/circuits/sha256/sigmaplus.circom b/circuits/sha256/sigmaplus.circom index 749e220..9b994f0 100644 --- a/circuits/sha256/sigmaplus.circom +++ b/circuits/sha256/sigmaplus.circom @@ -1,3 +1,22 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ + include "binsum.circom" include "sigma.circom" diff --git a/circuits/sha256/t1.circom b/circuits/sha256/t1.circom index 094edc1..70d881d 100644 --- a/circuits/sha256/t1.circom +++ b/circuits/sha256/t1.circom @@ -1,3 +1,22 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ + include "binsum.circom"; include "sigma.circom"; include "ch.circom"; diff --git a/circuits/sha256/t2.circom b/circuits/sha256/t2.circom index 02bff7b..fb4429b 100644 --- a/circuits/sha256/t2.circom +++ b/circuits/sha256/t2.circom @@ -1,3 +1,22 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ + include "binsum.circom"; include "sigma.circom"; include "maj.circom" diff --git a/circuits/sha256/xor3.circom b/circuits/sha256/xor3.circom index 2c56b28..9bbe76c 100644 --- a/circuits/sha256/xor3.circom +++ b/circuits/sha256/xor3.circom @@ -1,3 +1,22 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ + /* Xor3 function for sha256 out = a ^ b ^ c => diff --git a/circuits/tobin.circom b/circuits/tobin.circom index 72701cd..51724f8 100644 --- a/circuits/tobin.circom +++ b/circuits/tobin.circom @@ -1,4 +1,21 @@ +/* + Copyright 2018 0KIMS association. + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ template toBin(n) { diff --git a/cli.js b/cli.js index 60f754e..99131c7 100755 --- a/cli.js +++ b/cli.js @@ -3,20 +3,20 @@ /* Copyright 2018 0KIMS association. - This file is part of jaz (Zero Knowledge Circuit Compiler). + This file is part of circom (Zero Knowledge Circuit Compiler). - jaz is a free software: you can redistribute it and/or modify it + circom is a 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 + circom 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 . + along with circom. If not, see . */ /* eslint-disable no-console */ diff --git a/package-lock.json b/package-lock.json index 9432608..f01ec40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "circom", - "version": "0.0.7", + "version": "0.0.8", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1468,6 +1468,184 @@ "is-fullwidth-code-point": "^2.0.0" } }, + "snarkjs": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/snarkjs/-/snarkjs-0.1.0.tgz", + "integrity": "sha512-i+OOKwATef3/oUleae9FHt/qACPYH1M5gjQkdYYkyRYqScIuZHCmNSf6Q5RWJT5hmOkTEor+T2C5qwKSrzzGSg==", + "dev": true, + "requires": { + "big-integer": "^1.6.35", + "chai": "^4.1.2", + "eslint": "^5.3.0" + }, + "dependencies": { + "ajv": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.4.tgz", + "integrity": "sha512-4Wyjt8+t6YszqaXnLDfMmG/8AlO5Zbcsy3ATHncCzjW/NoPzAId8AK6749Ybjmdt+kUY1gP60fCu46oDxPv/mg==", + "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.36", + "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.36.tgz", + "integrity": "sha512-t70bfa7HYEA1D9idDbmuv7YbsbVkQ+Hp+8KFSul4aE5e/i1bjCNIRYJZlA8Q8p0r9T8cF/RVvwUgRA//FydEyg==", + "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 + }, + "debug": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.0.tgz", + "integrity": "sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "eslint": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.7.0.tgz", + "integrity": "sha512-zYCeFQahsxffGl87U2aJ7DPyH8CbWgxBC213Y8+TCanhUTf2gEvfq3EKpHmEcozTLyPmGe9LZdMAwC/CpJBM5A==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.5.3", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "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.1", + "require-uncached": "^1.0.3", + "semver": "^5.5.1", + "strip-ansi": "^4.0.0", + "strip-json-comments": "^2.0.1", + "table": "^5.0.2", + "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" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "dev": true + }, + "rxjs": { + "version": "6.3.3", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz", + "integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "dev": true + }, + "table": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/table/-/table-5.1.0.tgz", + "integrity": "sha512-e542in22ZLhD/fOIuXs/8yDZ9W61ltF8daM88rkRNtgTIct+vI2fTnAyu/Db2TCfEcI8i7mjZz6meLq0nW7TYg==", + "dev": true, + "requires": { + "ajv": "^6.5.3", + "lodash": "^4.17.10", + "slice-ansi": "1.0.0", + "string-width": "^2.1.1" + } + } + } + }, "source-map": { "version": "0.1.43", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", @@ -1721,184 +1899,6 @@ "requires": { "camelcase": "^4.1.0" } - }, - "zksnark": { - "version": "0.0.11", - "resolved": "https://registry.npmjs.org/zksnark/-/zksnark-0.0.11.tgz", - "integrity": "sha512-YIOk93pLvc8NDVvedB0SDM1kGjPTdTYC/sgAvc9Dm6qMSYnS7tzCr844QaUlMApFTldz7D/6xlF1l24ttTGLXw==", - "dev": true, - "requires": { - "big-integer": "^1.6.35", - "chai": "^4.1.2", - "eslint": "^5.3.0" - }, - "dependencies": { - "ajv": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.4.tgz", - "integrity": "sha512-4Wyjt8+t6YszqaXnLDfMmG/8AlO5Zbcsy3ATHncCzjW/NoPzAId8AK6749Ybjmdt+kUY1gP60fCu46oDxPv/mg==", - "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.36", - "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.36.tgz", - "integrity": "sha512-t70bfa7HYEA1D9idDbmuv7YbsbVkQ+Hp+8KFSul4aE5e/i1bjCNIRYJZlA8Q8p0r9T8cF/RVvwUgRA//FydEyg==", - "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 - }, - "debug": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.0.tgz", - "integrity": "sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "eslint": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.7.0.tgz", - "integrity": "sha512-zYCeFQahsxffGl87U2aJ7DPyH8CbWgxBC213Y8+TCanhUTf2gEvfq3EKpHmEcozTLyPmGe9LZdMAwC/CpJBM5A==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "ajv": "^6.5.3", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", - "debug": "^4.0.1", - "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.1", - "require-uncached": "^1.0.3", - "semver": "^5.5.1", - "strip-ansi": "^4.0.0", - "strip-json-comments": "^2.0.1", - "table": "^5.0.2", - "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" - } - }, - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", - "dev": true - }, - "regexpp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", - "dev": true - }, - "rxjs": { - "version": "6.3.3", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz", - "integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==", - "dev": true, - "requires": { - "tslib": "^1.9.0" - } - }, - "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", - "dev": true - }, - "table": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/table/-/table-5.1.0.tgz", - "integrity": "sha512-e542in22ZLhD/fOIuXs/8yDZ9W61ltF8daM88rkRNtgTIct+vI2fTnAyu/Db2TCfEcI8i7mjZz6meLq0nW7TYg==", - "dev": true, - "requires": { - "ajv": "^6.5.3", - "lodash": "^4.17.10", - "slice-ansi": "1.0.0", - "string-width": "^2.1.1" - } - } - } } } } diff --git a/package.json b/package.json index 0556998..dcdab22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "circom", - "version": "0.0.7", + "version": "0.0.9", "description": "Language to generate logic circuits", "main": "index.js", "directories": { @@ -38,6 +38,6 @@ "eslint": "^5.0.1", "eslint-plugin-mocha": "^5.0.0", "jison": "^0.4.18", - "zksnark": "0.0.11" + "snarkjs": "0.1.0" } } diff --git a/parser/jaz.jison b/parser/jaz.jison index 6b26e40..40ee3a4 100644 --- a/parser/jaz.jison +++ b/parser/jaz.jison @@ -1,3 +1,22 @@ +/* + Copyright 2018 0KIMS association. + + This file is part of circom (Zero Knowledge Circuit Compiler). + + circom is a 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. + + circom 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 circom. If not, see . +*/ + /* description: Construct AST for jaz language. */ /* lexical grammar */ diff --git a/src/compiler.js b/src/compiler.js index 33554c1..9b12507 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -1,20 +1,20 @@ /* Copyright 2018 0KIMS association. - This file is part of jaz (Zero Knowledge Circuit Compiler). + This file is part of circom (Zero Knowledge Circuit Compiler). - jaz is a free software: you can redistribute it and/or modify it + circom is a 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 + circom 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 . + along with circom. If not, see . */ const fs = require("fs"); @@ -254,11 +254,11 @@ function reduceConstrains(ctx) { } } - for (let j=0; j. + along with circom. If not, see . */ const path = require("path"); @@ -78,6 +78,8 @@ function exec(ctx, ast) { return execPlusPlusRight(ctx, ast); } else if (ast.op == "PLUSPLUSLEFT") { return execPlusPlusLeft(ctx, ast); + } else if (ast.op == "/") { + return execDiv(ctx, ast); } else if (ast.op == "**") { return execExp(ctx, ast); } else if (ast.op == "&") { @@ -176,7 +178,7 @@ function setScope(ctx, name, selectors, value) { function setScopeArray(a, sels) { if (sels.length == 1) { - a[sels[0]] = value; + a[sels[0].value] = value; } else { setScopeArray(a[sels[0]], sels.slice(1)); } @@ -386,8 +388,7 @@ function execFunctionCall(ctx, ast) { const v = exec(ctx, ast.params[i]); if (ctx.error) return; - if (v.type != "NUMBER") return error(ctx, ast.params[i], "expected a number"); - paramValues.push( v.value); + paramValues.push(v); } if (ast.params.length != paramValues.length) error(ctx, ast, "Invalid Number of parameters"); @@ -401,10 +402,7 @@ function execFunctionCall(ctx, ast) { const scope = {}; for (let i=0; i< fnc.params.length; i++) { - scope[fnc.params[i]] = { - type: "NUMBER", - value: paramValues[i] - }; + scope[fnc.params[i]] = paramValues[i]; } ctx.fileName = fnc.fileName; @@ -507,6 +505,14 @@ function execVariable(ctx, ast) { if (ctx.error) return; if (!v) return error(ctx, ast, "Variable not defined"); + + // If the signal has an assigned value (constant) just return the constant + if ((v.type == "SIGNAL") && (ctx.signals[v.fullName].value)) { + return { + type: "NUMBER", + value: ctx.signals[v.fullName].value + }; + } let res; res=v; return res; @@ -746,6 +752,21 @@ function execExp(ctx, ast) { }; } +function execDiv(ctx, ast) { + const a = exec(ctx, ast.values[0]); + if (ctx.error) return; + if (a.type != "NUMBER") return { type: "NUMBER" }; + const b = exec(ctx, ast.values[1]); + if (ctx.error) return; + if (b.type != "NUMBER") return { type: "NUMBER" }; + if (!a.value || !b.value) return { type: "NUMBER" }; + if (b.value.isZero()) return error(ctx, ast, "Division by zero"); + return { + type: "NUMBER", + value: a.value.times(b.value.modInv(__P__)).mod(__P__) + }; +} + function execAdd(ctx, ast) { const a = exec(ctx, ast.values[0]); if (ctx.error) return; diff --git a/src/gencode.js b/src/gencode.js index 4086011..3fbe8e0 100644 --- a/src/gencode.js +++ b/src/gencode.js @@ -1,20 +1,20 @@ /* Copyright 2018 0KIMS association. - This file is part of jaz (Zero Knowledge Circuit Compiler). + This file is part of circom (Zero Knowledge Circuit Compiler). - jaz is a free software: you can redistribute it and/or modify it + circom is a 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 + circom 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 . + along with circom. If not, see . */ const bigInt = require("big-integer"); @@ -65,6 +65,8 @@ function gen(ctx, ast) { return genPlusPlusLeft(ctx, ast); } else if (ast.op == "**") { return genExp(ctx, ast); + } else if (ast.op == "/") { + return genDiv(ctx, ast); } else if (ast.op == "&") { return genBAnd(ctx, ast); } else if (ast.op == "<<") { @@ -438,6 +440,15 @@ function genSub(ctx, ast) { return `bigInt(${a}).add(__P__).sub(bigInt(${b})).mod(__P__)`; } +function genDiv(ctx, ast) { + const a = gen(ctx, ast.values[0]); + if (ctx.error) return; + const b = gen(ctx, ast.values[1]); + if (ctx.error) return; + + return `bigInt(${a}).mul( bigInt(${b}).inverse(__P__) ).mod(__P__)`; +} + function genExp(ctx, ast) { const a = gen(ctx, ast.values[0]); if (ctx.error) return; diff --git a/src/lcalgebra.js b/src/lcalgebra.js index f2cb98f..0aa52b4 100644 --- a/src/lcalgebra.js +++ b/src/lcalgebra.js @@ -1,20 +1,20 @@ /* Copyright 2018 0KIMS association. - This file is part of jaz (Zero Knowledge Circuit Compiler). + This file is part of circom (Zero Knowledge Circuit Compiler). - jaz is a free software: you can redistribute it and/or modify it + circom is a 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 + circom 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 . + along with circom. If not, see . */ /* @@ -434,59 +434,73 @@ function toString(a, ctx) { function canonize(ctx, a) { if (a.type == "LINEARCOMBINATION") { + const res = clone(a); for (let k in a.values) { let s = k; while (ctx.signals[s].equivalence) s= ctx.signals[s].equivalence; if ((typeof(ctx.signals[s].value) != "undefined")&&(k != "one")) { - const v = a.values[k].times(ctx.signals[s].value).mod(__P__); - if (!a.values["one"]) { - a.values["one"]=v; + const v = res.values[k].times(ctx.signals[s].value).mod(__P__); + if (!res.values["one"]) { + res.values["one"]=v; } else { - a.values["one"]= a.values["one"].add(v).mod(__P__); + res.values["one"]= res.values["one"].add(v).mod(__P__); } - delete a.values[k]; + delete res.values[k]; } else if (s != k) { - if (!a.values[s]) { - a.values[s]=bigInt(a.values[k]); + if (!res.values[s]) { + res.values[s]=bigInt(res.values[k]); } else { - a.values[s]= a.values[s].add(a.values[k]).mod(__P__); + res.values[s]= res.values[s].add(res.values[k]).mod(__P__); } - delete a.values[k]; + delete res.values[k]; } } - for (let k in a.values) { - if (a.values[k].isZero()) delete a.values[k]; + for (let k in res.values) { + if (res.values[k].isZero()) delete res.values[k]; } - return a; + return res; } else if (a.type == "QEQ") { - a.a = canonize(ctx, a.a); - a.b = canonize(ctx, a.b); - a.c = canonize(ctx, a.c); + const res = { + type: "QEQ", + a: canonize(ctx, a.a), + b: canonize(ctx, a.b), + c: canonize(ctx, a.c) + }; + return res; + } else { + return a; } - return a; } function substitute(where, signal, equivalence) { if (equivalence.type != "LINEARCOMBINATION") throw new Error("Equivalence must be a Linear Combination"); if (where.type == "LINEARCOMBINATION") { if (!where.values[signal] || where.values[signal].isZero()) return where; - const coef = where.values[signal]; + const res=clone(where); + const coef = res.values[signal]; for (let k in equivalence.values) { if (k != signal) { const v = coef.times(equivalence.values[k]).mod(__P__); - if (!where.values[k]) { - where.values[k]=v; + if (!res.values[k]) { + res.values[k]=v; } else { - where.values[k]= where.values[k].add(v).mod(__P__); + res.values[k]= res.values[k].add(v).mod(__P__); } - if (where.values[k].isZero()) delete where.values[k]; + if (res.values[k].isZero()) delete res.values[k]; } } - delete where.values[signal]; + delete res.values[signal]; + return res; } else if (where.type == "QEQ") { - substitute(where.a, signal, equivalence); - substitute(where.b, signal, equivalence); - substitute(where.c, signal, equivalence); + const res = { + type: "QEQ", + a: substitute(where.a, signal, equivalence), + b: substitute(where.b, signal, equivalence), + c: substitute(where.c, signal, equivalence) + }; + return res; + } else { + return where; } } diff --git a/test/sha256.js b/test/sha256.js index 7d82d64..478a792 100644 --- a/test/sha256.js +++ b/test/sha256.js @@ -1,6 +1,6 @@ const chai = require("chai"); const path = require("path"); -const zkSnark = require("zksnark"); +const snarkjs = require("snarkjs"); const crypto = require("crypto"); const compiler = require("../index.js"); @@ -34,28 +34,28 @@ describe("SHA256 test", () => { const cirDef = await compiler(path.join(__dirname, "circuits", "constants_test.circom")); assert.equal(cirDef.nVars, 2); - const circuit = new zkSnark.Circuit(cirDef); + const circuit = new snarkjs.Circuit(cirDef); const witness = circuit.calculateWitness({ "in": "0xd807aa98" }); - assert(witness[0].equals(zkSnark.bigInt(1))); - assert(witness[1].equals(zkSnark.bigInt("0xd807aa98"))); + assert(witness[0].equals(snarkjs.bigInt(1))); + assert(witness[1].equals(snarkjs.bigInt("0xd807aa98"))); }); it("Should create a sum circuit", async () => { const cirDef = await compiler(path.join(__dirname, "circuits", "sum_test.circom")); assert.equal(cirDef.nVars, 101); - const circuit = new zkSnark.Circuit(cirDef); + const circuit = new snarkjs.Circuit(cirDef); const witness = circuit.calculateWitness({ "a": "111", "b": "222" }); - assert(witness[0].equals(zkSnark.bigInt(1))); - assert(witness[1].equals(zkSnark.bigInt("333"))); + assert(witness[0].equals(snarkjs.bigInt(1))); + assert(witness[1].equals(snarkjs.bigInt("333"))); }); it("Should calculate a hash", async () => { const cirDef = await compiler(path.join(__dirname, "circuits", "sha256_2_test.circom")); - const circuit = new zkSnark.Circuit(cirDef); + const circuit = new snarkjs.Circuit(cirDef); console.log("Vars: "+circuit.nVars); console.log("Constraints: "+circuit.nConstraints); @@ -75,7 +75,7 @@ describe("SHA256 test", () => { assert.equal(hash, hash2); - assert(witness[1].equals(zkSnark.bigInt(r))); + assert(witness[1].equals(snarkjs.bigInt(r))); }).timeout(1000000);