The process by which a public key is obtained from a private key, and from the public key, addresses associated with UTXOs are derived, is carried out by the wallet. How does it work?
In a deterministic wallet, all private keys are derived from a single number called seed, for example:
9400aedeede8cba2241d2b13e0a7412fe7464245efe8db54b4484143c7814977e641284cb4e023a9b48e075d0137631540fbf97976f3bbd32961667da1f62c5f
The seed is a hexadecimal number generated from a random source.
The process of deriving addresses in a Bitcoin wallet from a seed involves a series of hash operations. These are the steps in this process:
seed → master private key → master public key → public key → address
1. The seed is transformed into a master private key through a hash algorithm called HMAC-SHA512;
2. The master private key is transformed into a master public key through elliptic curve multiplication (multiplying the private key by a constant point on the elliptic curve called the generation point);
3. Starting from the master private key as the root, algorithms derive a tree structure of private and public key pairs;
4. To generate a Bitcoin address, the public key is hashed using the SHA-256 algorithm. This number is then hashed again using the RIPEMD-160 function: each address is associated with a public key;
5. The construction of the address involves adding a version byte in front of the RIPEMD–160 hash and the checksum at the end. The checksum consists of the first 4 bytes of the SHA-256 hash of the public key. The final address is then built from the Base58 encoding of this byte string.
6. Base58Check encoding: to create a publicly shareable Bitcoin address, the previous output is encoded with “Base58Check”. This eliminates some characters that are often misunderstood by humans or look alike. The result is what we know as a Bitcoin address: bc1q6zjfr73jywxck3stj0rzl62ga94hyxgw9tfu8g
Thanks to this derivation process, a deterministic hierarchical wallet (with all its addresses) can be recovered from a single seed. This is one of the advantages of deterministic hierarchical wallets over non-deterministic wallets.
A Bitcoin address is an alphanumeric string, a long sequence of letters and numbers, necessary for sending and receiving bitcoin. The address must be communicated to the sender of the transaction to receive bitcoin. To simplify, we can compare a Bitcoin address to an IBAN code of a bank account or an email address to which to send email.