mirror of
https://github.com/tornadocash/tornado-trees.git
synced 2024-12-04 15:14:35 +01:00
change index logic, fixes CVF-38. Update circom version.
This commit is contained in:
parent
9321740be7
commit
a04fe966f7
@ -28,18 +28,20 @@ template TreeUpdateArgsHasher(nLeaves) {
|
|||||||
bitsNewRoot.in <== newRoot;
|
bitsNewRoot.in <== newRoot;
|
||||||
bitsPathIndices.in <== pathIndices;
|
bitsPathIndices.in <== pathIndices;
|
||||||
|
|
||||||
hasher.in[0] <== 0;
|
var index = 0;
|
||||||
hasher.in[1] <== 0;
|
|
||||||
|
hasher.in[index++] <== 0;
|
||||||
|
hasher.in[index++] <== 0;
|
||||||
for(var i = 0; i < 254; i++) {
|
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[index++] <== 0;
|
||||||
hasher.in[257] <== 0;
|
hasher.in[index++] <== 0;
|
||||||
for(var i = 0; i < 254; i++) {
|
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++) {
|
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++) {
|
for(var leaf = 0; leaf < nLeaves; leaf++) {
|
||||||
// the range check on hash is optional, it's enforced by the smart contract anyway
|
// 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];
|
bitsHash[leaf].in <== hashes[leaf];
|
||||||
bitsInstance[leaf].in <== instances[leaf];
|
bitsInstance[leaf].in <== instances[leaf];
|
||||||
bitsBlock[leaf].in <== blocks[leaf];
|
bitsBlock[leaf].in <== blocks[leaf];
|
||||||
hasher.in[header + leaf * bitsPerLeaf + 0] <== 0;
|
hasher.in[index++] <== 0;
|
||||||
hasher.in[header + leaf * bitsPerLeaf + 1] <== 0;
|
hasher.in[index++] <== 0;
|
||||||
for(var i = 0; i < 254; i++) {
|
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++) {
|
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++) {
|
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);
|
component b2n = Bits2Num(256);
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@openzeppelin/contracts": "^3.4.0",
|
"@openzeppelin/contracts": "^3.4.0",
|
||||||
"@openzeppelin/upgrades-core": "^1.5.1",
|
"@openzeppelin/upgrades-core": "^1.5.1",
|
||||||
"circom": "^0.5.38",
|
"circom": "0.5.42",
|
||||||
"circom_runtime": "^0.1.12",
|
"circom_runtime": "^0.1.12",
|
||||||
"circomlib": "git+https://github.com/tornadocash/circomlib.git#d20d53411d1bef61f38c99a8b36d5d0cc4836aa1",
|
"circomlib": "git+https://github.com/tornadocash/circomlib.git#d20d53411d1bef61f38c99a8b36d5d0cc4836aa1",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
|
@ -42,7 +42,14 @@ function prove(input, keyBasePath) {
|
|||||||
fs.writeFileSync(`${dir}/input.json`, JSON.stringify(input, null, 2))
|
fs.writeFileSync(`${dir}/input.json`, JSON.stringify(input, null, 2))
|
||||||
out = await exec(`${keyBasePath} ${dir}/input.json ${dir}/witness.json`)
|
out = await exec(`${keyBasePath} ${dir}/input.json ${dir}/witness.json`)
|
||||||
} else {
|
} 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`))
|
const witness = utils.stringifyBigInts(await wtns.exportJson(`${dir}/witness.wtns`))
|
||||||
fs.writeFileSync(`${dir}/witness.json`, JSON.stringify(witness, null, 2))
|
fs.writeFileSync(`${dir}/witness.json`, JSON.stringify(witness, null, 2))
|
||||||
}
|
}
|
||||||
|
@ -2241,10 +2241,10 @@ circom@0.5.33:
|
|||||||
tmp-promise "^2.0.2"
|
tmp-promise "^2.0.2"
|
||||||
wasmbuilder "0.0.10"
|
wasmbuilder "0.0.10"
|
||||||
|
|
||||||
circom@^0.5.38:
|
circom@0.5.42:
|
||||||
version "0.5.38"
|
version "0.5.42"
|
||||||
resolved "https://registry.yarnpkg.com/circom/-/circom-0.5.38.tgz#c099fb196085837575fb266f37b0516b1ec56eb5"
|
resolved "https://registry.yarnpkg.com/circom/-/circom-0.5.42.tgz#96a456f9538f4425654df091d15e3158e9da2acc"
|
||||||
integrity sha512-PFlXto8gDysUlwk6z/GYbn1Mv5BtW9BI4769N9gSP0/7KDNSqLNyVmL4DgMLc67/EpG4qJLGch3SdgzQD+/cfw==
|
integrity sha512-v6+f9g3z2ia17NQvQmyZjvh8cE8O3GtxRE36KfJfx/a+s58Y7aEDWsUG+GFRJhp1ajiQELdj3NehY9vHSf5Rkg==
|
||||||
dependencies:
|
dependencies:
|
||||||
chai "^4.2.0"
|
chai "^4.2.0"
|
||||||
circom_runtime "0.1.12"
|
circom_runtime "0.1.12"
|
||||||
|
Loading…
Reference in New Issue
Block a user