How does blockchain work? Everything there is to know
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 really 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 chosing 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 change 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 instructs the 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 have 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.
Read more in the article “Bitcoin Wallets: everything you need to know”.
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, hash is what serves as a proof of work.
What is mining?
Miners on a Blockchain are nodes that produce blocks by solving 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 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.
Read more in the article “What is Mining”.
- If you possess digital money then you need a digital wallet.
- A wallet is an address on the Blockchain.
- A wallet is a public key.
- Someone wanting to conduct a transaction must send a message with the transaction signed with their private key.
- Before a transaction is approved it is checked by every node who vote on it in a special electronic way that is different to the elections that most countries have.
- A transaction is placed in a block by miners who are special nodes.
- The computers in the network holding the Blockchain are called nodes.
- Miners place transactions in blocks in response to proof of work challenges.
- After miners successfully 'seal off' a block of transaction, they receive a reward, which currently stands at 12.5 BTC, and they also get to keep a transaction fees Bitcoin holders pay.
- Interaction is carried out on a Blockchain using rules built into the program of the Blockchain called protocols.
- Cryptography is essential on Blockchains to thwart thieves who would like to hack into the Blockchain.
- Cryptographic keys are made by key generators or keygens.
- Keygens use very advanced mathematics involving prime numbers to create keys.
- A block contains a timestamp, a reference to the previous block, the transactions and the computational problem that had to be solved before the block went on the Blockchain.
- The distributed network of nodes that need to reach consensus makes fraud almost impossible within the Blockchain.
Principles of Blockchain
The database is the Blockchain and each node on a Blockchain has access to the whole Blockchain. No one node or computer regulates the information it contains. Every node is able to validate the records of the Blockchain. This is all done without one or several intermediaries in control of everything.
It is architecturally decentralized as there is no one or several points of failure. There is no one point of failure that would bring down the Blockchain.
However the nodes of a Blockchain are logically centralized, as the entire Blockchain is a distributed network performing certain actions programmed into it.
Peer-to-peer (P2P) transmission
In line with the first principle, communication is always happening directly between peers, rather than through some central node. Information about what is happening on the Blockchain is stored on each node then passed to adjacent nodes. In this way information spreads through the whole network.
Transparency yet pseudonymity
Anyone inspecting the Blockchain is capable of seeing every transaction and its hash value. Someone using the Blockchain is able to be anonymous if they wish or they can give their identification to others. All that you see on the Blockchain is a record of transactions between Blockchain addresses.
Once the recording of a transaction is on the Blockchain and the Blockchain has been updated, then the alteration of the records of this transaction is impossible. This is due to that particular transaction record being linked to the record of every preceding one. Blockchain records are permanent, they are ordered chronologically, and they are available to all the other nodes. The diagram shows an extract from the Bitcoin Blockchain.
Why it is impossible to turn off the network?
As there are nodes throughout the world it is virtually impossible for the entire network to be taken over by a single party.
Why is it almost impossible to fake a block?
The reason that faking a block is almost impossible is that the validity of the block and, by extension, its inclusion into the Blockchain is determined by an electronic consensus of nodes. There are thousands of these nodes, scattered all over the world, and as a consequence capturing the network would require a computer with impossible power.
Can you use a Blockchain as normal database?
Can you store 3GB of files on the Blockchain in the same way you could use Access, Filemaker or MySql? This would not be a good idea. Most Blockchains are not suitable for this by design or simply lack the required capacity.
Traditional online databases usually use a client-server network architecture. This means that users with access rights can change entries stored in the database, but the overall control remains with administrators. When it comes to a Blockchain database, each user is in charge of maintaining, calculating and updating every new entry. Every single node must work together to make sure that they are coming to the same conclusions.
The Blockchain architecture also means that each node must work independently and compare the results of their work with the rest of the network. So, reaching a consensus can be very time-consuming. Because of this, Blockchain networks are considered to be very slow compared to traditional digital transaction technology.
However, there are experiments of producing databases with Blockchain technology, with BigchainDB being the first major company in the field. The creators took an enterprise-class distributed database and built their technology on top of it, while adding the three key attributes of the Blockchain: decentralization, immutability and the ability to register and transfer assets. Whether what they have created is useful remains to be determined.
- The Blockchain is a database, which is distributed among all nodes.
- No one or several nodes control the Blockchain.
- All nodes are able to validate a transaction.
- All communication on the Blockchain is p2p.
- Anyone using a Blockchain is anonymous if that is what they wish.
- All transactions occurring on a Blockchain are recorded there, so the transactions of any person using the network are public and completely transparent, even though they may be anonymous.
- Once a transaction is recorded on the Blockchain and the Blockchain has updated, then that transaction cannot be altered.
- No one person or organization can turn off a Blockchain.
- Although a Blockchain is politically and architecturally decentralized it is logically centralized.
Where can Blockchain be used?
In the following part of the article we will discuss some of the many various applications using Blockchain. We will frequently use the term smart contract. Let us define the term.
The Blockchain is ideal for what are known as smart contracts.
What are smart contracts?
Smart contracts define the rules and penalties around a specific agreement in the same way as traditional contracts do. However, the big difference is that smart contracts automatically enforce those obligations. The contracts are coded so that they are discharged on the fulfillment of specific criteria.
1. A warranty claim
Usually settling warranty claims is expensive, time-consuming and often difficult for those making the claim. It is possible to implement smart contracts using Blockchain that will inevitably make the process a lot easier.
In the past when a claim is made, all checks would be carried out by humans, which can be time-consuming and leaves room for human error. This will become unnecessary, as checks to ensure that all criteria have been met, and can be done automatically using the Blockchain. Once all obligations are fulfilled, the resulting payout is automatic. This can all be done using minimum human involvement.
One of the solutions offered by Deloitte is the inclusion of a QR-code in a receipt. The QR-code is set to contain all the relevant information regarding the purchase: item, serial number, date of purchase and so on. With it, the QR-code also holds instructions on how to find a ‘warranty bot’ on Facebook Messenger. The user can then send a picture of the receipt to that bot, the engine unwraps the QR-code and stores all the product information on the Blockchain.
Derivatives are used in stock exchanges and are concerned with the values of assets. Smart contracts in the trading of stocks and shares could revolutionize current practices by streamlining, automating and reducing the costs of derivatives trading across the industry. Settlements could be completed in seconds rather than the three days that are needed at present. Using smart contracts, peer-to-peer trading will become a usual operation, resulting in a complete revolution in stock trading. Barclays and several other companies has already trialed a way of trading derivatives using smart contracts, but they came to the conclusion that the technology won’t work unless banks collaborate to implement it.
3. Insurance claims
With smart contracts, a certain set of criteria for specific insurance-related situations can be established. In theory, with the implementation of Blockchain technology, you could just submit your insurance claim online and receive an instant automatic payout. Providing, of course, that your claim meets all the required criteria. French insurance giant AXA is the first major insurance group to offer insurance using Blockchain technology. They’ve recently introduced a new flight-delay insurance product that will use smart contracts to store and process payouts. Other insurance companies will surely follow suit.
4. Identity verification
Too much time and effort is currently wasted on identity verification. Using the decentralization of Blockchains, the verification of online identity will be much quicker. Online identity data in a central location will vanish with the use of the Blockchain smart contracts. Computer hackers will no longer have centralized points of vulnerability to attack. Data storage is tamper-proof and incorruptible when backed by Blockchain. All over the world, the Blockchain is leading to big improvements in the verification of identity.
The city of Zug in Switzerland uses a decentralized application (DAPP) for the verification of its citizens’ electronic identities. Another producer of DAPPs, for identity verification is Oraclize in Estonia. It markets a DAPP to solve the KYC (Know Your Customer) problem. This is of major importance in identity verification. The organization Thomson Reuters is creating another DAPP for identity verification using Ethereum.
5. The Internet of Things (IoT)
The Internet of Things (IoT) is the network of physical devices, vehicles and other items embedded with software, actuators, sensors, software and network connectivity, connected to the Internet. All of those features enable such objects to collect and exchange data. Blockchain and its smart contracts are ideal for this.
Projects involving smart contracts for devices have been predicted to become very common. The world's leading IT research company, Gartner, has made the prediction that by the time we reach 2020 at least 20 bln connected devices will exist. These devices are using Ethereum smart contracts. For instance, we have the Ethereum lightbulb, we have the Ethereum BlockCharge, involving the charging of electric vehicles, and lastly CryptoSeal; this is a tamper-proof seal for drug safety.
Blockchain will play a major role in the roll out of IoT, but will also provide ways of guarding against hackers. Because it is built for decentralized control, a security scheme based on it should be scalable enough to cover the rapid growth of the IoT. Moreover, Blockchain’s strong protection against data tampering will help prevent a rogue device from disrupting a home, factory or transportation system by relaying misleading information.
6. Archiving and file storage
Google Drive, Dropbox, etc. have thoroughly developed the electronic archiving of documents with the use of centralized methods. Centralized sites are always tempting to hackers. Blockchain and its smart contracts offer ways of reducing this threat substantially.
There are many Blockchain projects which aim to do this. Bear in mind, however, that there is often not enough storage within Blockchains themselves, but there are decentralized cloud storage solutions available, such as Storj, Sia, Ethereum Swarm and so on. From the user’s perspective they work just like any other cloud storage. The difference is that the content is hosted on various anonymous users’ computers, instead of data centers.
7. The protection of intellectual property
Archiving enabled by Blockchain will offer much greater protection of intellectual property than before. An application called Ascribe, using Blockchain, already gives this protection.
Lawbreakers have to hide and camouflage the money gained from their exploits. Currently this is done with fake bank accounts, gambling, and offshore companies, among other stratagems. There are a lot of concerns regarding the transparency of cryptocurrency transactions. But, all of the necessary regulatory elements, such as identifying parties and information, records of transactions and even enforcement can exist in the cryptocurrency system.
As the technology gets more mainstream attention, Blockchain and its smart contracts have the potential to render most money laundering tactics ineffective and very traceable.
9. Social media
At present, social media organizations are able to freely use the personal data of their clients. This helps them make billions of dollars. Using Blockchain smart contracts, users of social media will be enabled to sell their personal data, if they so desire. Such ideas are being investigated at MIT. The aim of the OPENPDS/SA project is to provide the data-owner to tune the degree of privacy preservation using the Blockchain technology.
10. The use of smart contracts in elections and polls
Elections and polls could be greatly improved with smart contracts. There are various apps already in existence, such as Blockchain Voting Machine, Follow My Vote and TIVI. All of them are promising to eliminate fraud, while providing complete transparency to the results and keeping the votes anonymous. However, there is still a long road ahead before decentralized voting is implemented widely.
Limitations and vulnerability
Any Blockchain network largely depends on the amount of active users within it. In order to operate to its full potential, a network has to be a robust one with a widely distributed grid of nodes.
Moreover, there is no Blockchain network in existence that could sustain the same amount of transactions as major card issuers like Visa or MasterCard do. As of 2017, Blockchain still has a very long way to go before it will be capable of replacing the giants of the financial world.
Finally, there is always a theoretical possibility of a large-scale capture of any given Blockchain network. If a single organization will somehow manage to gain control of the majority of the network’s nodes, it will no longer be decentralized in the full sense of the word.
Blockchain investment climate
As Bitcoin’s price hit the record $5,000 for the second time in 2017, there is probably no current investment opportunity more hyped up than cryptocurrencies and Blockchain technology. The general public and governing authorities are increasingly more aware of its advantages, and most concerns surrounding it are being refuted. A lot of companies have already invested in the technology, and it is very telling that the worldwide technology giant IBM is now considering investing “employee time and energy” into the space.
Many companies offer credit cards in a pursuit of encouraging loyalty and adding a new stream of revenue. Samsung has recently partnered with Blocko aiming to allow credit cards to engage in secure transactions using Blockchain technology. Samsung are aiming to create new business using digital identity, digital money and digital payment.
According to a report, as of October 2017, there have been 42 equity investment deals in 2017 alone, totalling $327 mln. The most active investor is a Japanese services firm SBI Holding, with stakes in eight Blockchain firms. A digital powerhouse Google is the second-most active investor, with stakes in the Bitcoin wallet company Blockchain and Ripple, a company that is working on Blockchain-based money transferring system.