# Salting & Hashing

**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.&#x20;

*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.&#x20;

**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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ultimatedigits.com/salting-and-hashing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
