Schoolkid fights, blockchain and smart contracts

So I’ve been trying to understand the whole blockchain thing better, since people nowadays seem to be wanting to use it for all kinds of contracts (even the investment bankers are taking interest, which suggests there’s some potential out there 😛 ).

One of the things I’ve been doing is to read this book (PDF) on Blockchain by Arvind Narayanan and co at Princeton. It’s an easy to read, yet comprehensive, take on bitcoin and cryptocurrency technologies, the maths behind it and so on.

And as I’ve been reading it, I’ve been developing my own oversimplified model of what blockchain and smart contracts are, and this is my take at explaining it.

Imagine that Alice and Bob are two schoolkids and they’ve entered into a contract which states that if Alice manages to climb a particular tree, Bob will give her a bar of chocolate. Alice duly climbs the tree and claims the chocolate, at which point Bob flatly denies that she climbed it and refuses to give her the chocolate. What is Alice to do?

In the conventional “contract world”, all that Alice can do is to take the contract that she and Bob had signed (assume they had formalised it) and take it to a court of law (a schoolteacher, perhaps, in this case), which will do its best possible in order to determine whether she actually climbed the tree, and then deliver the judgment.

As you may imagine, in the normal schoolkid world, going to a teacher for adjudicating on whether someone climbed a tree (most likely an “illegal” activity by school rules) is not the greatest way to resolve the fight. Instead, either Alice and Bob will try to resolve it by themselves, or call upon their classmates to do the same. This is where the blockchain comes in.

Simply put, in terms of the blockchain “register”, as long as more than half of Alice and Bob’s classmates agree that she climbed the tree, she is considered to have climbed the tree, and Bob will be liable to give her chocolate. In other words, the central “trusted third party” gets replaced by a decentralised crowd of third parties where the majority decision is taken to be the “truth”.

Smart contracts take this one step further. Bob will give the bar of chocolates to the collective trust of his classmates (the adjudicators). And if a majority of them agree that Alice did climb the tree, the chocolate will be automatically given to her. If not, it will come back to Bob. What blockchain technologies allow for is to write code in a clever manner so that this can get executed automatically.

This might be a gross oversimplification, but this is exactly how the blockchain works. Each transaction is considered “valid” and put into the blockchain if a majority of nodes agrees it’s valid. And in order to ensure that this voting doesn’t get rigged, the nodes (or judges) need to perform a difficult computational puzzle in order to be able to vote – this imposes an artificial cost of voting which makes sure that it’s not possible to rig the polls unless you can take over more than half the nodes – and in a global blockchain where you have a really large number of nodes, this is not feasible.

So when you see that someone is building a blockchain based solution for this or that, you might wonder whether it actually makes sense. All you need to do is to come back to this schoolkid problem – for the kind of dispute that is likely to arise from this problem, would the parties prefer to go to a mutually trusted third party, or leave it to the larger peer group to adjudicate? Using the blockchain is a solution if and only if the latter case is true.

Blockchain and real estate

Based on the title of this blog post, you might assume this might be about Honduras, where there is a proposal to use the blockchain to store land records. The problem with Honduras is that there is no “trusted third party” – nobody even trusts the government, for example, so the best way to store land records is in a decentralised hard to tamper manner.

Over the last few days I’ve been reading up a bit on blockchain and bitcoin and how it works and so on. I haven’t yet got to the math – that it is described as “proof of work” irritates me no end (given that work should be evaluated on output rather than input).

So I see that what makes blockchain secure (apart from the miners having to agree on every transaction, and securing bunches of transactions using cryptographic hashes) is that every block contains within itself a hash of the previous blocks. In other words, the entire sequence of transactions is maintained.

The way “normal currency” (like cash) works is that only possession matters, not history. So the fact that there is a hundred rupee note in my pocket means that I can spend that money, and nobody has a track of how that hundred rupee note reached my pocket. This makes the system insecure since if a pickpocket picks this note, there is no proof (apart from possibly catching him in the act red-handed) that he picked it from my pocket.

With bitcoin, on the other hand, there is a record of how each bit of currency (no pun intended) ended up where it ended up. So even if someone were to magically “steal” my bitcoin, the historical records show that this legitimately belongs to me, and that makes it secure.

This reminds me of the paperwork involved when we bought our apartment in Bangalore last year. Normally you would imagine that a certificate indicating that the title currently rests with the current owner is enough to conduct a real estate transaction. but lawyers and bankers here are not satisfied with that.

The paperwork for the apartment I bought went back sixty odd years, when the land on which the building was built was first “allotted” by the City Improvement Trust Board. If I have to sell this apartment on, along with the certificate that I own this apartment I’ll have to furnish copies of this entire history going 60-70 years back. And the way property deals are done here, I don’t expect the system to change.

So this is what makes real estate such a prime candidate for using blockchain. Not only is a third party (such as the government department that stores land records) not trusted, it is a standard practice to include the entire history of every land or property going back several years. A sale transfers ownership, but in terms of paperwork, a layer gets added, not replaced.

This shows why real estate is such a prime candidate for moving to blockchain for storing transactions. It is ironical that a small and crime-ridden country such as Honduras is showing the way on this. It is time for countries like India to consider similar uses. But first, we will need to digitise existing records and make sure there is exactly one owner for each piece of property, and blockchain can’t help us with that challenge!