Nearly everyone has heard of Blockchain and that it is cool. But not everybody understands how it works. This article shows that Blockchain certainly isn’t magic.
What is Blockchain?
A Blockchain is a diary that is almost impossible to forge.
Let’s imagine that 10 people in one room decided to make a separate currency. They have to follow the flow of funds, and one person – let’s call him Bob – decided to keep a list of all actions in a diary:
One man – let’s call him Jack – decided to steal money. To hide this, he changed the entries in the diary:
Bob noticed that someone had interfered with his diary. He decided to stop this from happening.
He found a program called a Hash function that turns text into a set of numbers and letters as in the table below.
A hash is a string of numbers and letters, produced by hash functions. A hash function is a mathematical function that takes a variable number of characters and converts it into a string with a fixed number of characters. Even a small change in a string creates a completely new hash.
After each record, he inserted a hash. The new diary was as follows:
Jack decided to change entries again. At night, he got to the diary, changed the record and generated a new hash.
Bob noticed that somebody had sifted through the diary again. He decided to complicate the record of each transaction. After each record, he inserted a hash generated from the record+last hash. So each entry depends on the previous.
If Jack tries to change the record, he will have to change the hash in all previous entries. But Jack wanted more money, and he spent the whole night counting all the hashes.
But Bob did not want to give up. He decided to add a number after each record. This number is called “Nonce”. Nonce should be chosen so that the generated hash ends in two zeros.
Now, to forge records, Jack would have to spend hours and hours choosing Nonce for each line.
More importantly, not only people but computers can’t figure out the Nonce quickly.
Later, Bob realized that there were too many records and that he couldn’t keep the diary-like this forever. So when he wrote 5,000 transactions, he converted them to a one-page spreadsheet. Mary checked that all transactions were right.
Bob spread his spreadsheet diary over 5,000 computers, which were all over the world. These computers are called nodes. Every time a transaction occurs it has to be approved by the nodes, each of whom checks its validity. Once every node has checked a transaction there is a sort of electronic vote, as some nodes may think the transaction is valid and others think it is a fraud.
The nodes referred to above are computers. Each node has a copy of the digital ledger or Blockchain. Each node checks the validity of each transaction. If a majority of nodes say that a transaction is valid then it is written into a block.
Now, if Jack changes one entry, all the other computers will have the original hash. They would not allow the change to occur.
This one spreadsheet is called a block. The whole family of blocks is the Blockchain. Every node has a copy of the Blockchain. Once a block reaches a certain number of approved transactions then a new block is formed.
The Blockchain updates itself every ten minutes. It does so automatically. No master or central computer instruct computers to do this.
As soon as the spreadsheet or ledger or registry is updated, it can no longer be changed. Thus, it’s impossible to forge it. You can only add new entries to it. The registry is updated on all computers on the network at the same time.
- A Blockchain is a type of diary or spreadsheet containing information about transactions.
- Each transaction generates a hash.
- A hash is a string of numbers and letters.
- Transactions are entered in the order in which they occurred. Order is very important.
- The hash depends not only on the transaction but the previous transaction’s hash.
- Even a small change in a transaction creates a completely new hash.
- The nodes check to make sure a transaction has not been changed by inspecting the hash.
- If a transaction is approved by a majority of the nodes then it is written into a block.
- Each block refers to the previous block and together make the Blockchain.
- A Blockchain is effective as it is spread over many computers, each of which has a copy of the Blockchain.
- These computers are called nodes.
- The Blockchain updates itself every 10 minutes.
Wallets, digital signatures, protocols
Bob gathered the 10 people together. He needed to explain the new coin to them.
Jack had confessed his sins to the group and deeply apologized. To prove his sincerity he gave Ann and Mary their coins back.
With all that sorted, Bob explained why this could never happen again. He decided to implement something called a digital signature to confirm every transaction. But first, he gave everyone a wallet.
What is a wallet?
A wallet is a string of numbers and letters, such as 18c177926650e5550973303c300e136f22673b74. This is an address that will appear in various blocks within the Blockchain as transactions take place. No visible records of who did what transaction with who, only the number of a wallet. The address of each particular wallet is also a public key.
To carry out a transaction you need two things: a wallet, which is basically an address, and a private key. The private key is a string of random numbers, but unlike the address, the private key must be kept secret.
When someone decides to send coins to anyone else they must sign the message containing the transaction with their private key. The system of two keys is at the heart of encryption and cryptography, and its use long predates the existence of Blockchain. It was first proposed in the 1970s.
Once the message is sent it is broadcast to the Blockchain network. The network of nodes then works on the message to make sure that the transaction it contains is valid. If it confirms the validity, the transaction is placed in a block and after that, no information about it can be changed.
What are cryptographic keys?
A cryptographic key is a string of numbers and letters. Cryptographic keys are made by key generators or keygens. These keygens use very advanced mathematics involving prime numbers to create keys.
The Blockchain consists of individual behaviour specifications, a large set of rules that are programmed into it. Those specifications are called protocols. The implementation of specific protocols essentially made Blockchain what it is — a distributed, peer-to-peer and secured information database.
The Blockchain protocols ensure that the network runs the way it was intended to by its creators, even though it’s completely autonomous and isn’t controlled by anyone. Here are some examples of protocols implemented in Blockchain:
- Input information for every hash number has to include the previous block’s hash number.
- The reward for successfully mining a block decreases by half after every 210,000 blocks are sealed-off.
- In order to keep the amount of time needed to mine one block at approximately 10 minutes, mining difficulty is recalculated every 2,016 blocks.
Proof of Work
The placing of a transaction in a block is called a successful conclusion to a proof of work challenge and is carried out by special nodes called miners.
Proof of Work is a system that requires some work from the service requester, usually meaning processing time by a computer. Producing a proof of work is a random process with low probability, so normally a lot of trial and error is required for a valid proof of work to be generated. When it comes to Bitcoins, the hash is what serves as a proof of work.
What is mining?
Miners on a Blockchain are nodes that produce blocks by solving the proof of work problems. If a miner produces a block that is approved by an electronic consensus of nodes then the miner is rewarded with coins. As of October 2017, Bitcoin miners get 12.5 Bitcoins per block.
The reward is not the only incentive for miners to keep running their hardware. They also get the transaction fees that Bitcoin users pay. Currently, as there is a huge amount of transactions happening within the Bitcoin network, the transaction fees have skyrocketed. Even though the fees are voluntary on the part of the sender, miners will always prioritize transfers with higher transaction fees. So, unless you are willing to pay a rather high fee, your transaction might take a very long time to be processed.