tl:dr: The WIF is the master private key. The addresses are different things entirely but are derived from that.
[I] am looking to understand how the WIF relates to the public addresses
In Bitcoin, Wallet Import format (WIF) is a way of writing private keys. The numbers that give you power to spend money.
WIF is used to make backups of keys and when replacing one wallet program with another from a different developer.
However addresses are abstractions of locking scripts. These locking scripts are the parts of transactions in the blockchain that effectively specify who is allowed to spend a specific amount.
For P2PKH outputs the address would be based on a hash of a public key.
Addresses are used to tell payers how they can construct an output in a transaction that will pay you money.
Note that WIF and addresses never appear in the Bitcoin blockchain.
Derivation of addresses from keys
There are other questions here about Bitcoin address generation that may be helpful however my rough understanding of the process is as follows
- When you create a wallet, a seed is created. This is a randomly generated number.
- From that seed we can use HMAC-SHA512 to generate
- A master private key
- A master public key
- A master chain code
- From those, each time we want to receive a payment, we can use BIP-32 and a chosen derivation-path to create the next in a series of hierarchical deterministic (HD) private and public keys.
- from each of those public keys we can create an address suitable for
use with one of the standard Bitcoin locking scripts.
for P2PKH locking scripts the process is
| SHA256,RIPEMD160 (AKA HASH160)
Public key hash
| Base58Check encode with 0x00 prefix
When you have a long string of numbers and letters and are wondering what sort of thing it is, this may help.
||Example value (DO NOT USE)
|0 0x00 "1"
||Pubkey hash (P2PKH address)
|5 0x05 "3"
||Script hash (P2SH address)
|128 0x80 "5"
||Private key (WIF, uncompressed pubkey)
|128 0x80 "K"/"L"
||Private key (WIF, compressed pubkey)
|4,136,178,30 0x0488B21E "xpub"
|4,136,173,228 0x0488ADE4 "xprv"
||BIP32 private key
|111 0x6F "m"/"n"
||Testnet pubkey hash
|196 0xC4 "2"
||Testnet script hash
|239 0xEF "9"
||Testnet Private key (WIF, uncompressed pubkey)
|239 0xEF "c"
||Testnet Private key (WIF, compressed pubkey)
|4,53,135,207 0x043587CF "tpub"
||Testnet BIP32 pubkey
|4,53,131,148 0x04358394 "tprv"
||Testnet BIP32 private key
||Bech32 pubkey hash or script hash
||Bech32 testnet pubkey hash or script hash
Prefixes are given as decimal, hex and resulting symbolic values.