A TREATISE ON BITCOIN

- Khalid Riyaz , Journal Club

2017-08-06

Cultural


**READ THIS BEFORE PROCEEDING** :
One of the most valuable traits a soldier or a student can have. Patience. Sometimes patience is the key to victory. So buckle up to descend into this jungle of Cryptocurrency.
Warning: People with health concerns who are broke may find this hazardous. Proceed at your own risk.
Also, since this epic is quite long, you can scroll down to the bottom for a TL;DR, if too lazy to read. A short and crisp summary. Read it carefully to understand the gist of the article.


The World for all it’s intricacies works upon complex systems which have been around since time immemorial. The great journey of Human endeavour is vastly accompanied by certain mechanisms, certain frameworks kept in place to make our lives easier. Our belief in these systems is what makes them work. We believe in the government to govern us, and once it steps over the limit of gross incompetence into the clutches of Corruption, it all culminates in an episodic Civil war, Governments are replaced. Similarly, we BELIEVE in the value of Gold, or the Indian ₹, which is merely a piece of paper. One fateful day if enough people in the world are collectively brainwashed into thinking there is no value in that piece of paper, the Rupee will be extinct. All money is the work of imagination. They function because of a collective agreement that they will, although this doesn't mean they have no power, just that it resides in mass belief.

Now coming to what is perhaps the newest addition to the empty shells we call currency - Cryptocurrency. More specifically Bitcoin (although there are others such as Etherum, the newest addition Ubiq etc.). Cryptocurrency is one that solely exists as a string of numbers inside a computer and Bitcoin, is a currency of the Internet : a distributed, worldwide and decentralised digital money. Unlike traditional form of currencies like the Rupee, this is not controlled or issued by a central authority whatsoever. There is no third party involvement from a bank, or the government etc. Essentially, with Bitcoin, you can be your own bank.

Before we begin to unravel the mechanics of this seemingly weird stuff, let’s talk a bit about how it came into existence and why?

Some background.

For starters, there already is digital money. That’s what you use in online transactions. In fact, it’s estimated that only about 9% of the world’s money is in physical form with the rest being digital. So why are we so excited about Bitcoin?

Speaking of Cash, it is the only form of payment which can actually be made between two parties directly. You can go to our very own Yumpy’s, ask for a Butter Garlic fries and pay the amount in cash to the vendor, direct and frictionless without intervention from a 3rd party. However, if you used PayTM, they charge you or the vendor for the transaction (very less but measurable). Similarly, if you have to book an online Movie ticket using credit card, you have to pass through the bank or the card company. For any online transaction you have to pass through a payment processor of sorts, who is basically a middleman increasing transaction costs and also limiting their size.

Since the 80s, many techies have been trying to eliminate the middleman completely and replicate the frictionless and direct benefits of a cash payment online. There was no way to do this. The major issue was that of a problem called ‘Double Spending’. If you have a digital copy of a picture, you can replicate it any number of times and send it to thousands of people online. This ease of copying is what takes billions away from the movie industry, and almost destroyed the music industry. Likewise, for money that exists entirely online, nothing’s stopping anyone from acting similarly. There was no way around this problem without using a middleman.

When it was all but given up, came along Satoshi Nakamoto, the unknown and mysterious inventor of Bitcoin - the first and most significant cryptocurrency, with a paper titled “Bitcoin: A Peer-to-Peer Electronic Cash System”. For all we know, “Satoshi Nakamoto” might be a pseudonym for a group of coders. Interestingly, Satoshi never intended to invent a new currency, but rather a system or platform for functioning of such a cryptocurrency.

The idea.

The mediation from a 3rd party has costs, which they exact from you - the involved party. This limits the transaction size, increases transaction costs and is a hassle for non-reversible payments (It takes quite some effort for a refund on your Amazon cancellation, doesn’t it? And that might be charged as well. Amazon actually makes it a lot easier, which is not the case for other services). For authentication, you are forced to give a lot of information to the vendors which you might otherwise not give. Some fraud is accepted as unavoidable. These frauds and uncertainties could be avoided by using physical cash, but there is no system in place to conduct transactions across networks without a trusted third party.

So, what we need is an electronic payment system based on computational cryptographic proof instead of trust, allowing the involved parties to transact without a trusted 3rd party. (The aim is to essentially automate the 3rd party. In a nutshell, develop some computation that mathematically governs the transaction. Math doesn’t lie.)

What was proposed was a ‘Peer-to-peer’ decentralised timestamp server to generate computational proof of the chronological order of transactions. This was the solution to the double-spending problem. What this meant was that instead of a single authority to monitor all transactions, a wide network of volunteers (who are also the users) will govern them while making sure no one is defrauding the system. And the system is secure as long as the majority of nodes in the network (which is made of the computers or computational resources the volunteers are using) are “Honest” and control more CPU power than any cooperating deceptive group(s).

