Blockchain In Plain English
This is not yet another post, written by a tech geek, to another tech geek. The knowledge gap between the blockchain space and the community is getting wider day by day. The aim of this series is to explain how Blockchains work in the simplest manner, so that an average person can easily understand it.
There will be 4 posts:
Small recap: Sal has tried to double-spend his money, because he is too lazy to make his own coffee. Because of Sal’s laziness, now we have to work more on our protocol. Thanks, Sal!
Remember why double-spending is not an issue in centralized solutions. Because all the transactions are processed by a single
entity (person, bank, or whatever). Although it may sound dumb, let’s see what will happen if you try to double-spend your money
on your debit-card. In our scenario, you have 10 dollars in your account. You want 2 items from different online vendors
(say Ebay and Amazon), both cost 10 dollars. So you have written some hacker code
that will try to buy these 2 items
simultaneously.
We do kind of want to replicate this logic. The tricky part is, replicating this without making our protocol centralized is hard.
For example, we could have assigned Joe as our leader, and everybody could send their transactions to Joe. After Joe processed transactions, he could broadcast these transactions to everyone else. Nobody will update their Word Documents on their own. They will only add the transactions that are coming from Joe, to their Word documents. This would solve the double-spending problem. But, why don’t we use centralized solutions then? Now, we are not different at all. Joe may be corrupted, someone can bribe Joe, Joe may accidentally do something wrong, etc.
Here are some other things we CANNOT do:
I believe, now you understand how big is this double-spending problem, if we do not want to make compromises with decentralization.
Quis custodiet ipsos custodes? (Who watches the watchers?)
Roman poet Juvenal
Recall that, we have this double-spending problem, because everybody is updating their Word Document on their own. This is too chaotic! And selecting a leader was solving the double-spending problem. What if we select a leader for very short periods? And everybody in the system will be a leader sooner or later, so effectively, the users will become the authority. It will be a system that governs itself. Sounds promising, but you should have questions. Don’t worry, I will answer all of them.
Let us recall our 5 friends. They were using Word as their distributed ledger. But each page in Word can have some limited amount of transactions (say 50 for now).
What happens if the page gets full? Easy! They press enter
, and a new page is created automatically!
Now, we don’t want our 5 friends to create new pages on their own. Say that current page of the Word document is full,
and they are hearing new transactions. They can note these new transactions somewhere else (like notepad), but we don’t want
them to include these new
transactions in their Word documents immediately by creating a new page.
If we somehow manage to assign a random person for each page’s creation, and fill the contents of it, then the ordering problem will be solved. A very easy solution would be the round-robin approach (they take turns in the new page creation). For example, alphabetical order: Brian, James, Joe, John, Sal. They will create new pages in this order, endlessly.
The updated protocol is as the following:
Now, if anybody but Sal is the next page creator, Sal can’t double-spend. Because one of his transactions will be declined by the page creator as an invalid transaction. The question is: Can Sal double-spend by putting 2 conflicting transactions in the same page if he is the page creator?
As I said, anyone can do anything in blockchain. Sal can try to double-spend. Nothing or nobody is preventing him from that. But Sal will not gain anything from it, since everybody else in the team will say “Hey Sal, you are cheating mate! You have 7 dollars but you are trying to spend 14 dollars in here. I’m not accepting this page” (reminder: in decentralized system, everyone knows how much money there is in each account). The others will simply decline that whole page, and let the next person create the next page. That’s the beauty of blockchain, you get to do whatever you want, and others get to do whatever they want. If the majority is honest, the protocol will run just fine :)
Dude, slow down! You are too smart. We will cover that in the 4th article. Sigh…
I’ll only explain how this attack works for now. Say, Sal is the page creator for this round. He collects the necessary amount of transactions to create a page. But he creates 2 different pages, namely A and B.
A
:
-7 from Sal's account, +7 to Brian's account
(Sal buys coffee from Brian)B
:
-7 from Sal's account, +7 to Joe's account
(Sal buys coffee from Joe)Notice that only the last transaction is different between A
and B
.
And Sal sends the page A
to Brian and James, B
to John and Joe. What will happen now?
Do not worry, we will also fix this in the future. Keep in your mind that this is a great question. You will find the detailed answer in the 4th article of this series. I advise to not jump directly into there. Everything I will explain, will be a building block. It might not make sense if you hurry.
Just to satisfy your curiosity, I can provide a simple answer. In this attack scenario, there will be basically 2 different
ledgers (one with page A
, one with page B
). If we can find a deterministic criteria for the majority to select one of them, they can discard
the other ledger, and all transactions will be consistent with each other. Say, in every page, the majority will broadcast
their version of the ledger, and if there are more than 1 version, they will select one of them depending on an objective
criteria. This criteria can be alphabetical order on the contents of the block (very bad criteria by the way, just saying).
This is not how blockchains work! It was just a dummy example to demonstrate that this problem can be solved.
Joe, being a complete retard using computers, accidentally pressed ctrl+v
three times instead of once. And now the
transaction that Brian pays Joe 10 dollars is recorded, but 3 times…
Brian -10, Joe +10
Brian -10, Joe +10
Brian -10, Joe +10
Unfortunately, Brian does have enough money to cover these transactions, and they will not fail. Okay, this was an honest mistake, but what if it was a malicious action? What if Joe tried to create a fake transaction of:
Brian -10000, Joe +10000
Our protocol should not allow any of this non-sense.
This problem can easily be solved with Digital Signatures. In summary (in case you did not read the link I gave, but you should), everyone has a password, that they can use for creating transactions for their money. Joe cannot create the transaction Brian -10000, Joe +10000, since the money is coming from Brian in here. The only person that can craft this transaction is Brian. However, the copy-paste problem still persists. Joe can copy-paste a valid transaction that Brian made: Brian -10, Joe +10 many times.
So, the naive Digital Signature scheme solves the problem of:
Brian -10000, Joe +10000
but not:
Brian -10, Joe +10
Brian -10, Joe +10
Brian -10, Joe +10
.We can solve the second one with little additional effort: by adding some counter to each transaction. For example, now, Brian would create this transaction: 1. Brian -10, Joe +10. If he wants to replicate this transaction, and send 30 dollars to Joe with 3 separate transactions, then the transactions should be like this:
1. Brian -10, Joe +10
2. Brian -10, Joe +10
3. Brian -10, Joe +10
Now, assuming Brian did not intend to send 30 dollars, but 10 dollars to Joe. And Joe did the copy-paste accident.
1. Brian -10, Joe +10
1. Brian -10, Joe +10
1. Brian -10, Joe +10
These are clearly the same transactions, not separate ones.
By utilizing Digital Signatures, and adding a little trick, now our transactions are bullet-proof. Nobody can craft/duplicate transactions on behalf of someone else.
The others will simply discard that fake/invalid page. And his ledger will be incompatible with the majority.
No xD
What will happen when someone joins, or leaves the network?
…
Yeah, that will mess up the system. Since we are taking turns, the page creator for that turn should not leave the protocol whenever he wants. We also cannot allow anyone to join as soon as they want. All of this, because we are taking turns for becoming the page creators. So, it seems taking turns is actually not a good idea, huh? Good.
Also, there is another really weak point of this system as I mentioned: Denial of Service attacks. Because of the round-robin fashion, we know in advance, who will try to create which page. If we want to censor some transactions, we can attack the page creator at that slot, and he will be unable to create the page (it is quite easy to perform Denial of Service attacks, especially to an ordinary computer).
I mean, if you are okay with having a few trusted centralized authorities (whitelist of users) that will be the page creators, and if they are resilient to Denial of Service attacks, this protocol is probably do the trick. But we are aiming for true decentralization here, in a trustless setting (meaning that: we should not have to trust anybody).
In summary, what we have proposed is not a good solution because of these 2 reasons:
Although what we have done has some flaws at the moment, we are actually close to a real solution. Proof of Work solves all the aforementioned problems, with one cost: electricity usage (we will also solve this via Proof of Storage and Proof of Stake, but let’s take one step at a time).
We will inspect how PoW works in the next article. See you there!