Skip to content

Commit a533ad9

Browse files
committed
Add explicit constrains for recepient, relayer and fee
1 parent d4e6031 commit a533ad9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

circuits/withdraw.circom

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ template Withdraw(levels) {
5050
tree.pathElements[i] <== pathElements[i];
5151
tree.pathIndices[i] <== pathIndices[i];
5252
}
53+
54+
// Add hidden signals to make sure that tampering with recipient or fee will invalidate the snark proof
55+
// Most likely it is not required, but it's better to stay on the safe side and it only takes 2 constraints
56+
// Squares are used to prevent optimizer from removing those constraints
57+
signal recipientSquare;
58+
signal feeSquare;
59+
signal relayerSquare;
60+
signal refundSquare;
61+
recipientSquare <== recipient * recipient;
62+
feeSquare <== fee * fee;
63+
relayerSquare <== relayer * relayer;
64+
refundSquare <== refund * refund;
5365
}
5466

5567
component main = Withdraw(20);

0 commit comments

Comments
 (0)