Flush Custom Metadata Signature Structure
To authorize the flushCustomMetadata
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 all custom metadata entries associated with their username (_username
).
Signed Message Format
The message is constructed by concatenating the following components as strings, separated by commas (,
):
string.concat(
"3ca44e54",
",",
_identity,
",",
Strings.toString(_nonce)
)
1. MNS Flush Custom Metadata Identifier (Hex String):
- Value:
3ca44e54
- Purpose: A specific identifier used within the EIP-191 framework to distinguish MNS
flushCustomMetadata
messages from other types of signed messages.
2. Target Identity (String):
- Value: The
_identity
string itself. - Purpose: Specifies the identity (username) for which all associated custom metadata entries will be removed.
3. 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
flushCustomMetadata
action. This prevents replay attacks of the operation initiated by the owner.
Practical Example
Let's say the current owner wants to flush all custom metadata from their identity with the following parameters:
- Identity:
"alice"
- Nonce:
20
The message would be constructed as:
"3ca44e54,alice,20"
Message Breakdown:
3ca44e54
: Function selector for flush custom metadata verificationalice
: The identity (username) from which all metadata will be removed20
: The current identity owner's nonce
This message would then be signed using EIP-191 standard, and the resulting signature would be used to verify the metadata flush request in the verifyMessageSignedForFlushCustomMetadata
function.
- The function selector
3ca44e54
is the first 4 bytes of the keccak256 hash of the function signature forverifyMessageSignedForFlushCustomMetadata
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 identity can flush all custom metadata from their identity
- This operation removes all custom metadata entries at once, unlike
removeCustomMetadata
which removes specific entries - The
_nonce
parameter is the user's general nonce, similar to the remove function