Skip to main content

Add Custom Metadata Signature Structure

To authorize the addCustomMetadata 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 add or update a specific custom metadata field (_value) associated with their username (_username).

Signed Message Format

The message is constructed by concatenating the following components as strings, separated by commas (,):

string.concat(
"4cfe021f",
",",
_identity,
",",
_value,
",",
Strings.toString(_nameServiceNonce)
)

1. MNS Add Custom Metadata Identifier (Hex String):

  • Value: 4cfe021f
  • Purpose: A specific identifier used within the EIP-191 framework to distinguish MNS addCustomMetadata messages from other types of signed messages.

2. Target Identity (String):

  • Value: The _identity string itself.
  • Purpose: Specifies the identity (username) to which this custom metadata entry applies.

3. Metadata Value (String):

  • Value: The _value string itself, exactly as provided by the user.
  • Purpose: Represents the custom data being associated with the username (e.g., a profile link, description, or other user-defined information).

4. MNS Nonce (String):

  • Value: The result of Strings.toString(_nameServiceNonce).
  • Purpose: The string representation of the current username owner's nonce specific to the MNS contract for this addCustomMetadata action. This prevents replay attacks of the metadata update operation initiated by the owner.

Practical Example

Let's say the current owner wants to add custom metadata to their identity with the following parameters:

  • Identity: "alice"
  • Metadata Value: "https://alice.example.com/profile"
  • Name Service Nonce: 12

The message would be constructed as:

"4cfe021f,alice,https://alice.example.com/profile,12"

Message Breakdown:

  • 4cfe021f: Function selector for add custom metadata verification
  • alice: The identity (username) to which the metadata applies
  • https://alice.example.com/profile: The custom metadata value being added
  • 12: The current identity owner's name service nonce

This message would then be signed using EIP-191 standard, and the resulting signature would be used to verify the metadata addition request in the verifyMessageSignedForAddCustomMetadata function.

tip
  • The function selector 4cfe021f is the first 4 bytes of the keccak256 hash of the function signature for verifyMessageSignedForAddCustomMetadata
  • 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 add custom metadata to their identity
  • The _value can contain any string data such as URLs, descriptions, or other custom information
  • Custom metadata allows users to associate additional information with their identities