# VirtualMaster

TIP-1022 master registration utilities.

[TIP-1022](https://docs.tempo.xyz/protocol/tips/tip-1022)

These utilities expose deterministic hashing and bounded salt mining helpers for
`registerVirtualMaster(bytes32 salt)` without introducing any extra hashing dependency.

## Examples

```ts twoslash
import { Address, Hex } from 'ox'
import { VirtualMaster } from 'ox/tempo'

const registration = {
  address: Address.from(
    '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
  ),
  salt: Hex.from(
    '0x00000000000000000000000000000000000000000000000000000000abf52baf'
  )
}

const registrationHash =
  VirtualMaster.getRegistrationHash(registration) // keccak256(address || salt)
const masterId = VirtualMaster.getMasterId(registration) // bytes [4:8] of the hash
```

## Functions

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`VirtualMaster.getMasterId`](/tempo/reference/VirtualMaster/getMasterId) | Derives the 4-byte TIP-1022 `masterId` from a master address and salt. |
| [`VirtualMaster.getRegistrationHash`](/tempo/reference/VirtualMaster/getRegistrationHash) | Computes the TIP-1022 registration hash for a master address and salt. |
| [`VirtualMaster.mineSalt`](/tempo/reference/VirtualMaster/mineSalt) | Searches a bounded range of salts for the first value that satisfies TIP-1022 PoW. |
| [`VirtualMaster.mineSaltAsync`](/tempo/reference/VirtualMaster/mineSaltAsync) | Searches for a salt that satisfies TIP-1022 PoW using parallel workers and WASM-accelerated keccak256. |
| [`VirtualMaster.validateSalt`](/tempo/reference/VirtualMaster/validateSalt) | Validates that a salt satisfies the TIP-1022 32-bit proof-of-work requirement. |

## Types

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`VirtualMaster.Salt`](/tempo/reference/VirtualMaster/types#virtualmastersalt) | A valid salt input for TIP-1022 master registration. |
