A blockchain is a distributed database or ledger that is shared among the nodes of a computer network. As a database, a blockchain stores information electronically in digital format. Blockchains are best known for their crucial role in cryptocurrency systems, such as Bitcoin, for maintaining a secure and decentralized record of transactions. The innovation with a blockchain is that it guarantees the fidelity and security of a record of data and generates trust without the need for a trusted third party.
One key difference between a typical database and a blockchain is how the data is structured. A blockchain collects information together in groups, known as blocks, that hold sets of information. Blocks have certain storage capacities and, when filled, are closed and linked to the previously filled block, forming a chain of data known as the blockchain. All new information that follows that freshly added block is compiled into a newly formed block that will then also be added to the chain once filled.
A database usually structures its data into tables, whereas a blockchain, as its name implies, structures its data into chunks (blocks) that are strung together. This data structure inherently makes an irreversible timeline of data when implemented in a decentralized nature. When a block is filled, it is set in stone and becomes a part of this timeline. Each block in the chain is given an exact timestamp when it is added to the chain.
HOW A BLOCKCHAIN WORKS
To understand how a blockchain works, we’ll use it in the context of cryptocurrencies (digital currencies), which utilize blockchain technology, more specifically, Bitcoin, as it is the oldest and most popular cryptocurrency in the world.
● A blockchain consists of a secure chain of blocks, each block holding a list of transactions that were previously authenticated. Since a multitude of computers distributed across the world manage the blockchain network, it acts as a decentralized database (or ledger). This means that a copy of the blockchain data is maintained by each participant (node), and they communicate with each other to ensure that they are all on the same page (or block).
● Thus, blockchain transactions take place within a peer-to-peer network, and this is what makes Bitcoin a borderless, censorship-resistant and decentralized digital currency. Furthermore, since they do not need any kind of trust, most blockchain systems are considered trustless. No single authority is in control of Bitcoin.
● The process of mining, which relies on hashing algorithms, is a core part of almost every blockchain. The SHA-256 algorithm (Secure 256-bit hash algorithm) is used by Bitcoin. It takes an input of any length and generates an output that has the same length at all times. The output generated is called a "hash" and is always made of 64 characters (256bits).
● So, the same input, no matter how many times the process is repeated, would result in the same output. But the output will change entirely if a minor change is made to the input. As such, hash functions are deterministic, and most of them are built as a one-way hash function.
● Being a one-way function means that to calculate the input from the output is almost impossible. One can only guess what the input was, but the chances of guessing it correctly are extremely low. This is one of the reasons why the blockchain of Bitcoin is secure.
● Now that we know what the algorithm does, with a simple example of a transaction, let's see how a blockchain works. Let’s imagine that we have Radha and Krishna along with their Bitcoin balance, and that Radha owes Krishna 3 Bitcoins.
In order for Radha to send the 3 Bitcoins to Krishna, she broadcasts to all the miners in the network a message with the transaction. In that transaction, along with a digital signature and her public key, Radha gives the miners Krishna's address and the amount of Bitcoins she would like to send. The signature is made with the private key of Radha and the miners can verify that Radha is, in fact, the owner of those coins.
● Once the miners are assured that the transaction is legitimate, they will place it together with several other transactions in a block and try to mine the block. To do this, the block is put through the SHA-256 algorithm. To be considered legitimate, the output must start with a certain amount at 0's. The amount of 0s required depends on what the "difficulty" is, which varies based on how much computing power there is on the network.
● The miners add what is called a "nonce" into the block before running it through the algorithm in order to generate an output hash with the desired amount of 0's in the beginning. Since the output is totally changed by even a slight tweak to the input, the miners use high-performance computers to attempt many random nonces before they find a valid output hash. This system of making computers run to create blocks by solving mathematical problems is referred to as Proof-of-Work (PoW).
● After mining, the miner broadcasts the newly mined block to all the other miners. They then verify that the block is legitimate so that they can add it to their copy of the blockchain and complete the transaction. But the miners must also provide the output hash from the previous block in the chain, so that all blocks are joined together, hence the name ‘blockchain’.
● A copy of the blockchain is on the computer of every miner and everyone trusts the longest blockchain, i.e., the blockchain that has the most computational work put into it. If a transaction in a previous block is changed by a miner, it will change the output hash for that block, which will lead to changes in every successive hash also since blocks are linked with hashes. In order to make anyone recognise his blockchain as the correct one, the miner will have to redo all of the work. So, if a miner were to cheat, he would need more than 50% of the computing power of the network, which is very unlikely. Network attacks such as this are called 51% attacks.
BENEFITS OF BLOCKCHAIN
The primary benefit of blockchain is as a database for recording transactions, but its benefits extend far beyond those of a traditional database. Most notably, it removes the possibility of tampering by a malicious actor, as well as providing these business benefits:
● Time savings. Blockchain slashes transaction times from days to minutes. Transaction settlement is faster because it doesn’t require verification by a central authority.
● Cost savings. Transactions need less oversight. Participants can exchange items of value directly. Blockchain eliminates duplication of effort because participants have access to a shared ledger.
● Tighter security. Blockchain’s security features protect against tampering, fraud, and cybercrime.
While the Bitcoin system is the best-known application of blockchain technology, there are thousands of cryptocurrencies that are built on the back of this emerging technology. While it remains to be seen if bitcoin will succeed in supplanting other forms of traditional payment methods, the applications of blockchain technology are growing fast, and proponents say they may lead to dramatic changes across industries.