Sounds too complex? Let me try and put this to you in plain terms.

How does a rich dude make sure no one is embezzling his funds, or defrauding them in any of his businesses? Well, he keeps records. We are doing something similar here. Imagine an enormous digital record which anyone with access to the internet can look at. It’s open for everyone to see, and nobody’s in charge. It’s actually kept alive by a network of thousands of computers across the world, voluntarily, with their combined power more than most of the Supercomputers of the world put together. These owners of the computers are who we call ‘Miners’ and they get paid for their services (Ahem..in Bitcoins). All the information going in is permanent, with each computer keeping a copy of the record to ensure that nothing’s altered. If anyone wants to hack the system, they would have to hack all the computers on the network (which the finest of them have tried, including the NSA, but failed).

For any new piece of information added, which is called a “Block”, the approval of all computers is essential and only done so if they have enough mathematical proof (more on this in a second) that it is correct information. This is then stacked on top of the chain of information existing previously, and hence the platform, or rather, the system is called the “Blockchain”. Each block also contains information about the previously confirmed block, with them being linked together.(So basically, each block is being built on top of all the previous ones). This feature is carried on all the way deep into the chain, and hence, the further down the block is, the harder it is to alter the data and the more permanent it becomes, because to change that particular piece of data, the attacker has to alter all the blocks coming after it, which is an exercise in futility as it requires monumental computational power.
In this way, transactions are sequenced to make them secure.

Now let’s talk about Mining.

Miners are the workforce which help keep the infrastructure of this entire system running and are paid in newly minted Bitcoins. It’s all crowd-sourced. The Bitcoin creators have set a few rules and put them in the code, and every person runs software that works under these rules. If someone alters the software, everyone else see that. And hence you can’t meaningfully alter the rules without mass approval. This collective agreement is what defines Bitcoin. If you defer from this agreement (which is mathematically coded) you will be sidelined. I’ve been throwing around the words ‘Computation’ and ‘Math’, but what kind of operations are actually powering this voodoo stuff?

The Math

Before we begin, let me explain some quirky terms.

A ‘Hash’ function is one which maps some variable sized input to some fixed size output, we call hash values, and the process is called ‘Hashing’. Take for example, the string sequence “abcd”. Let’s assign positional values for the alphabets (eg: a=1, b=2 etc.). For example, suppose that a hash functions maps the string to a number which is the sum of the individual characters, which in this case is 10. You can see that the same hash value might have multiple inputs. Similarly, with enough trials it’s possible to map the hash value back to the original input value.

Hashing is commonly used in cryptography, storing passwords and databases. You can see that with a complex enough algorithm, you could create hash values that are characterised by:
1.) Impossible to map back to the input (Well, not impossible but most improbable)…Note that it’s different than Encryption in that, it can’t be mapped back to the input irrespective of whether the person has some privileged information, and
2.) Hash collisions where the same output has multiple inputs can be avoided.

One of the algorithms in wide use is the SHA algorithm (designed by the NSA). Other algorithm prevalent in computing is MD5(produces a 128 bit hash). What they do is put the original data in, and churn out a number which serves as a signature of the original data. In case of passwords, for one-way algorithms mapping to a unique hexadecimal number, people can hash the original data and check quickly if the output matches what it should, to verify integrity. Bitcoin currently uses the SHA-256 algorithm.
So, these work on the assumption that we can’t recreate the original data quickly from the output hash, yet you can check quickly enough.(This falls under a superset of problems called P vs NP problems, which is a beautiful pursuit on it’s own. Do check it out).

Mining is actually the computation of the hash of a block, which includes a reference to the previous block, a hash of a set of transactions, and a Nonce (this is sort of a buffer - pseudo random bits of information padded after the block to ensure you can’t replicate the same hash again, as you will see below).

The rules we talked about before? These rules govern what kind of hash values are allowed. These previously agreed upon dictums by the community detail what sort of hash values are supposed to be computed mathematically. And only once a requisite hash has been computed by a miner will it be added to the Blockchain, after the other miners check the authenticity and that whether or not it satisfies the rules. These folks have to solve a math problem to arrive at the necessary hash value, which are exceptionally hard to compute and such computations are done in the range of trillions per second. (It sort of is like a lottery ticket. The hash is the winning ticket, and the miners keep buying all the tickets with each one buying a ton of them each second. In the end, the one who finds the hash value gets the prize in the form of Bitcoins awarded for their efforts).

You might be confused in that, won’t hashing a block always provide the same output? Yes, and no. What the SHA does is, add some random data to each transaction block, called a nonce, so that you could not possibly get the same hash value again for a specific input. And the algorithm ensures that a very small change in the original data wildly changes the hash value.

