CPSC 3640 / CPSC 5400

Decentralized Payments, Contracts, and Finance for Humans and AI

Hands-On Component: P2PKH Address Calculator

Lecture 5 · Wednesday, September 16, 2026

This calculator goes through each step that computes a P2PKH address from a public key.

Testnet4 P2PKH address calculator

Example public key: 03f8a6959facf2896be1d167115e814a330298b91bd32161cef753e6a7cd78d556
Expected address: myofnF2NWgLAwZ6rDhx66LhA7eJkqs3FHZ
  1. Let pk be the public key.
  2. Compute h = SHA-256(pk).
  3. Compute pkh = RIPEMD-160(h). This is the public-key hash, or HASH160(pk).
  4. Prepend the Testnet4 version byte: p = 6f || pkh.
  5. Compute c = SHA-256(SHA-256(p)). First SHA-256: Second SHA-256:
  6. Take the first four bytes of c as the checksum, then compute b = p || c[0:4]. Versioned payload + checksum:
  7. Compute address = Base58(b).