mirror of
https://github.com/tornadocash/tornado-core.git
synced 2024-11-22 01:37:07 +01:00
rename pathIndex -> pathIndices
This commit is contained in:
parent
07168f9816
commit
ec4508e81e
@ -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;
|
||||
}
|
||||
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
|
4
cli.js
4
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')
|
||||
|
@ -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,
|
||||
})
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user