mirror of
https://github.com/tornadocash/tornado-core.git
synced 2025-05-02 06:16:03 -04:00
rename pathIndex -> pathIndices
This commit is contained in:
parent
07168f9816
commit
ec4508e81e
5 changed files with 19 additions and 22 deletions
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue