fix: underflow error for AllowedERC725YKey + allow to set the zero key 0x00000000...00000000
via the Key Manager
#226
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR introduce?
The
AllowedERC725YKey
feature in the LSP6 Key Manager currently does not allowed to set0x0000000000000000000000000000000000000000000000000000000000000000
(=bytes32(0)
or 32 x00
bytes) as an allowed ERC725YKey.If a controller address has this data key in its list of allowed ERC725Y data key, the check against the allowed data key leads to integer underflow when counting the number of zero trailing bytes 🚫 in the allowed data key (see screenshot below).
As a result, this can lead the controller to be stuck and prevent the controller address from setting data on the account linked to this KeyManager.
This PR fixes this bug, while also allowing to whitelist any allowed ERC725Y data key by setting the zero-key
0x00000000...00000000
in the list of allowed ERC725Y data keys.