Skip to content

Commit

Permalink
Add explicit constrains for recepient, relayer and fee
Browse files Browse the repository at this point in the history
  • Loading branch information
pertsev committed Apr 28, 2020
1 parent d4e6031 commit a533ad9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions circuits/withdraw.circom
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ template Withdraw(levels) {
tree.pathElements[i] <== pathElements[i];
tree.pathIndices[i] <== pathIndices[i];
}

// Add hidden signals to make sure that tampering with recipient or fee will invalidate the snark proof
// Most likely it is not required, but it's better to stay on the safe side and it only takes 2 constraints
// Squares are used to prevent optimizer from removing those constraints
signal recipientSquare;
signal feeSquare;
signal relayerSquare;
signal refundSquare;
recipientSquare <== recipient * recipient;
feeSquare <== fee * fee;
relayerSquare <== relayer * relayer;
refundSquare <== refund * refund;
}

component main = Withdraw(20);

0 comments on commit a533ad9

Please sign in to comment.