diff --git a/package-lock.json b/package-lock.json index fe67cc7..b951894 100644 --- a/package-lock.json +++ b/package-lock.json @@ -143,6 +143,11 @@ "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.48.tgz", "integrity": "sha512-j51egjPa7/i+RdiRuJbPdJ2FIUYYPhvYLjzoYbcMMm62ooO6F94fETG4MTs46zPAF9Brs04OajboA/qTGuz78w==" }, + "blakejs": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.1.0.tgz", + "integrity": "sha1-ad+S75U6qIylGjLfarHFShVfx6U=" + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -571,9 +576,9 @@ "dev": true }, "fastfile": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/fastfile/-/fastfile-0.0.2.tgz", - "integrity": "sha512-rS9vpAM4DS+xacKSH0MVCqr/Y5SiIAiunJTYSuq1H9nfRpkP37ewgnjH3FztziKBUQB2xPYS/WxEEjHl+pA5Fg==" + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/fastfile/-/fastfile-0.0.7.tgz", + "integrity": "sha512-Zk7sdqsV6DsN/rhjULDfCCowPiMDsziTMFicdkrKN80yybr/6YFf9H91ELXN85dVEf6EYkVR5EHkZNc0dMqZKA==" }, "ffiasm": { "version": "0.0.2", @@ -586,11 +591,13 @@ } }, "ffjavascript": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.1.2.tgz", - "integrity": "sha512-zB1dhgBjJlvyk2VQIQzFSpUJmanYQYDR/Fo1KhZnaNW5chMFJT55qz0dx1LMKrAklBbidKzz2/C7dgibxQF94g==", + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.2.4.tgz", + "integrity": "sha512-XFeWcjUDFPavN+DDOxhE8p5MOhZQJc9oO1Sj4ml1pyjqNhS1ujEamcjFyK0cctdnat61i7lvpTYzdtS3RYDC8w==", "requires": { - "big-integer": "^1.6.48" + "big-integer": "^1.6.48", + "wasmcurves": "0.0.4", + "worker-threads": "^1.0.0" } }, "ffwasm": { @@ -1154,27 +1161,12 @@ "dev": true }, "r1csfile": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/r1csfile/-/r1csfile-0.0.5.tgz", - "integrity": "sha512-B+BdKPb/WUTp4N/3X4d1Spgx9Ojx5tFVejGZRJxpTtzq34mC8Vi/czWfiPj85V8kud31lCfYcZ16z7+czvM0Sw==", + "version": "0.0.14", + "resolved": "https://registry.npmjs.org/r1csfile/-/r1csfile-0.0.14.tgz", + "integrity": "sha512-7m4eWpnbjkwGGUaRmIAJc4w+HvaeBPJXUKHIqLkHeD9Yyjem6/EHmlgDVl+4hWNWGZqdhXuMqWSH9+O6QOXBdw==", "requires": { - "fastfile": "0.0.1", - "ffjavascript": "0.1.0" - }, - "dependencies": { - "fastfile": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/fastfile/-/fastfile-0.0.1.tgz", - "integrity": "sha512-Fk8PWafGWGEUw7oPq/dJen92ASxknCEy4ZC8n4VEvSwCp/jcReyEmVoWsRIWTf+IvAp2MzvFi54vOPeK2LQZtQ==" - }, - "ffjavascript": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.1.0.tgz", - "integrity": "sha512-dmKlUasSfvUcxBm8nCSKl2x7EFJsXA7OVP8XLFA03T2+6mAc3IiVLC2ambEVOcMOhyhl0vJfVZjM9f9d38D1rw==", - "requires": { - "big-integer": "^1.6.48" - } - } + "fastfile": "0.0.7", + "ffjavascript": "0.2.4" } }, "regexpp": { @@ -1472,6 +1464,15 @@ "big-integer": "^1.6.48" } }, + "wasmcurves": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/wasmcurves/-/wasmcurves-0.0.4.tgz", + "integrity": "sha512-c/Tob+F/7jJhep1b2qtj54r4nkGaRifNbQ1OJx8cBBFH1RlHbWIbISHWONClOxiVwy/JZOpbN4SgvSX/4lF80A==", + "requires": { + "big-integer": "^1.6.42", + "blakejs": "^1.1.0" + } + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -1492,6 +1493,11 @@ "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", "dev": true }, + "worker-threads": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/worker-threads/-/worker-threads-1.0.0.tgz", + "integrity": "sha512-vK6Hhvph8oLxocEJIlc3YfGAZhm210uGzjZsXSu+JYLAQ/s/w4Tqgl60JrdH58hW8NSGP4m3bp8a92qPXgX05w==" + }, "wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", diff --git a/package.json b/package.json index c4124ec..08ada53 100644 --- a/package.json +++ b/package.json @@ -31,12 +31,12 @@ "dependencies": { "chai": "^4.2.0", "circom_runtime": "0.0.6", - "fastfile": "0.0.2", + "fastfile": "0.0.7", "ffiasm": "0.0.2", - "ffjavascript": "0.1.2", + "ffjavascript": "0.2.4", "ffwasm": "0.0.7", "fnv-plus": "^1.3.1", - "r1csfile": "0.0.5", + "r1csfile": "0.0.14", "tmp-promise": "^2.0.2", "wasmbuilder": "0.0.10" }, diff --git a/src/bigarray.js b/src/bigarray.js index 15a43a3..dfd58c3 100644 --- a/src/bigarray.js +++ b/src/bigarray.js @@ -1,4 +1,4 @@ -const SUBARRAY_SIZE = 0x10000; +const SUBARRAY_SIZE = 0x40000; const BigArrayHandler = { get: function(obj, prop) { @@ -19,7 +19,7 @@ const BigArrayHandler = { class _BigArray { constructor (initSize) { this.length = initSize || 0; - this.arr = []; + this.arr = new Array(SUBARRAY_SIZE); for (let i=0; i0) { + nextPossibleConstraints = {}; + removedSignals = {}; + nRemoved = 0; + lIdx = {}; + for (let i=0;i Object.keys(c.a).length) { + const aux = c.a; + c.a=c.b; + c.b=aux; + } + + // Mov to C if possible. + if (isConstant(c.a)) { + const ct = {t: "N", v: c.a.coefs[sONE]}; + c.c = ctx.lc.add(ctx.lc.mul(c.b, ct), c.c); + c.a = { t: "LC", coefs: {} }; + c.b = { t: "LC", coefs: {} }; + } + if (isConstant(c.b)) { + const ct = {t: "N", v: c.b.coefs[sONE]}; + c.c = ctx.lc.add(ctx.lc.mul(c.a, ct), c.c); + c.a = { t: "LC", coefs: {} }; + c.b = { t: "LC", coefs: {} }; + } + + if (ctx.lc.isZero(c.a) || ctx.lc.isZero(c.b)) { + const freeC = substituteRemoved(c.c); + const isolatedSignal = getFirstInternalSignal(ctx, freeC); + if (isolatedSignal) { + // console.log(isolatedSignal); + // console.log(freeC); + removedSignals[isolatedSignal] = isolateSignal(freeC, isolatedSignal); + if (lIdx[isolatedSignal]) { + lIdx[isolatedSignal].forEach( (s) => { + removedSignals[s] = substitute(removedSignals[s], isolatedSignal, removedSignals[isolatedSignal]); + }); + } + + addTolIdx(removedSignals[isolatedSignal], isolatedSignal); + ctx.constraints[possibleConstraints[i]] = null; + nRemoved ++; + + sig2constraint[isolatedSignal].forEach( (s) => { + nextPossibleConstraints[s] = true; + }); + } + } + } + + nextPossibleConstraints = Object.keys(nextPossibleConstraints); + + for (let i=0; i=0) { + lSignal = ctx.signals[lSignal.e]; + } + + lSignal.c = ctx.stDISCARDED; + } + + possibleConstraints = nextPossibleConstraints; + + } + + let o=0; + for (let i=0; i