Salting & Hashing

This is the mechanism we use to protect the privacy of users' mobile numbers on-chain at Ultimate Digits.

Ultimate Digits Hashing Rule

Preliminary Steps

  1. Normalize the data, remove any spaces, and strip any non-numeric characters from the mobile number.

  2. Ensure the mobile number has a consistent format. Since we’re targeting international numbers, we always use the full international version. E.g., +1 123 456 7890 becomes 11234567890.

Ultimate Digits Extraction

Extract the last n digits from the mobile number where n is a predetermined value (for example, 4). This is referred to as the 'Ultimate Digits'.

Salting

Combine the 'Ultimate Digits' with a user-specific salt. The salt can be derived from the user's crypto address or another unique user-specific identifier (randomized salting pattern). The salt ensures even if two users have the same 'Ultimate Digits', their hashes will differ.

SaltedValue = Ultimate Digits + Salt

Hashing

We use a cryptographic hash function to hash the SaltedValue. We use the keccak256 hash function (standard for Ethereum).

UltimateDigitsHash = keccak256(SaltedValue)

Storing on the Blockchain

Store the UltimateDigitsHash on the blockchain. This value can be used for verification without revealing the actual mobile number.

Verification

  1. When a user wants to verify or change their number, they'll undergo the same process to generate a new hash.

  2. The newly generated hash is then compared with the one on-chain to confirm a match.

Implementation Example

  1. Suppose a user has the mobile number "11234567890" and their Ethereum address (used as a salt) is "0xabc...123".

  2. The last 4 digits (Ultimate Digits) are 7890.

  3. Salted value becomes 7890abc...123.

  4. Hash the salted value with keccak256 to get UltimateDigitsHash.

  5. Store this hash on-chain.

Last updated