-
Notifications
You must be signed in to change notification settings - Fork 124
Salt StorageMap keys #1129
Description
What should be done?
Useres can currently use StorageMaps in accounts to authenticate many key-value pairs in a single storage slot. The keys of the Smt underlying the StorageMap are taken directly from user input. This means users or an attacker could insert many key-value pairs that end up in the same subtree. However, a uniform distribution of keys across an Smt is important for storage optimizations, so it would be desirable for us to ensure keys are uniformly distributed and not entirely user-controlled.
How should it be done?
To that end, we can add a salt to the user keys, like the account ID. So in essence, the actual key in an Smt should be the hash of the tuple (KEY || [account_id_prefix, account_id_suffix, 0, 0]) or something similar.
When is this task done?
When user input can no longer affect the distribution of keys in a StorageMap.
Additional context
No response