Bitcoin address test tool

This tool will help you to understand technically how a bitcoin address is created.

(note: 0 – 8 values are hexstring, 9 is string)

(any random 256-bit number from 0x1 to 0xFFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFE BAAE DCE6 AF48 A03B BFD2 5E8C D036 4140)
more info: Secp256k1
Public key type:
(copmpressed public keys must be 33byte and start with 02 or 03)
(uncopmpressed public keys must be 65byte and start with 04)
checksum calculation

How to create a Bitcoin address?

Creating a legacy Bitcoin address involves several steps that encompass the fundamentals of Bitcoin's underlying cryptographic mechanisms. Legacy Bitcoin addresses, also known as P2PKH (Pay-to-PubKey Hash) addresses, start with the number "1" and are derived from a user's public key. This guide aims to provide a clear, technical explanation of how to generate a legacy Bitcoin address from scratch.

Prerequisites

To follow this guide, you should have a basic understanding of cryptographic principles, particularly ECC (Elliptic Curve Cryptography), which is used to generate Bitcoin public and private keys, and hashing algorithms such as SHA-256 and RIPEMD-160.

Generate ECDSA Key Pair

Bitcoin uses the secp256k1 ECDSA (Elliptic Curve Digital Signature Algorithm) for its key generation. The first step is to generate a private key, which is simply a random number (d) within the range defined by the secp256k1 parameters.

  • Generate a private key: Select a random number `d` that is less than the secp256k1 field size (`0 < d < n`), where `n` is the order of the curve.
  • Generate the public key: Multiply the private key `d` by the curve's base point `G` to get the public key `Q`. The public key `Q` is a point on the curve, represented as `Q = dG`.
Public Key Hashing

Once you have the public key, the next step is to create a public key hash. This process involves using both the SHA-256 and RIPEMD-160 hashing algorithms.

  • SHA-256 hash of the public key: Compute the SHA-256 hash of the public key.
  • RIPEMD-160 hash of the SHA-256 hash: Take the result of the SHA-256 hash and then apply the RIPEMD-160 hashing algorithm to it. This produces a 20-byte hash, which is the Bitcoin address's public key hash (PKH).
Add Network Byte

Bitcoin addresses can signify different networks, like the main Bitcoin network or the testnet. For a legacy Bitcoin address on the main network, you prepend the PKH with a network byte. The main network byte is `0x00`.

  • Prepend network byte: Add the network byte to the start of the PKH.
Checksum and Base58Check Encoding

The next steps are to create a checksum and use Base58Check encoding to convert the binary data into a human-readable form.

  • Double SHA-256: Perform SHA-256 twice on the result of network byte + PKH.
  • Checksum: Take the first 4 bytes of the double SHA-256 result as the checksum. This helps in detecting typos or errors when the address is typed manually.
  • Append checksum: Add the checksum to the end of the network byte + PKH.
  • Base58Check encoding: Finally, encode the binary data (network byte + PKH + checksum) using Base58Check encoding. This encoding is used because it omits characters that might look similar, such as 0 (zero) and O (the letter O), to prevent confusion.
The Legacy Bitcoin Address

The result of the Base58Check encoding is your legacy Bitcoin address, which starts with a "1". This address can now be used to receive Bitcoin transactions.

Conclusion

Generating a legacy Bitcoin address is a detailed process that involves cryptographic operations and specific Bitcoin protocols like ECDSA, SHA-256, RIPEMD-160, and Base58Check encoding. Understanding these steps not only gives insight into how Bitcoin addresses are created but also underlines the security and thoughtfulness behind Bitcoin's design. While new address formats like SegWit (which start with "3" or "bc1") offer benefits like lower fees and better scalability, legacy addresses remain a fundamental part of the Bitcoin network.