diff --git a/nightfall-deployer/contracts/ChallengesUtil.sol b/nightfall-deployer/contracts/ChallengesUtil.sol index facea657c..ac13fc05f 100644 --- a/nightfall-deployer/contracts/ChallengesUtil.sol +++ b/nightfall-deployer/contracts/ChallengesUtil.sol @@ -70,15 +70,19 @@ library ChallengesUtil { for (uint256 i = 0; i < transaction.proof.length; i++) { if (transaction.proof[i] == 0) nZeroProof++; } + uint256 nZeroCompressedSecrets; + for (uint256 i = 0; i < transaction.compressedSecrets.length; i++) { + if (transaction.compressedSecrets[i] == 0) nZeroCompressedSecrets++; + } require( (transaction.tokenId == ZERO && transaction.value == 0) || transaction.ercAddress == ZERO || transaction.recipientAddress != ZERO || transaction.commitments[0] == ZERO || transaction.commitments[1] != ZERO || - transaction.commitments.length != 1 || - transaction.nullifiers.length != 0 || - transaction.compressedSecrets.length != 0 || + transaction.nullifiers[0] != ZERO || + transaction.nullifiers[1] != ZERO || + nZeroCompressedSecrets != 8 || nZeroProof == 4 || // We assume that 3 out of the 4 proof elements can be a valid ZERO. Deals with exception cases transaction.historicRootBlockNumberL2[0] != 0 || transaction.historicRootBlockNumberL2[1] != 0, @@ -106,10 +110,8 @@ library ChallengesUtil { transaction.recipientAddress != ZERO || transaction.commitments[0] == ZERO || transaction.commitments[1] != ZERO || - transaction.commitments.length != 1 || transaction.nullifiers[0] == ZERO || transaction.nullifiers[1] != ZERO || - transaction.nullifiers.length != 1 || nZeroCompressedSecrets == 8 || // We assume that 7 out of the 8 compressed secrets elements can be a valid ZERO. Deals with exception cases nZeroProof == 4 || // We assume that 3 out of the 4 proof elements can be a valid ZERO. Deals with exception cases transaction.historicRootBlockNumberL2[1] != 0, // If this is a single, the second historicBlockNumber needs to be zero @@ -137,10 +139,8 @@ library ChallengesUtil { transaction.recipientAddress != ZERO || transaction.commitments[0] == ZERO || transaction.commitments[1] == ZERO || - transaction.commitments.length != 2 || transaction.nullifiers[0] == ZERO || transaction.nullifiers[1] == ZERO || - transaction.nullifiers.length != 2 || nZeroCompressedSecrets == 8 || // We assume that 7 out of the 8 compressed secrets elements can be a valid ZERO. Deals with exception cases nZeroProof == 4, // We assume that 3 out of the 4 proof elements can be a valid ZERO. Deals with exception cases 'This double transfer transaction type is valid' @@ -156,15 +156,19 @@ library ChallengesUtil { for (uint256 i = 0; i < transaction.proof.length; i++) { if (transaction.proof[i] == 0) nZeroProof++; } + uint256 nZeroCompressedSecrets; + for (uint256 i = 0; i < transaction.compressedSecrets.length; i++) { + if (transaction.compressedSecrets[i] == 0) nZeroCompressedSecrets++; + } require( (transaction.tokenId == ZERO && transaction.value == 0) || transaction.ercAddress == ZERO || transaction.recipientAddress == ZERO || - transaction.commitments.length != 0 || + transaction.commitments[0] != ZERO || + transaction.commitments[1] != ZERO || transaction.nullifiers[0] == ZERO || transaction.nullifiers[1] != ZERO || - transaction.nullifiers.length != 1 || - transaction.compressedSecrets.length != 0 || + nZeroCompressedSecrets != 8 || nZeroProof == 4 || // We assume that 3 out of the 4 proof elements can be a valid ZERO. Deals with exception cases transaction.historicRootBlockNumberL2[1] != 0, // A withdraw has a similar constraint as a single transfer 'This withdraw transaction type is valid'