What is blockchain?
A blockchain is a list of data records that operates as a decentralized digital ledger. Data is stored in blocks in chronological order and protected using cryptography.
The first blockchain model was created in the early 1990s, when computer scientist Stuart Haber and physicist W. Scott Stornetta decided to use cryptography on the blockchain to protect digital documents from tampering.
Their work inspired many programmers and cryptography enthusiasts, eventually leading to the creation of Bitcoin as the first decentralized electronic money system (or simply the first cryptocurrency).
Although blockchain technology is much older than cryptocurrencies, its potential was only realized after the advent of Bitcoin in 2008. Since then, interest in it continues to grow every day, and cryptocurrencies are becoming increasingly accepted.
Blockchain technology is primarily used to record cryptocurrency transactions, but it is also suitable for different types of digital data and can perform a variety of tasks. The oldest, most secure and popular blockchain network is Bitcoin, which combines cryptography and game theory.
How does blockchain work?
In the context of cryptocurrencies, a blockchain consists of a stable chain of blocks, each of which contains a list of previously confirmed transactions. Because the blockchain network is maintained by many computers around the world, it functions as a decentralized database, or ledger. This means that each participant (node) stores a copy of the blockchain data and interacts with other nodes to confirm that the information in the blocks matches.
Thus, blockchain transactions occur on a global peer-to-peer network, and this is what makes Bitcoin a decentralized digital currency that has no restrictions and is censorship resistant. Additionally, most blockchain systems do not require trust and are not controlled by a single governing body.
At the core of almost every blockchain is a mining process based on hashing algorithms. Bitcoin uses the SHA-256 algorithm (256-bit secure hashing algorithm). It accepts an arbitrary length input and generates a fixed length output. The output is called a hash and, in this case, is always 64 characters (256 bits).
The same inputs will lead to the same output no matter how many times the process is repeated. However, if you change the input data slightly, the output will be completely different. Due to this, in the world of cryptocurrencies, most hash functions are deterministic and unidirectional.
Unidirectionality means that it is almost impossible to calculate the input from the output data. One can only guess what was at the input, but the chances of guessing this information are extremely low. This ensures the security of the Bitcoin blockchain.
Let's look at how blockchain works using a simple transaction as an example.
Let's imagine that Alice and Bob have several bitcoins on their balance sheets. Alice owes Bob 2 bitcoins.
To send them, Alice transmits a message with the transaction to all miners in the network.
In this transaction, Alice tells the miners Bob's address and the amount of Bitcoin she would like to send, as well as a digital signature and her public key. The signature is made using Alice's private key and confirms that she is the owner of these coins.
Miners must verify the validity of the transaction, after which they combine it with other transactions and try to create a block using the SHA-256 algorithm. The output must start from a certain number of 0s, which depends on the so-called “difficulty” and computing power of the network.
To get an output hash with the correct number of 0s at the beginning, miners add a so-called nonce number to the block before running the algorithm. Since a small change in the input completely changes the output, miners try different combinations until they find the desired hash.
After creating a block, the miner broadcasts it to other miners. They then check the validity of the block so they can add it to their copy of the blockchain and complete the transaction. Miners also include the output hash of the previous block in the block in order to link all the blocks together into a kind of chain, that is, a blockchain. The blockchain trust system is built on this mechanism.
Each miner stores a copy of the blockchain on his computer, and the degree of trust in the blockchain depends on the invested computing power and its length. If a miner changes a transaction in a previous block, the output hash of that block will also change, causing all hashes after it to change. Then the miner will have to redo all the work in order for his blockchain to be accepted as valid. To deceive the system, an attacker would need to take over more than 50% of the network's computing power, which is almost impossible. Such network attacks are called 51% attacks.
A model in which the production of blocks is carried out by the work of a computer is called Proof-of-Work (PoW). There are other models, such as Proof-of-Stake (PoS), that do not require much computing power and consume less power, offering scalability to many users.
