diff --git a/circuits/merkleTree.circom b/circuits/merkleTree.circom index a8b2328..c93f131 100644 --- a/circuits/merkleTree.circom +++ b/circuits/merkleTree.circom @@ -4,14 +4,12 @@ include "../node_modules/circomlib/circuits/mimcsponge.circom"; template HashLeftRight() { signal input left; signal input right; - signal output hash; component hasher = MiMCSponge(2, 220, 1); hasher.ins[0] <== left; hasher.ins[1] <== right; hasher.k <== 0; - hash <== hasher.outs[0]; } @@ -27,12 +25,12 @@ template Mux() { } // Verifies that merkle proof is correct for given merkle root and a leaf -// pathIndex input is an array of 0/1 selectors telling whether given pathElement is on the left or right side of merkle path +// pathIndices input is an array of 0/1 selectors telling whether given pathElement is on the left or right side of merkle path template MerkleTree(levels) { signal input leaf; signal input root; signal private input pathElements[levels]; - signal private input pathIndex[levels]; + signal private input pathIndices[levels]; component selectors[levels]; component hashers[levels]; @@ -42,14 +40,13 @@ template MerkleTree(levels) { hashers[i] = HashLeftRight(); selectors[i].in[1] <== pathElements[i]; - selectors[i].s <== pathIndex[i]; + selectors[i].s <== pathIndices[i]; hashers[i].left <== selectors[i].out[0]; hashers[i].right <== selectors[i].out[1]; } selectors[0].in[0] <== leaf; - for (var i = 1; i < levels; i++) { selectors[i].in[0] <== hashers[i-1].hash; } diff --git a/circuits/withdraw.circom b/circuits/withdraw.circom index e060f4f..1aee5e1 100644 --- a/circuits/withdraw.circom +++ b/circuits/withdraw.circom @@ -37,7 +37,7 @@ template Withdraw(levels) { signal private input nullifier; signal private input secret; signal private input pathElements[levels]; - signal private input pathIndex[levels]; + signal private input pathIndices[levels]; component hasher = CommitmentHasher(); hasher.nullifier <== nullifier; @@ -50,7 +50,7 @@ template Withdraw(levels) { tree.root <== root; for (var i = 0; i < levels; i++) { tree.pathElements[i] <== pathElements[i]; - tree.pathIndex[i] <== pathIndex[i]; + tree.pathIndices[i] <== pathIndices[i]; } } diff --git a/cli.js b/cli.js index e2e9c2b..68843a2 100755 --- a/cli.js +++ b/cli.js @@ -107,7 +107,7 @@ async function withdrawErc20(note, receiver, relayer) { nullifier: deposit.nullifier, secret: deposit.secret, pathElements: path_elements, - pathIndex: path_index, + pathIndices: path_index, } console.log('Generating SNARK proof') @@ -182,7 +182,7 @@ async function withdraw(note, receiver) { nullifier: deposit.nullifier, secret: deposit.secret, pathElements: path_elements, - pathIndex: path_index, + pathIndices: path_index, } console.log('Generating SNARK proof') diff --git a/test/ERC20Mixer.test.js b/test/ERC20Mixer.test.js index 8e0d42d..88530be 100644 --- a/test/ERC20Mixer.test.js +++ b/test/ERC20Mixer.test.js @@ -136,7 +136,7 @@ contract('ERC20Mixer', accounts => { nullifier: deposit.nullifier, secret: deposit.secret, pathElements: path_elements, - pathIndex: path_index, + pathIndices: path_index, }) @@ -204,7 +204,7 @@ contract('ERC20Mixer', accounts => { nullifier: deposit.nullifier, secret: deposit.secret, pathElements: path_elements, - pathIndex: path_index, + pathIndices: path_index, }) @@ -263,7 +263,7 @@ contract('ERC20Mixer', accounts => { nullifier: deposit.nullifier, secret: deposit.secret, pathElements: path_elements, - pathIndex: path_index, + pathIndices: path_index, }) @@ -344,7 +344,7 @@ contract('ERC20Mixer', accounts => { nullifier: deposit.nullifier, secret: deposit.secret, pathElements: path_elements, - pathIndex: path_index, + pathIndices: path_index, }) diff --git a/test/ETHMixer.test.js b/test/ETHMixer.test.js index 2462b23..c1bf85a 100644 --- a/test/ETHMixer.test.js +++ b/test/ETHMixer.test.js @@ -148,7 +148,7 @@ contract('ETHMixer', accounts => { refund, secret: deposit.secret, pathElements: path_elements, - pathIndex: path_index, + pathIndices: path_index, }) let proofData = await websnarkUtils.genWitnessAndProve(groth16, input, circuit, proving_key) @@ -208,7 +208,7 @@ contract('ETHMixer', accounts => { nullifier: deposit.nullifier, secret: deposit.secret, pathElements: path_elements, - pathIndex: path_index, + pathIndices: path_index, }) @@ -263,7 +263,7 @@ contract('ETHMixer', accounts => { refund, secret: deposit.secret, pathElements: path_elements, - pathIndex: path_index, + pathIndices: path_index, }) const proofData = await websnarkUtils.genWitnessAndProve(groth16, input, circuit, proving_key) const { proof, publicSignals } = websnarkUtils.toSolidityInput(proofData) @@ -289,7 +289,7 @@ contract('ETHMixer', accounts => { refund, secret: deposit.secret, pathElements: path_elements, - pathIndex: path_index, + pathIndices: path_index, }) const proofData = await websnarkUtils.genWitnessAndProve(groth16, input, circuit, proving_key) const { proof, publicSignals } = websnarkUtils.toSolidityInput(proofData) @@ -315,7 +315,7 @@ contract('ETHMixer', accounts => { refund, secret: deposit.secret, pathElements: path_elements, - pathIndex: path_index, + pathIndices: path_index, }) const proofData = await websnarkUtils.genWitnessAndProve(groth16, input, circuit, proving_key) @@ -341,7 +341,7 @@ contract('ETHMixer', accounts => { refund, secret: deposit.secret, pathElements: path_elements, - pathIndex: path_index, + pathIndices: path_index, }) const dummyRoot = randomHex(32) @@ -370,7 +370,7 @@ contract('ETHMixer', accounts => { refund, secret: deposit.secret, pathElements: path_elements, - pathIndex: path_index, + pathIndices: path_index, }) const proofData = await websnarkUtils.genWitnessAndProve(groth16, input, circuit, proving_key) let { proof, publicSignals } = websnarkUtils.toSolidityInput(proofData) @@ -422,7 +422,7 @@ contract('ETHMixer', accounts => { refund: bigInt(1), secret: deposit.secret, pathElements: path_elements, - pathIndex: path_index, + pathIndices: path_index, }) const proofData = await websnarkUtils.genWitnessAndProve(groth16, input, circuit, proving_key)