Mining for Bitcoin
Part 1 – A peek into the world of Bitcoin
By Rahul Anand. R (M.Sc. Theoretical Computer Science , 2017-2022)
Illustration by Eshwar K (B.E. Computer Science Engineering , 2015-2019)
Imagine spending about 2.26 lakhs INR to buy one unit of a currency that does not even exist, at least in the physical sense of the word. That’s bitcoin. Doesn’t exist anywhere but only on paper or rather, on computers. You can’t see it or hold it in your hand like the fiat currency that we are accustomed to. Yet, it is touted to be the next big thing in the financial system of the world.
Bitcoin is a type of cryptocurrency invented by a programmer/ group of programmers under the pseudonym Satoshi Nakamoto in 2009. Cryptocurrencies are virtual currencies that have techniques of cryptography at their core, which are used to facilitate transactions. Bitcoin is perhaps the most commonly known cryptocurrency but there are a lot more of them.
Bitcoin works with cryptography at its core. Without cryptography, it is virtually nothing. To understand how bitcoin works, we need to delve deeper into concepts such as private and public keys, transaction chain, blockchain, cryptographic hash functions etc.
Bitcoin is an entirely decentralised economic system. That is, all the transactions and records are not stored in a single server or computer, like it is usually the case with banks. Rather, it works on peer to peer distribution system. Sounds familiar? That’s how torrent downloads work, based on peer to peer distribution. In case of bitcoin, all the information there is, is stored on every node in the network which makes it almost impossible for a Government or any other institution to take away its value or control its flow. Anything such as what happened on 8 November 2016 here in India is almost certainly eliminated.
Now, to understand how the bitcoin works, let us follow its journey from one user to another. For example, Ram wishes to pay Shyam using bitcoin. Ram would have all his bitcoin stored in a bitcoin wallet (like the wallets that we use for fiat currency). For paying, Ram would have to announce that he wishes to transfer a certain amount of bitcoin to Shyam, to all the nodes in the network. Some of the nodes, called “miners”, collect many such transactions (the collection of many such transactions is called a Block) and add it to a distributed ledger called Blockchain. When a transaction gets added to the blockchain, it is over. Sounds, simple, right? It certainly is not.
Let me list out what all could possibly go wrong in this process. First, how can the miners be sure that that it is really Ram who is announcing the transaction? This problem of authentication is solved using a pair of keys – private and public keys. Every holder of bitcoin has a unique private key assigned to them. When the user wishes to announce a transaction, they input the private key and the transaction message which combine to form a public key which can be verified by the nodes in the network. This key combination works like a digital signature and is impossible to replicate, thus verifying the authenticity of the user.
Now that it is made sure that Ram announced the transaction, how do the miners know that Ram is not spending bitcoin that he does not even possess? To eliminate this problem, each user is required to mention previous transactions in which he received bitcoin, equal to the amount of transaction, while announcing. If Ram wishes to pay Shyam less than what he received from a previous transaction, he should credit the change to himself. This way, each transaction contains records of previous transaction. This is called the transaction chain and verifies the authenticity of the bitcoin.
After the authenticity of the user and the transaction is verified, a miner picks it up from there. The miner may choose any transaction to include in his block. A transaction fee for the miner is optional, which can be included to better the chances of the transaction getting included faster. If the transaction is picked up by more than one miner and added twice to the ledger, wouldn’t that credit the receiver twice? This problem is solved by solving a problem. All the miners take part in a race to solve a problem and whoever comes first, gets to add the “block” of transactions to the “blockchain”. But the problem is not a simple one. Cryptography comes to the fore here. A special kind of mathematical function called cryptographic hash function called SHA-256 is required to be solved by the miners. A cryptographic hash function can be understood by considering a function f(x)=y. It is easy to find ‘y’ when ‘x’ is known. But the reverse, finding ‘x’ when ‘y’ is known is difficult and requires a lot of guesswork. SHA-256 is like this example, only a lot more complex, since it contains 256 characters which are a mix of 0s and 1s. Each block is encrypted into a hash containing 256 characters using this algorithm. This means that the possible number of hashes is 2 raised to the power of 256. The input for a block also contains the hash of the previous block to determine the sequence of transactions. The miners are required to guess the exact input and whoever does that first, gets to add the block. This is one of the founding principles of bitcoin called “proof of work”. After the transaction is added to the blockchain, the transaction is complete. But if Ram has a malicious intent and wants to feign his transaction with Shyam by somehow feeding only him blocks containing his transaction, while feeding a totally different transaction to the rest of the network, what can be done? Proof of work saves the day here. The bitcoin system works by considering only the longest chain of blocks to be true. This is since the probability of a single miner solving the hash continuously many times is colossally high, making fraud very difficult. So, Ram would have to compete with every other miner to broadcast his own version of transactions continuously and win every time.
An important aspect involving miners is that every time one of them adds a new block, they are rewarded 12.5 units of bitcoin created out of thin air. This is the only way new bitcoins are added to the system. Initially, the reward was 50 btc and that value is supposed to halve every four years. Following this decrease, the total number of bitcoin units that can ever exist is fixed at 21 million. This is unlike fiat currency, which is printed as and when need arises, causing inflation. The bitcoin economy, on the other hand, is bound to deflate due to the pre-defined number of units.
For a user to perform transactions with bitcoin, all they need is some bitcoin, a bitcoin wallet and a computer. Bitcoin has many advantages over fiat currency. It provides a high level of anonymity since the transaction messages require only account numbers of the senders and receivers. This, coupled with a VPN, provides extreme levels of anonymity. But this facet of bitcoin has made it the most popular way of performing illicit transactions using the Dark Web, mostly for drugs.
As mentioned earlier, Bitcoin is not the only cryptocurrency available. The alternative cryptocurrencies, blockchain and other developments in the world of cryptocurrencies will be dealt with in the following article.
RAHUL ANAND R (M.Sc. THEORETICAL COMPUTER SCIENCE, 2017-2022) is an amateur writer trying to get the best out of himself. He loves watching movies and TV shows, reading books and listening to music. He is a big fan of AR Rahman.
ESHWAR. K (B.E COMPUTER SCIENCE ENGINEERING, 2015 – 2019) is obsessed with photography and designing. He is enthusiastic about exploring places in his bike and learning through travelling. He also has his eyes set on recent developments in the field of computer science and new business startups