ABefore starting, it is essential to mention that this article is aimed at those users who possess certain knowledge about Bitcoin and the crypto world. So we recommend that you first review certain topics of this world in order for you to understand them. With this you will be very clear about the relationship they have with Bitcoin and the creation of addresses. Among these articles are the asymmetric cryptography, hash function, SHA-256 algorithms y ECDSA.
Now let's take a brief look at what a Bitcoin address is. You can take a look in our article What is a Bitcoin address? to expand your knowledge.
Well, in the world of cryptocurrencies, an address is an identifier, the place to which a certain amount of cryptocurrencies is associated and destined. Therefore, anyone who wants to send or receive cryptocurrencies will always need to have an address. For example, in Bitcoin public addresses generally look like this: 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa. As we can see they are a set of alternate letters and numbers whose length varies between 26 and 32 characters.
To create an address, a total of 9 steps are required, which we will explain in detail below.
Process to create a Bitcoin address
The process to create a Bitcoin address first starts with the generation of a private key. This will provide us with the exclusive use of the funds. From this, a public key is generated, which will allow us to share information with other people without putting our funds at risk. Obtaining the public key through the private key is due to the application of the algorithm ECDSA. A very efficient implementation of elliptic curve cryptography, where the curve is used as a generator point secp256k1 to get the public key.
Then, once this key pair is generated, the process of generating the public addresses of Bitcoin begins.
1.- Select the public key obtained from the previous process. That is, from the application of the algorithm ECDSA a the private key. Which should have an appearance similar to this one:
2.- Apply a hashing to the public key by implementing the algorithm SHA-256. This algorithm allows to generate outputs (outputs) of fixed extension from inputs (inputs) of variable extension, which are irreversible. So they are unidirectional and it is not possible to deduce the private key through the public one.
After applying the hashing function we will obtain a 256-bit stream:
3.- Hashear again the previously obtained output, applying in this case the algorithm RIPEMD-160. With which it produces we will obtain a 160-bit stream:
4.- Add the version byte used for Bitcoin's core network (0x00) in front of the output obtained from the RIPEMD-160 hashing algorithm application. With this we will obtain a Bitcoin address in hexadecimal format, which will look like this:
And by adding this byte it also allows to identify and distinguish Bitcoin addresses from other cryptocurrencies that also use the protocol.
5.- Perform the hash with the SHA-256 algorithm to the result obtained from RIPEMD-160. This step is necessary as a verification mechanism to verify that the Bitcoin address is spelled correctly.
6.- Apply the hash with the SHA-256 algorithm to the result of the previous hash. This step concatenates the address obtained. As already mentioned, the SHA-256 algorithm is applied twice as a verification mechanism.
7.- Choose the first 4 bytes of the last SHA-256 hash, which represent the Bitcoin address checksum. In this example they would be:
8.- Add the 4 bytes of the checksum of the previous point, to the extended hash RIPEMD-160 of point 4. This is a 25 byte Bitcoin binary address:
9.- Convert the result of the byte string using Base58Check encoding, used to encode Bitcoin addresses. So the byte string will be transformed into a string base58.
This is the most widely used format for Bitcoin addresses. So the encoding Base58Check converts the byte string to a set of uppercase and lowercase letters and numbers. This in order to make them easier to distinguish. Although as a whole they are still illegible characters and at first glance they are not cryptic.
This is the whole process whose term is to create a bitcoin address so that we can use it as we wish. All this process is also carried out with the Vanity Address, they are what this last case we do a generation by brute force in order to find a personalized address. Well, learn more about these types of addresses from our excellent article about Vanity Addres.