Remove Custom Metadata Signature Structure
To authorize the removeCustomMetadata
operation within the MNS service, the user who currently owns the username must generate a cryptographic signature compliant with the EIP-191 standard.
This signature proves the current username owner's intent and authorization to remove a specific custom metadata entry (identified by its key/index _key
) associated with their username (_username
).
Signed Message Format
The message is constructed by concatenating the following components as strings, separated by commas (,
):
string.concat(
"8adf3927",
",",
_username,
",",
Strings.toString(_key),
",",
Strings.toString(_nonce)
)
1. MNS Remove Custom Metadata Identifier (Hex String):
- Value:
8adf3927
- Purpose: A specific identifier used within the framework to distinguish MNS
removeCustomMetadata
messages from other types of signed messages.
2. Target Username (String):
- Value: The
_username
string itself. - Purpose: Specifies the username from which the custom metadata entry will be removed.
3. Metadata Key/Index (String):
- Value: The result of
Strings.toString(_key)
. (Assuming_key
is auint256
representing the index or slot of the metadata to remove). - Purpose: The string representation of the identifier for the specific metadata entry targeted for removal.
4. MNS Nonce (String):
- Value: The result of
Strings.toString(_nonce)
. - Purpose: The string representation of the current username owner's nonce specific to the MNS contract for this
removeCustomMetadata
action. This prevents replay attacks of the removal operation initiated by the owner.
Practical Example
Let's say the current owner wants to remove custom metadata from their username with the following parameters:
- Username:
"alice"
- Metadata Key:
3
(the index/identifier of the metadata entry to remove) - Nonce:
15
The message would be constructed as:
"8adf3927,alice,3,15"
Message Breakdown:
8adf3927
: Function selector for remove custom metadata verificationalice
: The username from which the metadata will be removed3
: The key/index of the specific metadata entry to remove15
: The current username owner's nonce
This message would then be signed using EIP-191 standard, and the resulting signature would be used to verify the metadata removal request in the verifyMessageSignedForRemoveCustomMetadata
function.
- The function selector
8adf3927
is the first 4 bytes of the keccak256 hash of the function signature forverifyMessageSignedForRemoveCustomMetadata
Strings.toString
converts a number to a string (standard OpenZeppelin utility)- The signature verification uses the EIP-191 standard for message signing
- Only the current owner of the username can remove custom metadata from their username
- The
_key
parameter identifies which specific metadata entry to remove by its index/identifier - The
_nonce
parameter is the user's general nonce, not specifically the name service nonce