mirror of
https://github.com/tornadocash/tornado-core.git
synced 2024-11-22 01:37:07 +01:00
refactor loop
This commit is contained in:
parent
ec4508e81e
commit
f8cd3fea1e
@ -1,6 +1,6 @@
|
||||
include "../node_modules/circomlib/circuits/mimcsponge.circom";
|
||||
|
||||
// Computes MiMC(left + right)
|
||||
// Computes MiMC([left, right])
|
||||
template HashLeftRight() {
|
||||
signal input left;
|
||||
signal input right;
|
||||
@ -37,19 +37,14 @@ template MerkleTree(levels) {
|
||||
|
||||
for (var i = 0; i < levels; i++) {
|
||||
selectors[i] = Mux();
|
||||
hashers[i] = HashLeftRight();
|
||||
|
||||
selectors[i].in[0] <== i == 0 ? leaf : hashers[i - 1].hash;
|
||||
selectors[i].in[1] <== pathElements[i];
|
||||
selectors[i].s <== pathIndices[i];
|
||||
|
||||
hashers[i] = HashLeftRight();
|
||||
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;
|
||||
}
|
||||
|
||||
root === hashers[levels - 1].hash;
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ include "merkleTree.circom";
|
||||
template CommitmentHasher() {
|
||||
signal private input nullifier;
|
||||
signal private input secret;
|
||||
|
||||
signal output commitment;
|
||||
signal output nullifierHash;
|
||||
|
||||
@ -42,8 +41,7 @@ template Withdraw(levels) {
|
||||
component hasher = CommitmentHasher();
|
||||
hasher.nullifier <== nullifier;
|
||||
hasher.secret <== secret;
|
||||
|
||||
nullifierHash === hasher.nullifierHash;
|
||||
hasher.nullifierHash === nullifierHash;
|
||||
|
||||
component tree = MerkleTree(levels);
|
||||
tree.leaf <== hasher.commitment;
|
||||
|
Loading…
Reference in New Issue
Block a user