From a533ad9ffb62163a42d4fa9a09984c5dd4e5c41d Mon Sep 17 00:00:00 2001 From: Alexey Date: Tue, 28 Apr 2020 10:36:48 +0300 Subject: [PATCH] Add explicit constrains for recepient, relayer and fee --- circuits/withdraw.circom | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/circuits/withdraw.circom b/circuits/withdraw.circom index bed8cd6..54c3838 100644 --- a/circuits/withdraw.circom +++ b/circuits/withdraw.circom @@ -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);