Skip to content

Commit 571adc1

Browse files
committed
add validation of plaintext arguments onDecrypt
1 parent d5954ee commit 571adc1

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

contracts/ConfidentialToken.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ contract ConfidentialToken is ConfidentialEIP3009, ERC20Permit, AccessManaged, I
118118
error PublicKeyIsNotRegistered(address viewer);
119119
error ValueIsEncrypted();
120120
error ValueWasNotEncryptedCorrectly();
121+
error WrongPlaintextFormat();
121122

122123
/// @notice Modifier to check if the user is registered
123124
/// @param user The address of the user to check
@@ -160,8 +161,12 @@ contract ConfidentialToken is ConfidentialEIP3009, ERC20Permit, AccessManaged, I
160161
bytes[] calldata plaintextArguments
161162
) external override {
162163
require(_callbackSenders.remove(msg.sender), AccessViolation());
164+
// Both actions require more than 1 plaintext argument in the array
165+
require(plaintextArguments.length > 1, WrongPlaintextFormat());
166+
require(plaintextArguments[0].length == 1, WrongPlaintextFormat());
163167
OnDecryptAction action = OnDecryptAction(uint8(bytes1(plaintextArguments[0])));
164168
if(action == OnDecryptAction.HISTORIC_VIEW) {
169+
require(plaintextArguments[1].length == 20, WrongPlaintextFormat());
165170
address sender = address(bytes20(plaintextArguments[1]));
166171
require(_knownPublicKey(sender), PublicKeyIsNotRegistered(sender));
167172

docs/ConfidentialToken.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ error ValueIsEncrypted()
143143
error ValueWasNotEncryptedCorrectly()
144144
```
145145

146+
### WrongPlaintextFormat
147+
148+
```solidity
149+
error WrongPlaintextFormat()
150+
```
151+
146152
### onlyRegisteredUser
147153

148154
Modifier to check if the user is registered

0 commit comments

Comments
 (0)