A Blog About Blockchain A to Z

A blog about everything in blockchain including the technologies and concepts that make it possible, architecture, types, consensus, cryptocurrencies, applications/use cases, advantages & disadvantages and technical aspects which includes smart contracts, ethereum and solidity programming!

Overview

It ensures high level of security as the transactions which take place are anonymous. Each transactions or digital events taking place in a Blockchain network is verified, only if it is agreed upon by the consensus of the majority party of the users participating in this process.

The key takeaway here is that it is decentralised, highly secure because it uses cryptography which is a method to encrypt data securely, highly transparent and immutable as once a transaction has been initiated, it cannot be reversed.

Blockchain is one of the most popular emerging technologies in today’s world. It provides trusted computing, decentralised consensus and smart contracts to empower users with high quality data.

The most accepted blockchain technology Bitcoin is also known as digital currency and has a broad range of applications financially as well as non-financially. It has been the most popular cryptocurrency since it was invented and it is the best example that uses the Blockchain technology.

Let’s begin!

Blockchain Architecture

Blockchain Architecture

A blockchain is basically a distributed data structure. It creates a digital ledger of transactions and thereby allowing to share it among a distributed network of computers and it also maintains a continuously-growing list of records called generally called “blocks” which are secured from tampering and revision. A blockchain implementation comprises of two kinds of records: blocks and transactions. In each block contains a timestamp and a link to a previous block is provided by the secure hash algorithm. The prime advantage is that it uses cryptography which allows different users to modify the transactions on a secured network each one accessing their node of data.If majority of nodes agree that the transaction performed looks valid, identifying information which matches the blockchain’s history and thus a new block is added to the chain.

Fundamental concepts related to blockchain architecture

(i) Decentralisation: Rather than one central authority overpowering others in the ecosystem, blockchain explicitly distributes control amongst all peers in the transaction chain.

(ii) Digital signature: Digital signature is a mathematical scheme for demonstrating the authenticity of digital messages or documents. A valid digital signature enables information integrity (using hash algorithm) to ensure message is not altered, message created by the sender (authentication) and sender cannot deny having sent the message (non-repudiation). The digital signature has to be authentic, unfalsifiable, non-reusable, unalterable and irreversible.

Each user owns a pair of private key and public key. The private key that shall be kept in confidentiality is used to sign the transactions. The digital signed transactions are broadcasted throughout the whole network.

The signature operation is based on asymmetric cryptography .The typical digital signature is involved with two phases: signing phase and verification phase.

In the signing phase, a digest of the initial information is created and this last is encrypted with the private key. A message digest is the output from a digest function that maps input data of an arbitrary length to an output of fixed length.

In the signature verification phase, the recipient extracts the encrypted digest from the message and use his public key to decrypt it. Next the recipient creates a digest from the received information and compare it with the previously unencrypted digest.

Elliptic Curve Digital Signature Algorithm (ECDSA) is the most widely used digital signature algorithm in blockchain.

(iii) Mining: It is the process of verifying and adding transactions to the large distributed public ledger of existing transactions, known as the blockchain. Users that perform data mining are called as data miners. Data miners dig deep into the data which is then evaluated according to the cryptographic rules. It is basically solving a mathematical puzzle. The data miners are then rewarded for the validation of the transactions in the blockchain.

(iv) Immutability: It is nearly impossible to delete or rollback transactions once they are included in the blockchain.

(v) Data integrity: Complex algorithms and agreement among users ensures that transaction data, once agreed upon, cannot be tampered with and thus remains unaffected. Data stored on blockchain acts as a single version of truth for all parties involved hence reducing the risk of fraud.

(vi) Anonymity: Each user can interact with the blockchain with a generated address, which does not reveal the real identity of the user.

(vii) Consensus Mechanism: Consensus is a dynamic way of reaching agreement in a group. In blockchain; because any entity, individual, or party can submit information to the blockchain, it is necessary for the distributed operators (group) of the blockchain to evaluate and agree on all added data before they are permanently incorporated into the blockchain. A method by which consensus decision-making is achieved is called consensus mechanism.

Block decoded

A blockchain is basically, a sequence of blocks

A block in a blockchain is an atomic unit that contains and maintains a list of transactions in the blockchain. A hash value is a value that is generated from a function that converts an input of letters and numbers into an encrypted output of a fixed length. It is generally unique.

Block Structure

A block consists of the block header and the block body. In particular, the block header includes:

(i) Block version: Indicates which set of block validation rules to follow.

(ii) Merkle tree root hash: the hash value of all the transactions in the block.

(iii) Timestamp: current time as seconds in universal time since January 1, 1970.

(iv) nBits: target threshold of a valid block hash.

(v) Nonce: a 4-byte field, which usually starts with 0 and increases for every hash calculation.

