Blockchain for dummies

Part 1: What is it good for?

Dennis Charmington
Avanza Tech
14 min readMar 1, 2018

--

How can you prove your identity? Why do you trust other identities?

The short answer

For you Twitter fans that consume information in chunks of 140 characters, here is the short answer why we need blockchain technology:

#Blockchain can dramatically change the way we manage trust & ownership, moving the power from intermediaries to the users

Why I wrote this

As a software developer @ Avanza, working in the fin-tech business, it’s easy to find oneself talking with colleagues about cryptocurrencies and the blockchain, which are fascinating new technologies with great potential to change the way we handle trust, ownership and intermediaries.

We at Avanza are on a mission to help millions of Swedes to a better (economical) future, that’s why I wanted to learn more about the blockchain and cryptocurrencies so I could understand if and how it would merge with our mission at Avanza.

I want to share what I have learnt so far, in such an easy way, that even non-techie people would want to read on and learn something about the blockchain technology.

Blockchain technology

In this first part of the article I will explain what problems blockchain technology solves, and in the next part I will try to explain how it solves those problems. Enjoy the ride 🚀

What is the blockchain?

  • It’s just software (computer code), running on many computers all around the world, communicating with each other.
  • It’s no more fancy than any other distributed software, e.g., Torrent file downloading (where you download parts of files from other people’s computers all around the world).
  • Blockchain is not bitcoin. Bitcoin is not blockchain. You can compare a blockchain to Internet and Bitcoin to email (email is one of many applications running on top of internet just as Bitcoin is one of many applications running on a blockchain.
  • There are many different blockchains, each with its own “flavour”, which has advantages and disadvantages. There are blockchains that host many different applications, and there are blockchains that host only 1 application. Bitcoin has its own exclusive blockchain.

What is the fuzz about, why should I care?

  • Technology has many times changed our world and impact our way of living. Remember how the cellular phone changed our world? Or digital money and credit cards? The Internet?
    Blockchain technology is one of those technologies, it can dramatically change the way we manage trust & ownership.
    Stay curious, be open-minded and try to understand any new technology that could potentially improve our world. If you’re not part of the solution you might be part of the problem
  • During the -90s, Napster (a software program) reshaped the whole music industry by enabling people to download music digitally directly from each other’s computers (using a peer-to-peer system), and thus removed the middleman between artists and consumers (the traditional music studios and their marketing and distribution channels).
    Today, teenagers cannot imagine nor understand how cumbersome and costly it was to acquire music before Napster and music-streaming services.
  • Every industry that mainly acts as a middleman between producers and customers (sellers or buyers) of immaterial or digital goods and services, is vulnerable to being replaced by a peer-to-peer system or a blockchain (which is a special type of peer-to-peer system, more on this later).
    Are you in one of those industries? Don’t be a “Nokia”, try to reinvent and embrace the change.

The problem

Before we try to understand the blockchain technology it’s essential to understand what problem it solves. Only then can we appreciate its beauty and cleverness.

How do you trust someone?

Let’s imagine you’re a cashier in 7-Eleven store, serving customers standing in a queue. Your next customer wants to buy some gum. You notice the customer has a protein-bar poking out of his pocket. It is the same brand of protein-bar that you sell in your store.

How do you know if that customer has taken the protein-bar from your store, or if he/she has purchased it elsewhere and brought it into the store? Think for a moment about this.

You ask, and the customer says he/she has brought it from home. Can you be certain the customer is telling the truth? What if every customer would have a protein-bar in their pocket and would claim that they brought it from home? Tricky situation. 🤨

What if that customer had a friend next to him/her, that would backup the story? Would you be more or less inclined to trust the customer?

What if that customer had 10 friends that would backup the story, would it make it easier or harder to trust the customer?

What if some other customer in the queue, not related to your current customer, would step forward and say that he had seen the protein-bar in the pocket of your current customer when entering your store, would you trust the unrelated person more or less than a friend of your current customer?

I think you will agree that having one witness is good, but having more will increase the level of trust, and that having independent witnesses will increase the level of trust even more, right?

This brings us to one of the core ideas of the blockchain technology:

The more independent witnesses who testify to the same fact, the higher chance that this fact is indeed true.

So simple, so understandable. Simply beautiful. This concept is basically how our justice system works.

You might wonder how this is relevant for the blockchain? I will explain that later when we talk about distributed systems, but for now you’ll just have to trust me 😇 when I say it’s very relevant and important!

Understanding ownership

The concept of ownership and the enforcement of ownership rights are core elements of our society. Most parts of what banks, insurance companies, lawyers, solicitors, courts and consulates do, is to manage ownership and enforce ownership rights. It’s easy to understand that this is big business, and that a technical innovation in this area could have a huge impact.

It’s only natural, that these kind of players (eg banks) are afraid of being replaced or diminished. Some banks try to defend their business by bad-talking the blockchain technology in the media, and might eventually have to shut down. Other banks will find new ways of providing value to customers.

Banks, insurance companies, lawyers, courts etc working everyday maintaining ownership of stuff for people

Let’s break down ownership into smaller parts, what does it consists of?
Image you are driving a car, and a police officer stops you for some reason.

How do you prove that it’s your car?

You probably show the police officer, your drivers license, but how does the officer know the license is yours? The officer must identify you. This is done by looking at the picture on the drivers license and comparing it to your face.

If that matches, the next step in order to prove that it’s your car, is to identify the car. This is done by looking at the registration plate number of the car.

And lastly, the officer must validate that the owner (you), is the rightful owner of the object (the car). This is done by looking into digital database of the centralised car-registry that holds a mapping of the owner and the object.

Proof of ownership has 3 elements

  1. Identification of the owner
    In computer security terms, proving that someone is who he/she claims to be, is called authentication
  2. Identification of the object being owned
  3. Mapping of the owner to the object
    In computer security terms, granting access based on one’s identity, is called authorisation

The third-party solution

How do we as a society manage ownership? The short answer is: we add an independent third-party (a middleman, an intermediary) between the two parties wanting to do an exchange. And we give this third-party our trust and exclusive right to manage a centralised ledgers!

What is a ledger?

A ledger is essentially something that maps owners to objects. It can come in the form of a physical financial book keeping records of transactions, or a digital database keeping track of owners of cars.

A ledger has basically two roles

  1. Proof of ownership
  2. Transfer of ownership

As an example, a car-registry agency might keep a database of ownership of cars, similar to the image below.

A trivial example of an ledger

Anyone wanting proof of ownership of a given car, would have to request that information from the agency and accept the answer to be the truth.

The reason we accept the answer as proof of ownership, is because we put our trust in our government, which in turn puts their trust in the car-registry agency it has created, to safely keep an up-to-date ledger.

For the ledger to be correct, the agency cannot allow anyone (but itself) to modify the ledger, otherwise it would be very easy for anyone to “steal” a car (just replace a name in the list with your own name).

However, people do sell their cars sometimes. We trust the car-agency to modify the ledger truthfully when someone sells his/hers cars to a new owner. This transfer of ownership requires identification of the current and the new owner and identification the car, from the agency’s point of view.

There is only one car-registry agency to ask for ownership information from, thus only 1 ledger and only 1 version of the truth. Therefore we can say that the ledger in this example is centralised.

This is basically how we manage ownership of objects in our society, by having a trustworthy, centralised, middleman between parties who want to exchange something.

What does ledgers have to do with money?

Well, do you own any money? Where is that money stored? Most likely in a bank.

How is that money stored? A stack of dollar-bills in a secure box with your name on it? No, it’s stored as digital currency in the banks private and secure database, i.e. the banks centralised ledger.

There are two possible ways to describe ownership in a ledger. One way is through inventory data which describes the current state of ownership.

Inventory data describing current state of ownership

Another way to describe ownership is through transaction data which describe transfers of ownership. If you keep a list of all transactions ever made, you would be able to tell how much money a certain person owned, simply by looking how much money that person has sent and how much money that person has received. (You would also need to know how much money a person had to start with, which leads to the question, where does the initial money come from? But let’s postpone that discussion for later).

Transaction data describing transfers of ownership

According to the transaction list above, Viktor would own this amount of money:

<whatever money he had initially> + 5$ (received from Dennis) - 200$ (sent to Tommy) + 10$ (received from Tommy).
If he started out with 200$, he would now have 15$.

The blockchain uses transaction data rather than inventory data, so it determines ownership based on the complete history of all transactions made.

In this example, Dennis sends $5 to Viktor and $5 to Tommy. But before those transactions can be executed, he must first prove to the bank (the middleman), that he is whom he claims to be. By logging in to “his” bank-account on the banks website, using his username and password (which in combination uniquely identifies him and grants access to his account), Dennis has proven his identification to the bank and the bank can execute the money transfers.

Notice that the bank can easily make sure that Dennis cannot transfer more money than he owns. If Dennis would initially have $7, the bank would accept the $5 transfer to Viktor but not accept the second transfer of $5 to Tommy. This validation check is trivial in a centralised ledger, but very hard in a distributed ledger (more on this further down).

Problems with a centralised ledger

Having a centralised ledger, has its advantages and disadvantages. Here are some problem with a centralised ledger:

  • The third-party (eg bank) holding the ledger becomes very powerful. It could abuse its power. It could for example decline your request for transferring your money to someone or freeze all your assets for some reason, eg political or security.
  • The third-party, can add fees for various services (e.g. transferring money), and can increase those fees however it wants to. The users have little to say.
  • The centralised ledger becomes a valuable (single-point) target for hackers.
  • The centralised ledger is a single-point-of-failure, a technical malfunction could cause major problems.
A third-party between you and the peer you want to do an agreement with. Do you trust this third-party and its software systems to always to the right thing?

Distributed Ledgers

Instead of using only one centralised ledger, a group of independent ledgers for documenting ownership could be used, i.e., a distributed ledger. This would remove the third-party and distribute its power to the users of the system.

A distributed ledger exists in many copies and is spread over multiple peers, where any peer can serve information, and modify its own copy of the ledger.

Double-spending problem

Let’s go back to the example where Dennis wanted to send $5 to both Viktor and Tommy, but has only $7 to start with, this time using a distributed ledger.

Dennis could requests one peer (holding a copy of the ledger) to transfer $5 Viktor, and the next minute he could instruct another peer to transfer $5 to Tommy. Each peer has only seen one transaction of $5 from Dennis’ account, and approved it since Dennis had $5 to start with. Dennis has been able to spent his money ($5) twice, which would not be possible in a centralised ledger.

To solve this problem, the peers need to synchronise their copies with each other somehow so that they all keep the same version of the truth. Every time a peer modifies its copy of the ledger it needs to tell all other peers about the change made. However, passing information forward among peers and updating the individual ledgers takes time. A user could spend his money twice if he can instruct multiple peers to transfer his money before these peers have had chance to synchronise with each other.

The fact that not all peers always have up-to-date ledgers, creates a time-window where money could be spent multiple times. This problem is called the double spending problem and has been a problem for a long time in distributed systems. Luckily, Blockchain technology, invented in 2009, solves this problem!

How the Blockchain solves the double-spending problem will be explained in next part of this article.

In this example, all the peers trusts each other, meaning that the transactional information sent to other peers would never be fake or incorrect. Therefore, every time transactional information is received by a peer, it is immediately and blindly accepted as truth and added to the local copy of the ledger.

However, in the real world where the peers of a distributed system are spread all over the world, connected via Internet, one should never trust other peers to always tell the truth. This can be illustrated by the Byzantine Generals’ problem.

The Byzantine Generals’ Problem

[Disclaimer: this is a modified description of the Byzantine Generals’ problem]

Imagine that the Eastern Roman empire (also know as the Byzantine empire) has decided to capture a city. The generals and their lieutenants have surrounded the city and communicate between each other only through messengers.

The generals what to execute a synchronised attack, so they message their lieutenants a specific time to start the attack. The more lieutenants (and their soldiers) that start the attack at exactly the time decided by the general, the higher chance of victory. If all generals, lieutenants and messengers were trustworthy then it would be easy to synchronise an attack and take over the city.

However, some of the generals, lieutenants or messengers may be traitors, spies or even enemy soldiers. They will pass on incorrect information to others, leading to a defeat for the Byzantine army. This means that the lieutenants cannot even trust their general so they pass on the message (time of attack) they have received from their general to the other lieutenants. But how do lieutenants know when to start an attack?

If you were a lieutenant 1 in the figure above, receiving 5 messages (each message containing a time of attack, with different/conflicting times), how would you decide which message/order to follow, i.e. what time to attack? How could you be sure that time of attack you have chosen is the same time that all other lieutenants has chosen? hmm…a bit tricky, right?

Do you remember the 7-eleven example earlier, where the cashier had to decide weather to trust the customer or not? We concluded that…

The more independent witnesses who testify to the same fact, the higher chance that this fact is indeed true.

So let’s apply that principle to the Byzantine Generals’ problem. As lieutenant 1, you could choose the time of attack that has been passed to you most often (the time of attack that most independent witnesses has testified to). You have received 3 messages stating the attack should start 16.00, and 2 other messages stating other times to start. So you simply choose to attack at 16.00.

Applying the same principle for the other lieutenants, they too would choose to attack at 16.00 (except the spies), thus the army would attack with 3 lieutenants (and their soldiers) and most likely capture the city.

The key here is that each lieutenant (expect the spies) would come to the same conclusion on their own, just by following the same principle. Even though there are two spy-lieutenants in this example, they are not able to affect the army enough to be defeated. However, if there were 3 spy-lieutenants instead, the army would most likely fail to capture the city.

Instead of blindly and only trusting your general (centralised decision making), you can trust the majority of all the lieutenants and your general (distributed decision making). This makes the army more spy-resilient.

Selecting a version of the truth, based on what the majority of peers states, is called consensus. This is what makes the blockchain resilient to hacker attacks and technical malfunctions, because you have to hack the majority of the peers in the network in order to change the collective decision.

Summary of part 1

  • Centralised ledgers are how we manage ownership in our society today.
  • Distributed ledgers have many advantages over centralised ledgers.
  • But distributed ledgers have inherent problems such as the Byzantine Generals’ problem & the double-spending-problem.
  • Blockchain technology, introduced in 2009, is software running on millions of computers around the world, implementing a distributed ledger.
  • Blockchain solves both the Byzantine Generals’ problem and the double-spending-problem, thus removing the need for having and trusting a third-party.

Stay tuned for part 2: How does the blockchain work?

Simplified view of “blocks” in a blockchain system

Props to Daniel Drescher for writing a great book about the blockchain, called “Blockchain basics. A non-technical introduction in 25 steps”.

--

--

Dennis Charmington
Avanza Tech

Senior iOS developer, contractor, currently @ BookBeat, Stockholm