Calculating Solutions

Overview

OP_NET miners search for SHA-1 near-collisions with the epoch's checksum root. The algorithm combines the checksum root, the miner's public key, and a random salt, then hashes using SHA-1 to find the best match.

The SHA-1 Mining Algorithm

The algorithm objective is to maximize matching_bits, which represents the number of identical bits between the computed hash and the target checksum root. The mining process iterates through salt values, retaining the solution that yields the highest bit match count.

Input Data

  • Checksum Root from previous epoch's final block.
  • Miner's Public Key.
  • Random 32-byte Salt.

Algorithm

The following diagram outlines the algorithm:
Mining Algorithm 1. Obtain checksum root 2. Generate 32-byte salt 3. Compute SHA-1 hash hash = SHA1(checksum_root + public_key + salt) 4. Count matching bits matching_bits = count(hash, target_pattern) 5. Better than best? Yes Save solution No 6. Adjust salt and repeat LOOP
  1. Obtain checksum root from completed epoch.
  2. Generate random 32-byte salt.
  3. Compute SHA-1 hash:
    • hash = SHA1(checksum_root + public_key + salt)
  4. Count matching bits against target:
    • matching_bits = count_matching_bits(hash, target_pattern)
  5. If better than current best, save solution.
  6. Adjust salt and repeat.
Computational Work
Finding competitive solutions requires significant computational effort. Miners might generate millions of attempts before finding a high-quality collision.

Epochs to Blocks

Nodes use the formula below to establish the deterministic mapping between epochs and blocks. This allows all participants to independently calculate which blocks belong to each epoch:

Epoch N = (N × 5) through (N × 5 + 4)
Where N is the Bitcoin block.