It is a unique number which miners will find as part of mining. Nonce stands for number which occurs only once. It is found as part of solving the mathematical puzzle (It’ll be explained in the Proof of Work consensus algorithm in the article).

To put it in simple terms, nonce is like finding a code which would open a number lock. In a trust less transaction environment like blockchain, the miners will find nonce to create the proof of work by solving a mathematical puzzle. As miners spend their computing resources and power to find nonce, they are compensated in terms of rewards paid in bitcoins.

(vi) Parent block hash: a 256-bit hash value that points to the previous block.

The block body is composed of a transaction counter and transactions. The maximum number of transactions that a block can contain depends on the block size and the size of each transaction. Blockchain uses an asymmetric cryptography mechanism to validate the authentication of transactions.

Types of Blockchain Systems:

Current blockchain systems are categorised into three types: public blockchain, private blockchain and consortium blockchain.

In public blockchain, all records are visible to the public and everyone could take part in the consensus process. Differently, only a group of pre-selected nodes would participate in the consensus process of a consortium blockchain. As for private blockchain, only those nodes that come from one specific organisation would be allowed to join the consensus process.

A private blockchain is regarded as a centralised network since it is fully controlled by one organisation. The consortium blockchain constructed by several organisations is partially decentralised since only a small portion of nodes would be selected to determine the consensus.

Comparing public, private and consortium blockchains

Comparison
  • Consensus determination. In public blockchain, each node could take part in the consensus process. And only a selected set of nodes are responsible for validating the block in consortium blockchain. As for private chain, it is fully controlled by one organisation and the organisation could determine the final consensus.
  • Read permission. Transactions in a public blockchain are visible to the public while it depends when it comes to a private blockchain or a consortium blockchain.
  • Immutability. Since records are stored on a large number of participants, it is nearly impossible to tamper transactions in a public blockchain. Differently, transactions in a private blockchain or a consortium blockchain could be tampered easily as there are only limited number of participants.
  • Efficiency. It takes plenty of time to propagate transactions and blocks as there are a large number of nodes on public blockchain network. As a result, transaction throughput is limited and the latency is high. With fewer validators, consortium blockchain and private blockchain could be more efficient.
  • Centralised. The main difference among the three types of blockchains is that public blockchain is decentralise, consortium blockchain is partially centralised and private blockchain is fully centralised as it is controlled by a single group.
  • Consensus process. Everyone in the world could join the consensus process of the public blockchain. Different from public blockchain, both consortium blockchain and private blockchain are permissioned.

Since public blockchain is open to the world, it can attract many users and communities are active. Many public blockchains emerge day by day. As for consortium blockchain, it could be applied into many business applications.

Consensus Algorithms

Byzantine Fault Tolerance

In blockchain, how to reach consensus among the untrustworthy nodes is a transformation of the Byzantine Fault Tolerance (BFT) Problem. In BFT problem, a group of generals who command a portion of Byzantine army circle the city. Some generals prefer to attack while other generals prefer to retreat. However, the attack would fail if only a part of the generals attack the city and not the whole. Thus, they have to reach an agreement to attack or retreat. How to reach a consensus in distributed environment is a challenge. It is also a challenge for blockchain as the blockchain network is distributed. In blockchain, there is no central node that ensures ledgers on distributed nodes are all the same. Some protocols are needed to ensure ledgers in different nodes are consistent. There are several common approaches to reach a consensus in blockchain which include Proof of Work (PoW) and Proof of Stake (PoS).

Proof of Work (PoW)

PoW (Proof of work) is a consensus strategy used in the Bitcoin network. In a decentralised network, someone has to be selected to record the transactions. The easiest way is random selection. However, random selection is vulnerable to attacks. So if a node wants to publish a block of transactions, a lot of work has to be done to prove that the node is not likely to attack the network. Generally the work means computer calculation.

In PoW, each node of the network is calculating a hash value of the block header. The block header contains a nonce and miners would change the nonce frequently to get different hash values.

The nonce is used to make it more difficult to generate a valid hash for a given block. Miners must find a nonce value that, when plugged into the hashing algorithm, generates an output that meets certain requirements (a certain number of leading zeros). Because the output values of hashing algorithms cannot be easily predicted from input values, this makes finding an acceptable nonce difficult and random. Miners have to use brute force to find the nonce by running different nonce values through the algorithm until an appropriate output value is found. This randomizes which node ends up solving the block and winning the bitcoin as a reward for solving the puzzle.

The consensus requires that the calculated value must be equal to or smaller than a certain given value. When one node reaches the target value, it would broadcast the block to other nodes and all other nodes must mutually confirm the correctness of the hash value. If the block is validated, other miners would append this new block to their own blockchains. Nodes that calculate the hash values are called miners and the PoW procedure is called mining in Bitcoin.

