diff --git a/circuits/TreeUpdateArgsHasher.circom b/circuits/TreeUpdateArgsHasher.circom index 4fb7eb0..a8306d8 100644 --- a/circuits/TreeUpdateArgsHasher.circom +++ b/circuits/TreeUpdateArgsHasher.circom @@ -28,18 +28,20 @@ template TreeUpdateArgsHasher(nLeaves) { bitsNewRoot.in <== newRoot; bitsPathIndices.in <== pathIndices; - hasher.in[0] <== 0; - hasher.in[1] <== 0; + var index = 0; + + hasher.in[index++] <== 0; + hasher.in[index++] <== 0; for(var i = 0; i < 254; i++) { - hasher.in[i + 2] <== bitsOldRoot.out[253 - i]; + hasher.in[index++] <== bitsOldRoot.out[253 - i]; } - hasher.in[256] <== 0; - hasher.in[257] <== 0; + hasher.in[index++] <== 0; + hasher.in[index++] <== 0; for(var i = 0; i < 254; i++) { - hasher.in[i + 258] <== bitsNewRoot.out[253 - i]; + hasher.in[index++] <== bitsNewRoot.out[253 - i]; } for(var i = 0; i < 32; i++) { - hasher.in[i + 512] <== bitsPathIndices.out[31 - i]; + hasher.in[index++] <== bitsPathIndices.out[31 - i]; } for(var leaf = 0; leaf < nLeaves; leaf++) { // the range check on hash is optional, it's enforced by the smart contract anyway @@ -49,16 +51,16 @@ template TreeUpdateArgsHasher(nLeaves) { bitsHash[leaf].in <== hashes[leaf]; bitsInstance[leaf].in <== instances[leaf]; bitsBlock[leaf].in <== blocks[leaf]; - hasher.in[header + leaf * bitsPerLeaf + 0] <== 0; - hasher.in[header + leaf * bitsPerLeaf + 1] <== 0; + hasher.in[index++] <== 0; + hasher.in[index++] <== 0; for(var i = 0; i < 254; i++) { - hasher.in[header + leaf * bitsPerLeaf + i + 2] <== bitsHash[leaf].out[253 - i]; + hasher.in[index++] <== bitsHash[leaf].out[253 - i]; } for(var i = 0; i < 160; i++) { - hasher.in[header + leaf * bitsPerLeaf + i + 256] <== bitsInstance[leaf].out[159 - i]; + hasher.in[index++] <== bitsInstance[leaf].out[159 - i]; } for(var i = 0; i < 32; i++) { - hasher.in[header + leaf * bitsPerLeaf + i + 416] <== bitsBlock[leaf].out[31 - i]; + hasher.in[index++] <== bitsBlock[leaf].out[31 - i]; } } component b2n = Bits2Num(256); diff --git a/package.json b/package.json index c82ec6e..8acf5ca 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "dependencies": { "@openzeppelin/contracts": "^3.4.0", "@openzeppelin/upgrades-core": "^1.5.1", - "circom": "^0.5.38", + "circom": "0.5.42", "circom_runtime": "^0.1.12", "circomlib": "git+https://github.com/tornadocash/circomlib.git#d20d53411d1bef61f38c99a8b36d5d0cc4836aa1", "dotenv": "^8.2.0", diff --git a/src/index.js b/src/index.js index bc30643..77e8f1f 100644 --- a/src/index.js +++ b/src/index.js @@ -42,7 +42,14 @@ function prove(input, keyBasePath) { fs.writeFileSync(`${dir}/input.json`, JSON.stringify(input, null, 2)) out = await exec(`${keyBasePath} ${dir}/input.json ${dir}/witness.json`) } else { - await wtns.calculate(utils.unstringifyBigInts(input), `${keyBasePath}.wasm`, `${dir}/witness.wtns`) + await wtns.debug( + utils.unstringifyBigInts(input), + `${keyBasePath}.wasm`, + `${dir}/witness.wtns`, + `${keyBasePath}.sym`, + {}, + console, + ) const witness = utils.stringifyBigInts(await wtns.exportJson(`${dir}/witness.wtns`)) fs.writeFileSync(`${dir}/witness.json`, JSON.stringify(witness, null, 2)) } diff --git a/yarn.lock b/yarn.lock index e1d0373..ee1dee7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2241,10 +2241,10 @@ circom@0.5.33: tmp-promise "^2.0.2" wasmbuilder "0.0.10" -circom@^0.5.38: - version "0.5.38" - resolved "https://registry.yarnpkg.com/circom/-/circom-0.5.38.tgz#c099fb196085837575fb266f37b0516b1ec56eb5" - integrity sha512-PFlXto8gDysUlwk6z/GYbn1Mv5BtW9BI4769N9gSP0/7KDNSqLNyVmL4DgMLc67/EpG4qJLGch3SdgzQD+/cfw== +circom@0.5.42: + version "0.5.42" + resolved "https://registry.yarnpkg.com/circom/-/circom-0.5.42.tgz#96a456f9538f4425654df091d15e3158e9da2acc" + integrity sha512-v6+f9g3z2ia17NQvQmyZjvh8cE8O3GtxRE36KfJfx/a+s58Y7aEDWsUG+GFRJhp1ajiQELdj3NehY9vHSf5Rkg== dependencies: chai "^4.2.0" circom_runtime "0.1.12"