An example of the problem might be to find a hash value at least, and close enough to a particular range. Imagine a numeric string of 32 bit characters. A One bit character would be numbers from 0 to 9. Two bit would be 00 to 99. Similarly three bit would be 000 to 999, and so on. As the number of bits increase, the count of numbers increases 10 fold. Now put all the numbers in a Universal set of tentative hash values. As you can see, 99% of the numbers in the set are 31 bits or longer, and 90% are 32 bit. Now, suppose the required hash value has to be close to a 29 bit number, the probability of finding that number in the first chance is 0.09%. The value is actually more constrained with being linked to the previous block, and it might be a complex alpha-numeral. Also, we need to consider how Bitcoin supports the SHA-256 algorithm (churns out a 256 bit signature of the input). Hence the chances to find it are really, one in a zillion. Thus it requires considerable computational power to come at a satisfactory hash value. Once you find it, it’s easy for others to verify that this number indeed maps to the original data. Thus they know that you’ve spent a lot of CPU power to find this number/string, and will accept your mined block. This is what’s called ‘Proof of work’, and confirms that you are not any malicious attacker. Any attackers will have to redo this for the block in the question, and all the subsequent blocks, which is a baffling task and a wasted effort.

Why not simply program more Bitcoins?

Simply because no will give a damn about you. The record is always being maintained, and anything out of what should be, is just ignored. It’s just like writing the number 100 on a blank paper and claiming that you’ve added ₹ 100 to your fortune. No one will believe you.

Where do Bitcoins come from?

Bitcoins are actually situated in the blockchain. When we say the miner is awarded bitcoins, nothing is actually being moved. He/She is just being given access to it. Each and every transaction is public, but Bitcoin allows you to remain anonymous. So no transaction can be traced back to you, should you desire.

Can this system be duped?

Bitcoin is not flawless. There always are 2 sides to the coin (Ahem! Excuse the bad pun). Of course, like anything else it can be cheated. But it’s strength lies in the fact that it’s tremendously hard to do so. Each node in the network has the value of a vote in the Blockchain. So, if more than 50% of the computation power in the network join hands, they can change the system and all the transaction details according to the whims of whoever is controlling them. This is widely known as the “51% attack”. But as you guessed, it’s frickin’ hard.

Why do you use cash?

For quick and small payments. You can buy a magazine, or a bar of chocolate from your local vendor. But online, you can’t quite do that. Most of the services online are part of a package or a subscription. You can’t selectively get access to that month’s magazine online, but you will have to subscribe for a period. Micro-payments are not possible currently (at least not far-reaching), and Bitcoins aims to change this. You no longer have to pay to the bank or any payment processing company. Bitcoin also grants you anonymity to perform any transaction, just like with physical cash.

Beauty of Blockchain

Blockchain has other implications than just revolutionising our spending. Since it’s a platform, it can be used for other things with the similar idea as well.

Consider identity for instance : Today you need multiple documents like your Passport, Aadhar card, Mark-sheets, Licence, Birth certificate, Marriage certificate, Bonafide certificates, Tax reports, Income reports, Employment history, Education history etc. to completely establish your identity as a person. But with Blockchain, all this data can be stored on it right from when you are born. Every milestone you pass will be registered on this record, and would be accessible to anyone who requires it. It removes any scope for Identity fraud, false certificates, Tax evasion etc. Employers can look at all your required information as they request it, and it could also be used for College admissions etc. Imagine the implications for Politicians, where the people can are only a click away from seeing all their history and records to make an informed decision. Lesser corruption as well.

Elections are expensive. Campaigning, workforce, setting up ballots etc. cost a lot of time, effort and money. But with Blockchain, you will soon be able to vote through your smartphone from the most secure platform ever devised in the history of humankind, at a fraction of the cost. All while retaining anonymity should you opt for it. You can make sure your vote is counted and it also eliminates voter fraud.

Blockchain will also usher in an era of true democracy. Now with the costs and effort for voting being almost eliminated, officials no longer need to hide behind closed doors to make important policy discussions, and the public can directly vote for all major issues. The birth of True Democracy and complete transparency for the Government.

Covfeve! Covfeve! Covfeve! The number of times I had to type that due to auto-correct made me more tired than this entire article. Thanks Don. So, go back to your boring lives now. What? That’s it. You expected some climactic ending culminating in an epic rant about the future and the magic of Bitcoin, didn’t you? No that’s it. Now go back to your dull life. Bye bye.

P.S and Tl;dr: For those of you wondering where is the Tl;dr. *Sigh*… You lazy ba***rds. I’m sure you are indeed, erudite enough to sit through an essay on an awesome technical marvel of our era. The average reading speed is 200 WPM. With a word count of 2998, you will merely spend 14.99 minutes of your lives. Geez. Scroll back up and read the article. There are some badass ideas up there. Go back up now.