Compare commits

...

4 Commits

Author SHA1 Message Date
Jordi Baylina
a1ae6e4a44 0.5.6 2020-04-07 12:54:30 +02:00
Jordi Baylina
c7c6b799ad FIX: Error in wasm generation of big circuits 2020-04-07 12:53:58 +02:00
Jordi Baylina
96776d2374 0.5.5 2020-03-31 15:36:55 +02:00
Jordi Baylina
ca7379995e Error reporting fixes 2020-03-31 15:36:26 +02:00
4 changed files with 27 additions and 25 deletions

8
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "circom", "name": "circom",
"version": "0.5.4", "version": "0.5.6",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@@ -592,9 +592,9 @@
} }
}, },
"ffjavascript": { "ffjavascript": {
"version": "0.0.4", "version": "0.0.5",
"resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.0.4.tgz", "resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.0.5.tgz",
"integrity": "sha512-6eiRvy+YuGCRjH4U8KdJbRel5VBW0zeuUL1FXQ+fFxTp5xv2ClqTfCYf5ClUtq0voGpd9XJAdUCvgIxHDbAQ0Q==", "integrity": "sha512-7je6PydOWLDUj3vU8JeCUgeezg4yrG/6qjlukQNuPHeeavnM4REcrN9LA2+xtqIMIPdx/wdUkPMQpixsz+CdIw==",
"requires": { "requires": {
"big-integer": "^1.6.48" "big-integer": "^1.6.48"
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "circom", "name": "circom",
"version": "0.5.4", "version": "0.5.6",
"description": "Language to generate logic circuits", "description": "Language to generate logic circuits",
"main": "index.js", "main": "index.js",
"directories": { "directories": {
@@ -33,7 +33,7 @@
"chai": "^4.2.0", "chai": "^4.2.0",
"circom_runtime": "0.0.3", "circom_runtime": "0.0.3",
"ffiasm": "0.0.2", "ffiasm": "0.0.2",
"ffjavascript": "0.0.4", "ffjavascript": "0.0.5",
"ffwasm": "0.0.6", "ffwasm": "0.0.6",
"fnv-plus": "^1.3.1", "fnv-plus": "^1.3.1",
"r1csfile": "0.0.3", "r1csfile": "0.0.3",

View File

@@ -923,41 +923,41 @@ class BuilderWasm {
} }
_buildComponents(module) { _buildComponents(module) {
const bytes = []; const bytes = new Array(this.components.length*5*4);
bytes.length=0;
for (let i=0; i<this.components.length; i++) { for (let i=0; i<this.components.length; i++) {
const c = this.components[i]; const c = this.components[i];
bytes.push(intToBytes32(this.hashMaps[c.hashMapName].pointer)); bytes.push(...intToBytes32(this.hashMaps[c.hashMapName].pointer));
bytes.push(intToBytes32(this.componentEntriesTables[c.entryTableName].pointer)); bytes.push(...intToBytes32(this.componentEntriesTables[c.entryTableName].pointer));
bytes.push(intToBytes32(i)); bytes.push(...intToBytes32(i));
bytes.push(intToBytes32(c.nInSignals)); bytes.push(...intToBytes32(c.nInSignals));
bytes.push(intToBytes32(c.newThread ? 1 : 0)); bytes.push(...intToBytes32(c.newThread ? 1 : 0));
module.addFunctionToTable(c.functionName); module.addFunctionToTable(c.functionName);
} }
const fBytes = [].concat(...bytes); this.pComponents = module.alloc(bytes);
this.pComponents = module.alloc(fBytes);
} }
_buildMapIsInput(module) { _buildMapIsInput(module) {
const bytes = []; const bytes = new Array(this.mapIsInput.length*4);
bytes.length=0;
for (let i=0; i<this.mapIsInput.length; i++) { for (let i=0; i<this.mapIsInput.length; i++) {
bytes.push(intToBytes32(this.mapIsInput[i])); bytes.push(...intToBytes32(this.mapIsInput[i]));
} }
const fBytes = [].concat(...bytes); this.pMapIsInput = module.alloc(bytes);
this.pMapIsInput = module.alloc(fBytes);
} }
_buildWit2Sig(module) { _buildWit2Sig(module) {
const bytes = []; const bytes = new Array(this.wit2sig.length*4);
bytes.length =0;
for (let i=0; i<this.wit2sig.length; i++) { for (let i=0; i<this.wit2sig.length; i++) {
bytes.push(intToBytes32(this.wit2sig[i])); bytes.push(...intToBytes32(this.wit2sig[i]));
} }
const fBytes = [].concat(...bytes); this.pWit2sig = module.alloc(bytes);
this.pWit2sig = module.alloc(fBytes);
} }
_buildCircuitVar(module) { _buildCircuitVar(module) {

View File

@@ -359,7 +359,7 @@ function execAssignement(ctx, ast) {
} }
if (!left.s) return ctx.throwError(ast, "variable. not defined yet"); if ((!left)||(!left.s)) return ctx.throwError(ast, "variable. not defined yet");
if (left.t == "C") return execInstantiateComponet(ctx, left, ast.values[1], leftSels); if (left.t == "C") return execInstantiateComponet(ctx, left, ast.values[1], leftSels);
if ((left.t == "S")&&( ["<--", "<==", "-->", "==>"].indexOf(ast.op) < 0)) return ctx.throwError(ast, "Cannot assign to a signal with `=` use <-- or <== ops"); if ((left.t == "S")&&( ["<--", "<==", "-->", "==>"].indexOf(ast.op) < 0)) return ctx.throwError(ast, "Cannot assign to a signal with `=` use <-- or <== ops");
@@ -444,14 +444,14 @@ function execInstantiateComponet(ctx, vr, fn, sels) {
const templateName = fn.name; const templateName = fn.name;
const template = ctx.templates[templateName]; const template = ctx.templates[templateName];
if (!template) return ctx.throwError("Invalid Template"); if (!template) return ctx.throwError(fn, "Invalid Template");
const paramValues = []; const paramValues = [];
for (let i=0; i< fn.params.length; i++) { for (let i=0; i< fn.params.length; i++) {
const v = exec(ctx, fn.params[i]); const v = exec(ctx, fn.params[i]);
if (ctx.error) return; if (ctx.error) return;
for (let j=0; j<v.s[0]; j++) { for (let j=0; j<v.s[0]; j++) {
if (v.v[j].t != "N") ctx.throwError("Parameters of a template must be constant"); if (v.v[j].t != "N") ctx.throwError(fn, "Parameters of a template must be constant");
} }
paramValues.push(v); paramValues.push(v);
} }
@@ -873,6 +873,8 @@ function execOpOp(ctx, ast, op, lr) {
right = {t:"N", v: ctx.field.one}; right = {t:"N", v: ctx.field.one};
} }
if (!right) return ctx.throwError(ast, "adding a no number");
const resAfter = ctx.lc[op](resBefore, right); const resAfter = ctx.lc[op](resBefore, right);
left.v[o] = resAfter; left.v[o] = resAfter;