Skip to content

Commit c075a44

Browse files
committed
fix: zero nullifier and compressedsecrets check
1 parent 038442c commit c075a44

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎nightfall-deployer/contracts/ChallengesUtil.sol

+14
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,19 @@ library ChallengesUtil {
7070
for (uint256 i = 0; i < transaction.proof.length; i++) {
7171
if (transaction.proof[i] == 0) nZeroProof++;
7272
}
73+
uint256 nZeroCompressedSecrets;
74+
for (uint256 i = 0; i < transaction.compressedSecrets.length; i++) {
75+
if (transaction.compressedSecrets[i] == 0) nZeroCompressedSecrets++;
76+
}
7377
require(
7478
(transaction.tokenId == ZERO && transaction.value == 0) ||
7579
transaction.ercAddress == ZERO ||
7680
transaction.recipientAddress != ZERO ||
7781
transaction.commitments[0] == ZERO ||
7882
transaction.commitments[1] != ZERO ||
83+
transaction.nullifiers[0] != ZERO ||
84+
transaction.nullifiers[1] != ZERO ||
85+
transaction.compressedSecrets.length != nZeroCompressedSecrets ||
7986
nZeroProof == 4 || // We assume that 3 out of the 4 proof elements can be a valid ZERO. Deals with exception cases
8087
transaction.historicRootBlockNumberL2[0] != 0 ||
8188
transaction.historicRootBlockNumberL2[1] != 0,
@@ -149,12 +156,19 @@ library ChallengesUtil {
149156
for (uint256 i = 0; i < transaction.proof.length; i++) {
150157
if (transaction.proof[i] == 0) nZeroProof++;
151158
}
159+
uint256 nZeroCompressedSecrets;
160+
for (uint256 i = 0; i < transaction.compressedSecrets.length; i++) {
161+
if (transaction.compressedSecrets[i] == 0) nZeroCompressedSecrets++;
162+
}
152163
require(
153164
(transaction.tokenId == ZERO && transaction.value == 0) ||
154165
transaction.ercAddress == ZERO ||
155166
transaction.recipientAddress == ZERO ||
167+
transaction.commitments[0] != ZERO ||
168+
transaction.commitments[1] != ZERO ||
156169
transaction.nullifiers[0] == ZERO ||
157170
transaction.nullifiers[1] != ZERO ||
171+
transaction.compressedSecrets.length != nZeroCompressedSecrets ||
158172
nZeroProof == 4 || // We assume that 3 out of the 4 proof elements can be a valid ZERO. Deals with exception cases
159173
transaction.historicRootBlockNumberL2[1] != 0, // A withdraw has a similar constraint as a single transfer
160174
'This withdraw transaction type is valid'

0 commit comments

Comments
 (0)