# Bitcoin Address Generator

# Bitcoin Address Generator

**Disclaimer:**Addresses are only for demonstration purposes, for productive use it is recommended to use more secure generation algorithms.

## Step 1: Private Key Generation

Private keys can be any 256 bit (32 byte)
value from 0x1 to 0xFFFF FFFF FFFF FFFF FFFF FFFF FFFF
FFFF BAAE DCE6 AF48 A03B BFD2 5E8C D036 4140 .
The total possible number of private keys is therefore 2

^{256}or 1.16 x 10^{77}.
This private key is in hexadecimal or base 16. Every 2 digits represents 8 bits or 1 byte. So,
with 64 characters, there are 256 bits total.

## Step 2: Full Public Key Generation

The first thing that needs to be done is to apply the ECDSA (Elliptic Curve Digital Signature
Algorithm) to the private key.
An elliptic curve is a curve defined by the equation y

^{2}= x^{3}+ ax + b with a chosen a and b. There is a whole family of such curves that are widely known and used. Bitcoin uses the secp256k1 curve. After applying the ECDSA to the private key, it generates a 64-byte integer. This consists of two 32-byte integers that represent the X and Y of the point on the elliptic curve, concatenated together.
Finally the bytes 0x04 are added at the start of the public key to get the full Bitcoin public
key.

This public key contains a prefix 0x04 and the x and y coordinates on the elliptic curve
secp256k1, respectively.

## Step 3: Compressed Public Key Generation

The public key is some point (X, Y) on the curve.
For each X there are only two Ys that define the point which lies on that curve.
Let’s keep X and the sign of Y. Later, Y can be derived.
The specifics are as follows:

- Take X from the ECDSA public key
- Add the 0x02 if the last byte of Y is even or the byte 0x03 if the last byte is odd

## Step 4: Encrypting the public key

First SHA-256 needs to be applied to the public key, and then apply RIPEMD-160 to the result.
The order is important.
SHA-256 and RIPEMD-160 are two hash functions.
This generates a 160-bit integer, which will be used for further modifications.

## Step 5: Adding network byte

The Bitcoin has two networks, main and test.
The main network is the network used to transfer the coins.
The test network was created to test new features and software.

## Step 6: Checksum

Next Step is to calculate the Checksum of the key from step 5.
The idea of checksum is to make sure that the data wasn’t corrupted during transmission.
The wallet software should look at the checksum and mark the address as invalid if the checksum
mismatches.
To calculate the checksum of the key, SHA-256 gets applied twice and then take the first 4 bytes
(8 digits) of the result.

## Step 7: Get Address

Finally concatenate the key from Step 5 and the checksum.
That’s it! That’s the wallet address for the private key at the start of the article.
But Bitcoin addresses are encoded in Base58.
Base58 represents a reduced alphabet, which doesent include chars that can lead to confusion
(e.q. I l, 0 O or similar).
The Base58 alphabet consists of the following chars:

123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ.

123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ.

## Step 8: Bech32 Address

Bech32 also known as bc1 addresses are the new standard for Bitcoin addresses as of 2020.
They are more efficient and easier to read and write down.
The Bech32 address is a combination of the network byte, the public key and the checksum.
The Bech32 alphabet consists of the following chars:

0 2 3 4 5 6 7 8 9 a c d e f g h j k m n p q r s t u v w x y z.

0 2 3 4 5 6 7 8 9 a c d e f g h j k m n p q r s t u v w x y z.

## Step 9: Result

The goal of the Bitcoin Address Generator is to provide you a comprehensible understanding of how a bitcoin address is generated from a secret key. The whole process of generating a private key and a corresponding bitcoin address can be complete automatically with the Autocomplete Button. The Tool provides an explanation for the generation of the bitcoin address with eight detailed steps. With the clear inputs button, the fields and inputs can be reset.