This is not an explanation of the blockchain, or is it?
Leonardo da Vinci was a great artist and scientist. Before he drew an arm he literally analysed it to the bone. He knew exactly how the muscles were working and how they were attached to the bone. This makes his drawings and paintings lifelike stills of bygone times. His empirical method of working also enabled him to design machines far ahead of his time. Today we call this way of working, scientific: observe, analyse, draw conclusions, verify and start all over again. For me, the blockchain is all about this, not only to understand the technology but also the impact of it.
The blockchain is comprehensive, challenging and it is a big puzzle. Once you have solved one piece, a new one pop-ups. In order to understand and judge the many articles, initiatives and business cases, I dived into the essences of the blockchain and tried to write them down for everybody to understand whether you are a consultant, marketeer or writer. As much it was an exercise for myself, I hope I succeeded and you gain some knowledge after you read this article.
There is no better start than with a quote of Satoshi Nakamoto about what the blockchain is
an electronic payment system based on cryptographic proof instead of trust, allowing any two willing parties to transact directly with each other without the need for a trusted third party
A blockchain is nothing more than lists of transactions chained together. Copies of this chain of blocks are distributed over multiple computers (also called nodes). The way these blocks are built, distributed and chained together makes it impossible to alter something in a block without it being noticed. To understand how it is done we need to dive into a technique called hashing.
Hashing is giving digital content an almost unique fingerprint (almost unique because there is a very very very minimum chance that two pieces of content generate the same hash). In blockchain the SHA-256 Cryptographic Hash Algorithm is used to hash content. This algorithm generates from any piece of digital content a 256 bits (32 bytes) fingerprint of 64 characters.
The word “blockchain” has the following hash: ef7797e13d3a75526946a3bcf00daec9fc9c9c4d51ddc7cc5df888f74dd434d1.The word “blockchai” (without the n) has the following hash:
A change in the content results in a complete different hash. You can hash any digital content type, so also images, pdf’s and so on. It doesn’t matter how long or big the file is, it generates a hash of 64 characters. For instance the hash of Satoshi Nakamoto’s White paper (9 pages) is:
But you can also hash a hash. Try some hashing yourself to fully understand the concept. Here is a link: https://passwordsgenerator.net/sha256-hash-generator/ or https://hash.online-convert.com/sha256-generator.
It’s important to notice that hashing content is not encrypting content. The original content cannot be recreated from the hash it generates. You can only generate the exact same hash when you have the original content.
So, let’s go back to how the blocks are chained together. Each blocks starts with the hash of the previous block. This hash is partly the result of the content in that block (details later). So if you would change something in a block, the hash of the block changes. The direct result will be that the hashes that connects the blocks don’t correspond any more. Therefore the chain will be broken. As copies of the blockchain are distributed over numerous nodes, it is immediately noticed when one copy is corrupted.
Let’s have a closer look at a block that is just a list of transactions. In order to do that we first will dive into transactions.
In order to do transactions on the blockchain you need to download and install software: the wallet. You use the wallet to manage your transactions. You don’t have to identify yourself to download and install the software. So you are an anonymous user.
When you install a wallet, you get two keys:
- a private key
- a public key
These keys are mathematically linked together. This means that what is encrypted with your private key, can be decrypted by your public.
The private key is the one you don’t want to lose. If you do, nobody can help you. The blockchain has no central authority where you can redeem your key as in “forgotten password”.
As a user you can initiate transaction like you send emails. Really simple. You don’t see the complexity under the hood. But what happens under the hood is really important.
Your public key is also your public address to receive transactions.
You use your private key to generate a signature that identifies you when you do a transaction.
There are three important items in a transactions:
- a message with the details of the transactions (amount and the to-address)
- your public key
- your signature
Your signature is generated as follows:
- the message with transaction details is hashed
- the hashed messages together with the private key generates a signature
Because the hash of the message is used in the signature, every signature is unique, so copying somebody’s signature is not an option because the hash depends on the content of the message and even if you have the message you don’t have the private key to create a signature.
A transaction consists of:
- the original message (not hashed)
- the signature
This is sent to the blockchain.
When the transaction arrives, it is validated.
- the signature is decrypted with the public key and reveals the hash of the message and the sender.
- the message (not the hashed one) is hashed and the hash is compared with the hash that came out of the decryption of the signature. If they are the same you know that the message hasn’t been altered
If the transaction is valid, your funds are checked and when you have enough funds the transaction is added to a pool of transactions. Transactions out of the pool will be added to the next block in the blockchain.
Building a block
So your transaction is now waiting to be added to a block. The messages tell which bitcoins have to be transferred from one address to another address. Miners (computers running blockchain software to add blocks to the blockchain) take two messages and make a hash out of them. Then they take another two messages and hash them too. Out of these two hashes a new hash is generated, and so on. A, so called, Merkle Tree is made out of all the transactions (see image). So at the end there is only one hash: the root hash.
Now you see that if only one transaction is changed at the bottom of the tree, the root hash changes. But we are not done hashing, let’s hash some more.
Mining: solving the puzzle
The root hash is combined with the hash of the previous block and a nonce number. This is a random number. These three items generate a new hash that will become the identifier of the block. However, this hash needs to meet some criteria.
And now we are diving into mining, giving birth to bitcoins and solving the puzzle. The criteria for the new hash are set by the amount of zeros that the hash has to start with. The more zeros, the more difficult it is to find the right hash.
When talking about solving the puzzle and that the difficulty of the puzzle is automatically adjusted, it is all about adjusting the number of zeros that the hash needs to have in the beginning.
Finding the right hash is called mining. The person that finds the right hash is allowed to add the new block to the blockchain. So what miners do, is
- add transactions to a block
- generate a new root hash
- combine this with the hash of the previous block
- add a nonce make a new hash
- hope that that hash has the right amount of zeros
- if not, start all over again
You can imagine that this takes a lot of calculating power. The miner that finds the right hash, can add his block with transactions to the blockchain and receives 12,5 bitcoins (at this moment) for it.
But mining is not only generating those hashes, in the process all transactions are constantly validated between the miners to come to a consensus whether a transaction is valid or not.
The difficulty of the puzzle is automatically adjusted to guarantee a block will be added every 10 minutes. So if more people start to set up mining facilities and therefore the mining capacity grows, the difficulty of the puzzle will be adjusted by adding more zeros to the hash.
This kind of mining is called Proof of work, all the miners work on solving the puzzle, the one who is first can add the block. Another form of mining is called Proof of Stake. Then one miner gets the assignment to build and add a block.
I know that I described the bone of the arm at best. The muscles and skin still need to follow. But hopefully you have a better understanding of mining, solving and adjusting the puzzle and the security features (hashing and distribution) of the blockchain. There are many variations of the blockchain and the technology keeps on developing. But remember, whether you use ethereum, hyperledgeror or other blockchain technology, the blockchain is all about transactions and cutting out a third party.
The Age of Cryptocurrency: How Bitcoin and Digital Money are Challenging the Global Economic Order by Michael J. Casey and Paul Vigna