Pre-registration of username Signature Structure
To authorize the preRegistrationUsername
operation, the user (_user
) must generate a cryptographic signature compliant with the EIP-191 standard.
The signature is created by signing a precisely formatted string message derived from the pre-registration details.
Signed Message Format
The message is constructed by concatenating the following components as strings, separated by commas (,
):
string.concat(
"b667c80b",
",",
AdvancedStrings.bytes32ToString(_hashUsername),
",",
Strings.toString(_mateNameServiceNonce)
)
1. MNS Pre-registration Identifier (Hex String):*
- Value:
b667c80b
- Purpose: A specific identifier used within the EIP-191 framework to distinguish MNS username pre-registration messages from other types of signed messages in the system.
2. Username Hash (String):
- Value: The result of
AdvancedStrings.bytes32ToString(_hashUsername)
. - Purpose: The string representation of the
bytes32
hash commitment being pre-registered. This hash is derived from the user's chosen username and their secretclowNumber
.
3. MNS Nonce (String):
- Value: The result of
Strings.toString(_nonce)
. - Purpose: The string representation of the user's nonce specific to the MNS contract (
mateNameServiceNonce
). This prevents replay attacks for pre-registration actions initiated by the_user
.
tip
addressToString
converts an address to a lowercase stringStrings.toString
converts a number to a stringAdvancedStrings.bytes32ToString(bytes32 _input)
converts abytes32
value into its lowercase hexadecimal string representation
Hash Username Structure
For pre-registration of a username, users must provide a hash of the username. The hash is calculated using SHA3-256 with the following structure:
keccak256(abi.encodePacked(_username, _clowNumber));
Where:
_username
is the desired username_clowNumber
is the key number of the username that will be used in theregistrationUsername
function