In the decentralised network, valid blocks might be generated simultaneously when multiple nodes find the suitable nonce nearly at the same time. However, it is unlikely that two competing forks will generate next block simultaneously. In PoW protocol, a chain that becomes longer thereafter is judged as the authentic one.

However, as miners have to do a lot of computer calculations in PoW, it wastes a lot of resources.

Proof of Stake (PoS)

PoS (Proof of stake) is an energy-saving alternative to PoW. Miners in PoS have to prove the ownership of the amount of currency. It is believed that people with more currencies would be less likely to attack the network.

The selection based on account balance is quite unfair because the single richest person is bound to be dominant in the network. As a result, many solutions are proposed with the combination of the stake size to decide which one to forge the next block.

Compared to PoW, PoS saves more energy and is more effective. Unfortunately, as the mining cost is nearly zero, attacks might come as a consequence. Many blockchains adopt PoW at the beginning and transform to PoS gradually

Basic differences between PoW and PoS

Applications/Use cases

Blockchain can help alleviate the security and scalability concerns in the following ways:

  1. The distributed ledger in a blockchain system is tamper-proof and this removes the need for trust among the involved parties. No single organisation has control over the vast amount of data generated by IoT devices.
  2. Using blockchain to store data would add another layer of security that hackers would need to bypass in order to get access to the network. Blockchain provides a much more robust level of encryption that makes it virtually impossible to overwrite existing data records.
  3. Blockchain provides transparency, by allowing anyone who is authorised to access the network to track the transactions that happened in the past. This can provide a reliable way to identify a specific source of any data leakages and take quick remedial action.
  4. Blockchain can enable fast processing of transactions and coordination among billions of connected devices. As the number of interconnected devices grows, the distributed ledger technology provides a viable solution to support the processing of the large number of transactions.
  5. By providing a way to enable trust among the stakeholders, blockchain can allow companies to reduce their costs by eliminating the processing overheads (for e.g. traditional protocol, hardware, or communication overhead costs).

The above reasons are why blockchain is finding its way into many applications. The applications of the Blockchain technology can be broadly classified into two:

(1) Financial: The single biggest financial use of blockchain is the Bitcoin technology. Other applications in this sector include in banks for processing transactions, in trading platforms, currency exchange and remittance, peer to peer transfers and in the insurance industry.

(2) Non-Financial: Blockchain technology is used in cloud storage, social media, Internet of Things (IoT), real estate, healthcare, gaming, supply chain management, digital identity and Proof of Ownership.

An Overview of Cryptocurrencies

Cryptocurrency is a medium of exchange value (just like ordinary money) that exists in the digital world and relies on encryption, which makes transactions secure. It makes use of blockchain technology.

The use of blockchain in cryptocurrencies makes all the transactions secure and helps to get rid of intermediaries represented by banks (third parties), which also contributes to a significant reduction in the commission fee.

The main feature of cryptocurrencies — security — is provided by Blockchain technology — a network of computers having an identical copy of the database and changing its records by a common agreement based on pure mathematics.

By using smart contracts in blockchain technology, it becomes possible to create your own cryptocurrency and issue your own token. Token is a type of privately issued cryptocurrency, a unit of value that an organisation creates to regulate and self-govern its business model, and empower its users to interact with its products while facilitating the distribution and sharing of rewards and benefits to all of its stakeholders.

Most famous cryptocurrencies are Bitcoin (BTC) and Ether (ETH). They can be called as electronic cash.

Bitcoins can be exchanged for currencies, services or even goods. There is a public ledger called bitcoin blockchain that records bitcoin transactions. In this ledger, there are chains of blocks where each block contains a hash of the previous block.

An Overview of Smart Contracts

A smart contract as a collection of code stored in the blockchain network that defines conditions to which all parties using the contract agree upon.

It is a stand-alone script usually written in Solidity and compiled into binary or JSON and deployed to a specific address on the blockchain.

It enables developers to create things that haven’t been invented yet. There is no need for a third party (middleman). We can create new markets, store registries of debts or promises and rest assured that we have the consensuses of the blockchain network that validates the transactions.

Anyone can deploy a smart contract to the decentralised database for a fee proportional to the storage size of the containing code. Nodes wishing to use the smart contract must indicate the result of their participation to the rest of the network.

Advantages of smart contracts:

Autonomy — There is no need to rely on a broker, lawyer or other intermediaries to confirm. Incidentally, this also removes the danger of manipulation by a third party, since execution is managed automatically by the network.

Trust — The documents are encrypted on a shared ledger. Hence, anyone cannot deny anything.

Backup — The documents stored on the blockchain are duplicated.

Safety — By using cryptography for encryption, the documents are kept safe.

