Skip to content
LogoLogo

10. Proof of work and difficulty

  • Compact bits as in Bitcoin. A set sign bit, a zero mantissa, or overflow beyond 256 bits is invalid.
  • ASERT (aserti3-2d), anchored at genesis:
    exponent = ((parent.ts − genesis.ts − spacing × parent.height) × 65536) // halflife   (floor)
    shifts   = exponent >> 16;   frac = exponent & 0xFFFF
    factor   = 65536 + ((195766423245049·frac + 971821376·frac² + 5127·frac³ + 2⁴⁷) >> 48)
    target   = (genesis_target × factor) << shifts (or >> −shifts), then >> 16
    target   = clamp(target, 1, pow_limit);  expected_bits = compact(target)
    
  • Regtest uses no retargeting: expected_bits = genesis_bits.