arnaucube
arnaucube/circomPublic Self-hosted repository
FIX discard unused signals
Jordi Baylina jordi@baylina.cat
Sat, 21 Nov 2020 23:01:57 +0100
commit

6c48e9ba01e4b97ea560317568e694c29afacf0d

parent

42162b10c118792652805839fee74998e1893ea3

2 files changed, 22 insertions(+), 11 deletions(-)

jump to
M src/compiler.js → src/compiler.js

@@ -81,10 +81,6 @@ if (ctx.getComponentIdx(ctx.mainComponent)<0) {

throw new Error("A main component must be defined"); } - if (ctx.verbose) console.log("Classify Signals"); - measures.classifySignals = -performance.now(); - classifySignals(ctx); - measures.classifySignals += performance.now(); if (ctx.verbose) console.log("Reduce Constants"); measures.reduceConstants = -performance.now();

@@ -108,8 +104,12 @@ await reduceConstrains(ctx);

measures.reduceConstraints += performance.now(); } + if (ctx.verbose) console.log("NConstraints After: "+ctx.constraints.length); - if (ctx.verbose) console.log("NConstraints After: "+ctx.constraints.length); + if (ctx.verbose) console.log("Classify Signals"); + measures.classifySignals = -performance.now(); + classifySignals(ctx); + measures.classifySignals += performance.now(); measures.generateWitnessNames = -performance.now(); generateWitnessNames(ctx);

@@ -462,7 +462,6 @@ lSignal = ctx.signals[lSignal.e];

} sig2constraint[s] = null; - lSignal.c = ctx.stDISCARDED; } /*

@@ -496,7 +495,12 @@ function getFirstInternalSignal(ctx, l) {

for (let k in l.coefs) { k = Number(k); const signal = ctx.signals[k]; - if ((signal.c == ctx.stINTERNAL)&&(!ctx.F.isZero(l.coefs[k])) &&(!removedSignals[k])) return k; + if ( ( ((signal.o & ctx.MAIN) == 0) + ||( ((signal.o & ctx.IN) == 0) + &&((signal.o & ctx.OUT) == 0))) + &&((signal.o & ctx.ONE) ==0) + &&(!ctx.F.isZero(l.coefs[k])) + &&(!removedSignals[k])) return k; } return null; }
M src/construction_phase.js → src/construction_phase.js

@@ -428,10 +428,17 @@ isIn = isIn || ((sSrc.o & ctx.MAIN)&&(sSrc.o & ctx.IN));

} // Skip if an out is assigned directly to an input. - if ((!isIn)||(!isOut)) { - sDest.e = sIdx; - } else { - if (utils.isDefined(sSrc.v)) sDest.v = sSrc.v; + if (!(isIn&&isOut)) { + if (isIn) { + sDest.e = sIdx; + } else if (isOut) { + sSrc.e = dIdx; + } else { + sDest.e = sIdx; + } + if (!isOut) { + if (utils.isDefined(sSrc.v)) sDest.v = sSrc.v; + } } } }