Skip to main content

Registration of username Signature Structure

To authorize the registrationUsername operation (the reveal phase following pre-registration), the user must generate a cryptographic signature compliant with the EIP-191 standard .

This signature proves ownership of the pre-registration commit by revealing the original username and the secret clowNumber.

Signed Message Format

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

string.concat(
"afabc8db",
",",
_username,
",",
Strings.toString(_clowNumber),
",",
Strings.toString(_nameServiceNonce)
)

1. MNS Registration Identifier (Hex String):

  • Value: afabc8db
  • Purpose: A specific identifier used within the EIP-191 framework to distinguish MNS username registration (reveal) messages from other types of signed messages.

2. Username (String):

  • Value: The _username string itself.
  • Purpose: The actual, plain-text username that the user intends to register. This must match the username used to generate the hash during pre-registration.

3. Clow Number (String):

  • Value: The result of Strings.toString(_clowNumber).
  • Purpose: The string representation of the secret uint256 number (clowNumber) chosen by the user during the pre-registration phase.

4. MNS Nonce (String):

  • Value: The result of Strings.toString(_nameServiceNonce).
  • Purpose: The string representation of the user's nonce specific to the MNS contract for this registration action. This prevents replay attacks for registration actions initiated by the user and should likely be incremented separately from the pre-registration nonce.

Practical Example

Let's say we want to register a username with the following parameters:

  • Username: "alice"
  • Clow Number: 12345
  • Name Service Nonce: 1

The message would be constructed as:

"afabc8db,alice,12345,1"

Message Breakdown:

  • afabc8db: Function selector for registration username verification
  • alice: The username to register
  • 12345: The secret clowNumber used during pre-registration
  • 1: The user's name service nonce

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

tip
  • The function selector afabc8db is the first 4 bytes of the keccak256 hash of the function signature for verifyMessageSignedForRegistrationUsername
  • Strings.toString converts a number to a string (standard OpenZeppelin utility)
  • The signature verification uses the EIP-191 standard for message signing
  • The clowNumber and username combination must match what was used during the pre-registration phase to successfully complete the registration