NPublic in code
Jordi Baylina jordi@baylina.cat
Mon, 07 Dec 2020 12:20:50 +0100
6 files changed,
30 insertions(+),
14 deletions(-)
M
package-lock.json
→
package-lock.json
@@ -208,9 +208,9 @@ "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
"integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=" }, "circom_runtime": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/circom_runtime/-/circom_runtime-0.1.8.tgz", - "integrity": "sha512-5ZmzCyidkNPb1zZsJGRXTuWcJ6kW6+gRBtHgf2tFqTh5dUyWVVPH0Zg7AsU2ijPr1AmYZUlme0yORUZK5HrjOA==", + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/circom_runtime/-/circom_runtime-0.1.9.tgz", + "integrity": "sha512-eh34quaGpeEWXthnhmC9zpoBL/5zJ0mGDbPT/plb/xVmFaKxJDcLuCr2sma5s3il8AYlEIb/nbqytojyI3TWDQ==", "requires": { "ffjavascript": "0.2.10", "fnv-plus": "^1.3.1"
M
package.json
→
package.json
@@ -30,7 +30,7 @@ "url": "https://github.com/iden3/circom.git"
}, "dependencies": { "chai": "^4.2.0", - "circom_runtime": "0.1.8", + "circom_runtime": "0.1.9", "fastfile": "0.0.18", "ffiasm": "0.1.1", "ffjavascript": "0.2.22",
M
ports/c/builder.js
→
ports/c/builder.js
@@ -433,6 +433,7 @@ `#define NComponents ${this.header.NComponents}`,
`#define NOutputs ${this.header.NOutputs}`, `#define NInputs ${this.header.NInputs}`, `#define NVars ${this.header.NVars}`, + `#define NPublic ${this.header.NPublic}`, `#define __P__ "${this.header.P.toString()}"`, "" );@@ -662,7 +663,7 @@ }
async _buildCircuitVar(fdData) { - const buff = new Uint8Array(72); + const buff = new Uint8Array(76); const buffV = new DataView(buff.buffer); utils.setUint64(buffV, 0, this.pWit2Sig, true);@@ -678,6 +679,7 @@ buffV.setUint32(56, this.header.NOutputs, true);
buffV.setUint32(60, this.header.NInputs, true); buffV.setUint32(64, this.header.NVars, true); buffV.setUint32(68, this.nCets, true); + buffV.setUint32(72, this.header.NPublic, true); fdData.pos = 0;@@ -697,7 +699,7 @@
async build(fdCode, fdData) { const encoder = new TextEncoder("utf-8"); - fdData.pos = 72; + fdData.pos = 76; while (fdData.pos % 8) fdData.pos++; const code=new BigArray();
M
ports/wasm/build_runtime.js
→
ports/wasm/build_runtime.js
@@ -693,6 +693,15 @@
f.addCode(c.i32_const(builder.header.NVars)); } + function buildGetNPublic() { + const f = module.addFunction("getNPublic"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + f.addCode(c.i32_const(builder.header.NPublic)); + } + function buildGetFrLen() { const f = module.addFunction("getFrLen"); f.setReturnType("i32");@@ -892,6 +901,7 @@ buildCheckConstraint();
buildCheckAssert(); buildGetNVars(); + buildGetNPublic(); buildGetFrLen(); buildGetPWitness(); buildGetPRawPrime();@@ -901,6 +911,7 @@ // buildFrToInt();
module.exportFunction("init"); module.exportFunction("getNVars"); + module.exportFunction("getNPublic"); module.exportFunction("getFrLen"); module.exportFunction("getSignalOffset32"); module.exportFunction("setSignal");
M
ports/wasm/builder.js
→
ports/wasm/builder.js
@@ -781,20 +781,21 @@ // Body functions
_buildHeader(module) { - this.pCircuit = module.alloc(48); + this.pCircuit = module.alloc(52); this.pNSignals = this.pCircuit; this.pNComponents = this.pCircuit + 4; this.pNInputs = this.pCircuit + 8; this.pNOutputs = this.pCircuit + 12; this.pNVars = this.pCircuit + 16; - this.ppWit2sig = this.pCircuit + 20; - this.ppComponents = this.pCircuit + 24; - this.ppMapIsInput = this.pCircuit + 28; - this.ppConstants = this.pCircuit + 32; - this.ppSignals = this.pCircuit + 36; - this.ppInputSignalsToTrigger = this.pCircuit + 40; - this.ppSignalsAssigned = this.pCircuit + 44; + this.pNPublic = this.pCircuit + 20; + this.ppWit2sig = this.pCircuit + 24; + this.ppComponents = this.pCircuit + 28; + this.ppMapIsInput = this.pCircuit + 32; + this.ppConstants = this.pCircuit + 36; + this.ppSignals = this.pCircuit + 40; + this.ppInputSignalsToTrigger = this.pCircuit + 44; + this.ppSignalsAssigned = this.pCircuit + 48; } _buildSizes(module) {@@ -985,6 +986,7 @@ module.addData(this.pNComponents, intToBytes32(this.header.NComponents));
module.addData(this.pNInputs, intToBytes32(this.header.NInputs)); module.addData(this.pNOutputs, intToBytes32(this.header.NOutputs)); module.addData(this.pNVars, intToBytes32(this.header.NVars)); + module.addData(this.pNPublic, intToBytes32(this.header.NPublic)); module.addData(this.ppWit2sig, intToBytes32(this.pWit2sig)); module.addData(this.ppComponents, intToBytes32(this.pComponents)); module.addData(this.ppMapIsInput, intToBytes32(this.pMapIsInput));
M
src/build.js
→
src/build.js
@@ -196,6 +196,7 @@ NComponents: ctx.components.length,
NInputs: ctx.components[ ctx.getComponentIdx("main") ].nInSignals, NOutputs: ctx.totals[ ctx.stOUTPUT ], NVars: ctx.totals[ctx.stONE] + ctx.totals[ctx.stOUTPUT] + ctx.totals[ctx.stPUBINPUT] + ctx.totals[ctx.stPRVINPUT] + ctx.totals[ctx.stINTERNAL], + NPublic: ctx.totals[ctx.stOUTPUT] + ctx.totals[ctx.stPUBINPUT], P: ctx.F.p }); }