Speed — Smart contracts use software code to automate tasks, which saves a lot of time when compared to manually processing the tasks.

Savings — Smart contracts save money. Since there is no intermediary (third party) involved, there are no hefty fees.

Accuracy — Automated contracts are not only faster and cheaper but also avoid the errors that come from manually doing the tasks.

Ethereum

Ethereum is a platform that allows people to write decentralised applications using blockchain technology efficiently.

A decentralised application (Dapp) is a tool for people and organisations on different sides of an interaction used to come together without any centralised intermediary. Early examples of Dapps include BitTorrent (file sharing) and Bitcoin (currency).

We can describe Ethereum as a blockchain with a built-in programming language. The programming language used to write smart contracts in Ethereum is Solidity.

Ethereum Virtual Machine (EVM)

The EVM is a large, decentralized system containing millions of objects, called accounts, which can maintain an internal database, execute code and talk to each other.

The first type of account is EOA (Externally Owned Account); it is used to transmit value (such as Ether) and is controlled by a private key.

On the other hand, there is another type of account which is the contract which was discussed above.

Solidity Programming

The main language used in Ethereum is Solidity — which is a Javascript-like language developed specifically for writing smart contracts.

Solidity is statically typed, supports inheritance, libraries and complex user-defined types among other features.

The solidity compiler turns code into EVM bytecode, which can then be sent to the Ethereum network as a deployment transaction.

Advantages of Blockchain

  • Disintermediation: Any two parties can make an exchange without any intermediation of a third party. Thus, the parties which are communicating with each other will not face any interference from a third party. This helps in reducing, sometimes even eliminating risks.
  • Freedom in payment: With blockchain comes freedom and convenience in payment. Using bitcoin it is possible to send and receive money anywhere and anytime. You do not have to worry about the bank holidays, the receiver’s destination or any other such hurdles which normally occur while transferring money.
  • Decentralization and user empowerment: Blockchain technology discards the need of any third-party or central authority of peer-to-peer transactions. Users are in full control of all their information and transactions. Thus, blockchain technology ensures user empowerment. The user is able to see all the transfers made, and if any one goes wrong, the user knows exactly where his money is.
    Due to the decentralized network, there is no central point of failure in blockchain. Thus, failure of any one site will not affect the entire network. This leads to decreased number of malicious attacks
  • Control and Security: Blockchain allows users to be in full control of their information and transactions which leads to a safe and secure network. Merchants cannot charge extra fees on an anything without their concern. They must first confirm with the customers and ask for their approval before making any changes.
    Since all the personal information of users is kept hidden from other unauthorised users, blockchain protects against identity theft. Data encryption provides security. As a public ledger system, blockchain records and validates each and every transaction made, which makes it safe and reliable. All the transactions made are authorised by miners, which make them immutable.
  • High Quality data: The data in blockchain is of high quality, i.e. it is complete, correct, accurate and available to the users whenever they need it.
  • Speeding transactions: Bank transactions can sometimes take a lot of time (days) for completion of the transactions successfully and for the final settlement. Blockchain transactions can help reduce transaction time to minutes by processing the transactions on a regular daily basis.
  • Transparency: The changes done in the transactions can be viewed publicly by all users, thus creating a level of complete transparency.
  • Reduced transaction costs: Since a lot of overhead costs is reduced by eliminating third party intermediations, the overall transaction costs are also reduced.

Disadvantages of Blockchain

  • Lack of awareness: Many people are still unaware of Blockchain technology and its applications. Since there is very less awareness about Blockchain, many people don’t use it.
  • Managing risks of transition: The solutions offered by Blockchain applications require significant changes to or replacement of existing systems.
  • High Initial capital cost: Although Blockchain technology reduces transactional costs, the high initial capital costs are still there.
  • Large energy consumption: Blockchain technology uses substantial amounts of computer power.

Summary

Blockchain has shown its potential for transforming the traditional industry with its key characteristics: decentralisation, anonymity, integrity, immutability, transparency and security.

In this blog, a comprehensive overview on blockchain was presented.

We first went through an overview of blockchain technologies including the briefing about blockchain and its characteristics, it’s architecture and the key fundamental concepts behind blockchain. In the fundamental concepts, we also discussed about digital signature and data mining.

Then we went through a brief block overview seeing what each block in the series of blocks — blockchain contains and then we discussed about the different types of blockchain systems, comparing and contrasting them with one another.

We also discussed about the consensus, why it is needed and how it can be achieved using consensus algorithms which include Proof of Work (PoW) and Proof of Stake (PoS).

Then we discussed about the financial and non-financial applications of blockchain technology, an overview of cryptocurrencies, smart contracts, Ethereum development platform and Solidity programming.

Finally, the advantages and disadvantages of blockchain technology was listed along with a brief discussion.

Thank you!