Compare commits

...

7 Commits

Author SHA1 Message Date
Jordi Baylina
e1286c29c7 0.5.28 2020-09-24 19:18:59 +02:00
Jordi Baylina
a002bcbc25 bls12-381 fix and fast r1cs generation 2020-09-24 19:18:49 +02:00
Jordi Baylina
f9f1d0c13e High Removed array 2020-09-19 18:36:35 +02:00
Jordi Baylina
fc01aad8b6 Reduce mem 2020-09-17 22:53:06 +02:00
Jordi Baylina
3d5aa14cdc 0.5.27 2020-09-17 17:45:44 +02:00
Jordi Baylina
5dc54bb7d2 Optimize recursive constant dependency 2020-09-17 17:42:32 +02:00
Jordi Baylina
349a39dc95 0.5.26 2020-09-17 10:38:01 +02:00
5 changed files with 61 additions and 46 deletions

73
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "circom",
"version": "0.5.25",
"version": "0.5.28",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -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"

View File

@@ -1,6 +1,6 @@
{
"name": "circom",
"version": "0.5.25",
"version": "0.5.28",
"description": "Language to generate logic circuits",
"main": "index.js",
"directories": {
@@ -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"
},

View File

@@ -340,23 +340,31 @@ async function reduceConstrains(ctx) {
possibleConstraints[i] = ctx.constraints.length - i -1;
}
let totalRemoved = 0;
while (possibleConstraints.length >0) {
if (possibleConstraints.length>1<<20) {
nextPossibleConstraints = new BigArray();
} else {
nextPossibleConstraints = {};
}
removedSignals = new BigArray();
removedSignals = {};
nRemoved = 0;
lIdx = new BigArray();
lIdx = {};
for (let i=0;i<possibleConstraints.length;i++) {
if ((ctx.verbose)&&(i%10000 == 0)) {
await Promise.resolve();
console.log(`reducing constraints: ${i}/${possibleConstraints.length} reduced: ${nRemoved}`);
}
const c = ctx.constraints[possibleConstraints[i]];
if (!c) continue;
// Limit of number of lelements removed per step
if (nRemoved>5000000) {
nextPossibleConstraints[possibleConstraints[i]] = true;
continue;
}
// Swap a and b if b has more variables.
if (Object.keys(c.b).length > Object.keys(c.a).length) {
const aux = c.a;
@@ -402,7 +410,7 @@ async function reduceConstrains(ctx) {
const cts = Object.keys(sig2constraint[isolatedSignal]);
for (let k=0; k<cts.length; k++) {
nextPossibleConstraints[cts[k]] = true;
if (ctx.constraints[cts[k]]) nextPossibleConstraints[cts[k]] = true;
}
}
}
@@ -434,7 +442,7 @@ async function reduceConstrains(ctx) {
}
}
const removedSignalsList = removedSignals.getKeys();
const removedSignalsList = Object.keys(removedSignals);
for (let i=0; i<removedSignalsList.length; i++) {
if ((ctx.verbose )&&(i%100000 == 0)) console.log(`removing signals: ${i}/${removedSignalsList.length}`);
@@ -445,6 +453,7 @@ async function reduceConstrains(ctx) {
lSignal = ctx.signals[lSignal.e];
}
sig2constraint[s] = null;
lSignal.c = ctx.stDISCARDED;
}
@@ -456,6 +465,9 @@ async function reduceConstrains(ctx) {
}
*/
possibleConstraints = nextPossibleConstraints;
totalRemoved += nRemoved;
if (ctx.verbose) console.log(`Removed: ${totalRemoved} TotalConstraints: ${ctx.constraints.length}` );
}

View File

@@ -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() );

View File

@@ -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);