From a002bcbc25b2dba1e0447d333e111d96738a4919 Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Thu, 24 Sep 2020 19:18:49 +0200 Subject: [PATCH] bls12-381 fix and fast r1cs generation --- package-lock.json | 71 ++++++++++++++++++++------------------- package.json | 6 ++-- src/construction_phase.js | 3 ++ src/r1csfile.js | 3 +- 4 files changed, 43 insertions(+), 40 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9e1c762..bebbe89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,6 +30,11 @@ "js-tokens": "^4.0.0" } }, + "@iden3/bigarray": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/@iden3/bigarray/-/bigarray-0.0.2.tgz", + "integrity": "sha512-Xzdyxqm1bOFF6pdIsiHLLl3HkSLjbhqJHVyqaTxXt3RqXBEnmsUmEW47H7VOi/ak7TdkRpNkxjyK5Zbkm+y52g==" + }, "@types/color-name": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", @@ -209,6 +214,18 @@ "requires": { "ffjavascript": "0.2.10", "fnv-plus": "^1.3.1" + }, + "dependencies": { + "ffjavascript": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.2.10.tgz", + "integrity": "sha512-GQI6gHYYG5/iD4Kt3VzezzK7fARJzP0zkc82V/+JAdjfeKBXhDSo5rpKFuK3cDcrdW0Fu2emuYNMEAuFqhEQvQ==", + "requires": { + "big-integer": "^1.6.48", + "wasmcurves": "0.0.5", + "worker-threads": "^1.0.0" + } + } } }, "cjson": { @@ -566,9 +583,9 @@ "dev": true }, "fastfile": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/fastfile/-/fastfile-0.0.16.tgz", - "integrity": "sha512-2sX5M4JQWAVmS2GojuRPA759aTOs5PyUEpZHjaecNtWBU9CfRFlTf2aBqFG2PJJnrcrawBBAQ1s0QSO+qQ4Zmg==" + "version": "0.0.18", + "resolved": "https://registry.npmjs.org/fastfile/-/fastfile-0.0.18.tgz", + "integrity": "sha512-q03PTKc+wptis4WmuFOwPNQx2p5myFUrl/dMgRlW9mymc1Egyc14JPHgiGnWK+sJ0+dBl2Vwtfh5GfSQltYOpw==" }, "ffiasm": { "version": "0.1.1", @@ -581,19 +598,19 @@ } }, "ffjavascript": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.2.10.tgz", - "integrity": "sha512-GQI6gHYYG5/iD4Kt3VzezzK7fARJzP0zkc82V/+JAdjfeKBXhDSo5rpKFuK3cDcrdW0Fu2emuYNMEAuFqhEQvQ==", + "version": "0.2.22", + "resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.2.22.tgz", + "integrity": "sha512-EsVqap2Txm17bKW0z/jXCX3M7rQ++nQUAJY8alWDpyhjRj90xjl6GLeVSKZQ8rOFDQ/SFFXcEB8w9X8Boxid+w==", "requires": { "big-integer": "^1.6.48", - "wasmcurves": "0.0.5", + "wasmcurves": "0.0.12", "worker-threads": "^1.0.0" }, "dependencies": { "wasmcurves": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/wasmcurves/-/wasmcurves-0.0.5.tgz", - "integrity": "sha512-BmI4GXLjLawGg2YkvHa8zRsnWec+d1uwoxE+Iov8cqOpDL7GA5XO2pk2yuDbXHMzwIug2exnKot3baRZ86R0pA==", + "version": "0.0.12", + "resolved": "https://registry.npmjs.org/wasmcurves/-/wasmcurves-0.0.12.tgz", + "integrity": "sha512-1Jl9mkatyHSNj80ILjf85SZUNuZQBCkTjJlhzqHnZQXUmIimCIWkugaVaYNjozLs1Gun4h/keZe1MBeBN0sRpg==", "requires": { "big-integer": "^1.6.42", "blakejs": "^1.1.0" @@ -1162,29 +1179,13 @@ "dev": true }, "r1csfile": { - "version": "0.0.14", - "resolved": "https://registry.npmjs.org/r1csfile/-/r1csfile-0.0.14.tgz", - "integrity": "sha512-7m4eWpnbjkwGGUaRmIAJc4w+HvaeBPJXUKHIqLkHeD9Yyjem6/EHmlgDVl+4hWNWGZqdhXuMqWSH9+O6QOXBdw==", + "version": "0.0.16", + "resolved": "https://registry.npmjs.org/r1csfile/-/r1csfile-0.0.16.tgz", + "integrity": "sha512-A2jRVWzGgmXeG2lVAc0H4suJmzt50it5UvBnycJgBCpMXM3tH/M6RguP7nvs6suY/yYnkN6jX6iTScSiDUF3FA==", "requires": { - "fastfile": "0.0.7", - "ffjavascript": "0.2.4" - }, - "dependencies": { - "fastfile": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/fastfile/-/fastfile-0.0.7.tgz", - "integrity": "sha512-Zk7sdqsV6DsN/rhjULDfCCowPiMDsziTMFicdkrKN80yybr/6YFf9H91ELXN85dVEf6EYkVR5EHkZNc0dMqZKA==" - }, - "ffjavascript": { - "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", - "wasmcurves": "0.0.4", - "worker-threads": "^1.0.0" - } - } + "@iden3/bigarray": "0.0.2", + "fastfile": "0.0.18", + "ffjavascript": "0.2.22" } }, "regexpp": { @@ -1483,9 +1484,9 @@ } }, "wasmcurves": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/wasmcurves/-/wasmcurves-0.0.4.tgz", - "integrity": "sha512-c/Tob+F/7jJhep1b2qtj54r4nkGaRifNbQ1OJx8cBBFH1RlHbWIbISHWONClOxiVwy/JZOpbN4SgvSX/4lF80A==", + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/wasmcurves/-/wasmcurves-0.0.5.tgz", + "integrity": "sha512-BmI4GXLjLawGg2YkvHa8zRsnWec+d1uwoxE+Iov8cqOpDL7GA5XO2pk2yuDbXHMzwIug2exnKot3baRZ86R0pA==", "requires": { "big-integer": "^1.6.42", "blakejs": "^1.1.0" diff --git a/package.json b/package.json index 53a9167..cc48f60 100644 --- a/package.json +++ b/package.json @@ -31,12 +31,12 @@ "dependencies": { "chai": "^4.2.0", "circom_runtime": "0.1.5", - "fastfile": "0.0.16", + "fastfile": "0.0.18", "ffiasm": "0.1.1", - "ffjavascript": "0.2.10", + "ffjavascript": "0.2.22", "ffwasm": "0.0.7", "fnv-plus": "^1.3.1", - "r1csfile": "0.0.14", + "r1csfile": "0.0.16", "tmp-promise": "^2.0.2", "wasmbuilder": "0.0.10" }, diff --git a/src/construction_phase.js b/src/construction_phase.js index 7936499..492a7c2 100644 --- a/src/construction_phase.js +++ b/src/construction_phase.js @@ -701,6 +701,9 @@ function execPin(ctx, ast) { if (sel.v[0].t != "N") return NQVAL; selsP.push(Scalar.toNumber(sel.v[0].v)); } + if (!ctx.components[cIdx]) { + return ctx.throwError(ast, "Component not defined yet"); + } const sIdx = ctx.components[cIdx].names.getSignalIdx(ast.pin.name, selsP); if (sIdx<0) return ctx.throwError(ast, "Signal not defined:" + buildFullName() ); diff --git a/src/r1csfile.js b/src/r1csfile.js index c3ca005..e5eeb94 100644 --- a/src/r1csfile.js +++ b/src/r1csfile.js @@ -8,8 +8,7 @@ module.exports.buildR1cs = buildR1cs; async function buildR1cs(ctx, fileName) { - const fd = await fastFile.createOverride(fileName); - + const fd = await fastFile.createOverride(fileName, 1<<22, 1<<24); const buffBigInt = new Uint8Array(ctx.F.n8);