Let’s deep dive into the process of how Bitcoin wallet addresses are generated.
Step 1: Generating A Private Key
Random numbers can be generated by a computer system in two ways:
Pseudo-Random Number Generation (PRNG)
The computer uses an algorithm to generate a random number from a seed/root value.
This generates a Pseudo-random / not truly random number because if we know the seed and the algorithm used to generate the random number, we can predict this number.
True Random Number Generation (TRNG)
The computer system uses physical processes to generate a random number.
These numbers are truly random because the equation governing the generation of these numbers is unknown/ incomputable.
Bitcoin software uses the underlying operating system’s random number generators to produce a 256-bits (32 bytes / 64 hex digits) long truly random number.
This is called the Private Key.

Step 2: Deriving The Public Key From Private Key
The public key is derived by the private key using an Elliptic Curve Cryptographic function that I’ve described in my below-mentioned post on Medium.
The Mathematics Behind Bitcoin
Please note that this is a One-Way Function.
This means that a Public Key can be derived from a Private Key, but vice versa can never be done.
A Public Key is 33 bytes / 66 hex digits long.
This can be shared with other uses to receive money on.
But 66 hex digits is a long number, isn’t it?
Let’s shorten it.

Step 3: Hashing With SHA256
A public key is shortened and hashed using SHA256 (another one-way hash function).
The result is 32 bytes / 64 hex digits long.
Step 4: Hashing With RIPEMD160
The previous SHA256 hash is shortened and hashed using another one-way hash function called RIPEMD160.
The result is 20 bytes / 40 hex digits long and is called the Public Key Hash (PKH).
This can be shared with other users instead of Public Keys.
Again, as it is a random string of characters, it is prone to typing errors.
Let’s fix this!

Step 5: Creating A Versioned PKH
A version number 00
is added to the PKH. The result is a versioned PKH. This is to tell that a number is a public key hash.
Let’s take a PKH.
5f2613791b36f667fdb8e95608b55e3df4c5f9eb
The version PKH will be:
005f2613791b36f667fdb8e95608b55e3df4c5f9eb
Step 6: Creating AÂ Checksum
The version PKH is hashed twice with SHA256 and the first four bytes of this result (called Checksum) are appended to the versioned PKH.
This checksum helps prevent typing errors.
The result of the above operation is 25 bytes (50 hex digits) long.
005f2613791b36f667fdb8e95608b55e3df4c5f9eb12181e60
00: Version
12181e60: Checksum

Let’s take a quick detour.
Hexadecimal encoding constitutes the following characters.
0123456789ABCDEF
Note that, hex digits are inefficient in representing bytes of data.
2 Hex digits = 1 byte = 8 bits of data
Another widely used encoding scheme is called base64 and it contains the following characters:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
1 base64 character = 6 bits of data
In order to prevent typing errors, we can create another encoding scheme by removing:
l & I (lowercase L, uppercase I)
0 & O (zero and uppercase O)
because they look similar.
Special characters (+ & / ) because while copying and pasting, they will prevent selecting the whole string by double-clicking it
After removing these 6 characters, we are left with 58 characters.
123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
These form the base58 encoding scheme.
Step 7: Base58 Encoding To Create An Address
Let’s base58 encode our previous result.
005f2613791b36f667fdb8e95608b55e3df4c5f9eb12181e60
00: Version
12181e60: Checksum
Remove the version byte 00
:
5f2613791b36f667fdb8e95608b55e3df4c5f9eb12181e60
Convert this to decimal:
2333040184766738101355977925681426545668075806022526574176
Divide the number by 58 repeatedly until the quotient is 0.
Store the remainders from this process.
12 22 10 24 45 37 11 39 54 21 14 43 19 34 1 16 39 8 18 48 38 42 4 14 23 46 38 7 46 46 5 39 8
Look up the table below for corresponding characters for each remainder.
This results in the following characters:
DPBRneCgwNFkLb2Hg9Kqfj5FQof8oo6g9
Add 1 for each removed version byte 00
 :
DPBRneCgwNFkLb2Hg9Kqfj5FQof8oo6g91
Reverse the characters to obtain the final result:
19g6oo8foQF5jfqK9gH2bLkFNwgCenRBPD
This is the final Address that is short, typing-error proof, and can be shared with others to receive funds.
And this is how Bitcoin Wallet Addresses are generated from pure randomness!