Blockchain Technology Consensus Algorithms and Applications: A Survey

—One of the new promising technologies for the future is block-chain. It has become one of the popular techniques for various transactions and applications in many different areas such as economy, business, and government. Blockchain technology started with cryptocurrency and bitcoin applications for a safe and transparent environment. Blockchain is a hybrid technology that incorporates various technologies and tools such as mathematics, peer-peer networking, cryptography algorithms, and consensus algorithms. This survey highlights the latest studies in blockchain and consensus algorithms. The study covers the most recent blockchain applications in various domains and sectors. Furthermore, the study gives an insight into the latest adoption of the blockchain in the real world.


Introduction
Blockchain technology received significant attention recently due to the potential of applications it can support in a new and more cost-effective approach. Blockchain has started in 2008 with the idea proposed by Nakamoto [1] who introduced Bitcoin as a new payment method that helps reduce the role of the third party in verification and validation of payment transaction. Nakamoto's idea changed the traditional way of financial transactions that required a third party to verify the movements of people's money. It transmits a transaction method from being centralized to decentralized. Since 2009, many variations of bitcoin have been proposed, such as ethereum [2], and nxtcoin [3]. A common feature among these variants is that anyone who wants to keep a ledger can also join, also pull at any time. Therefore, these types are being considered public Blockchains. Blockchain is now utilized in a wide range of applications such as financial, government, supply chain and internet of things (IoT). Blockchain provides a safe and transparent environment that allows a transaction over a distributed environment with no entral node to control and own the entire transaction. Thus, any node can join the network and make transactions. The distributed nature of Blockchain avoids it the single point of failure issues and offers high integrity for transactions and data against intentional and unintentional corruption. All users can use their devices to keep a large number of transaction records in blocks that construct the chain. Blockchain has different characteristics and features, the following are its main characteristics: • Decentralization: Blockchain changes the idea that requires a central node or a third party to store or verify any transaction by requiring a set of nodes to do so. Storing and updating data occur in a distributed manner. • Immutability: A Blockchain transaction is recorded in a decentralized permanent record, it cannot be changed or altered once it is added. After a transaction is added, it is stored in a distributed database. This brings more trust in the transaction record. • Transparency: Blockchain users can view their data and transactions in a transparent manner to all nodes. Transparency is a key element in the Blockchain for several applications such as supply chain, and financial services. • Anonymity: It allows users to perform anonymous transactions, the user is linked with public address and no one will know the actual name or address. Cryptography methods are used to conceal the user identity. • Consensus Driven: The verification and adding of each block to the Blockchain achieved by reaching agreement among all Blockchain nodes. This agreement happens using a consensus algorithm that encompasses rules for validating a block.
There is a tremendous amount of research in blockchain technology. Blockchain research can be classified into three categories, the first category of research focuses on blockchain security and developing and implementing new approaches to increase the security of the blockchain [4], [5]. The second category focuses on the consensus algorithms, suggesting a new algorithm, or making some variations on the existing algorithm, or building hybrid approaches of existing algorithms [6]. The third category focuses on Blockchain applications, and the adaptation and utilization of Blockchain in different areas [7], [8], [9]. In this survey, we provide an overview of the Blockchain according to the three aforementioned categories. This paper is organized as follows. We discuss Blockchain types in section two. Blockchain architecture is introduced in section three. Blockchain consensus algorithms are presented in section four. Blockchain adaptation and applications are introduced in section five, and section six provides the conclusion.

Types of Blockchain
There are three types of blockchain: Public, consortium, and fully private blockchains. These types can be classified into two categories permissionless and permission-based blockchain. In a permissionless blockchain, the access permissions in this type are not controlled such as in public blockchain. In a permission-based blockchain, the access permissions are more tightly controlled, it involves the consortium and a fully private blockchain [10], The following is the description of blockchain types:

Blockchain Architecture
Blockchain is considered as a public ledger and all the verified transactions are stored in a chain that includes blocks. The blocks are added continuously to this chain, and the chain grows with each block addition. To secure this ledger, there are different cryptography algorithms and consensus protocols used to protect the blocks from modifications and secure the blockchain from several attacks. One of the important cryptographic algorithms used in bitcoin is SHA-256, it is a hashing algorithm used for hash calculation. It takes an input of variable size to produce fixed size output, the size of output hash value using this algorithm is 256 bits. Besides the security aspect, hashing prevents users from changing the block data, since any tiny change in the blockchain block, will change the hash value completely. Blockchain uses public-key algorithms for digital signature which securely verifies the identity of a user. The public-key algorithm used in bitcoin is the elliptic curve algorithm. It is an asymmetric algorithm that uses two keys that are mathematically related, the public and private keys. The private key must be kept secret for the user and is used just by the user who owns it to encrypt the transaction when the purpose is user digital signature. The public key of the sender is used by the recipient to decrypt that transaction to validate the message integrity.

Block
The blockchain is the sequence of blocks as shown in figure 1. The block is a data container that contains a set of transactions distributed to all nodes in the network. The first block in the blockchain is called genesis block, this block does not have parent block so the previous hash for it equals zero. Blockchain's block contains two parts: header and data. Each block contains 256 bits hash value of the previous block in the chain called parent hash code which od placed in the header part. There are two more components in block header: basic information and Merkel root hash parts [8]. The header block main components are:

Merkle tree
The fundamental component of blockchain is Merkle Tree [1]. Merkle tree allows secure verification of the contents of stored data. It generates one hash value of all transactions contained in a single block. The maximum number of transactions in each block depends on the block and transaction size. The first step in forming a Merkle tree is to perform a hash on each of the transactions. Each transaction goes through a hash function to get the transaction hash value that has a fixed size. Another hashing is performed in a Merkle tree. The previously created transactions hash values are put in pairs and the hashing is performed on that pair of hashes and once they have paired and hashed, they have paired again and hashed, this process of hashing is continuing until all transaction just meet at a single hash. This single hash is called the Merkle root. The Merkle tree is illustrated in figure 2.

Smart contracts
Smart contracts are digital, distributed contracts, assure the agreement between two parties to be done efficiently and secure regarding the transactions in the network. Smart contracts are tiny computer programs stored inside the blockchain [8]. They can be accessed by every node in the blockchain and every node can interact with. They share the blockchain with immutability characteristics, no one can change the smart contract and there is a consensus for the contract. Smart contracts are used in blockchain transactions and secure the network against attacks that aim to steal or tamper with the assets. Ethereum implements and runs smart contracts. Ethereum serves many different functions to the users, after sending their transactions to Ethereum network they can order new contacts and use functions of the contract. These transactions are recorded on the blockchain. [12], [13].

Consensus Algorithms
All entities in the decentralized network must agree about the transaction in the network, check blockchain validity and determine if it will be added to blockchain or not, and which block to add next. For bitcoin, all entities must agree on the transaction history as decentralized networks have no centralization and no trust between network entities, the challenge here is how all these entities can agree on the correct state of the data record and how they all achieve consensus. There is a different implementation for consensus mechanisms for consensus algorithms that are used in different blockchain applications [14], they vary in different terms such as decentralization. In this section, we will summarize up to date consensus algorithms that are used in the technology of blockchain.

Proof of work
The first consensus algorithm is proof of work (PoW) which is used in the bitcoin network [1]. Proof of work idea focuses on the concept of all entities in a distributed network racing to get the solution of a difficult puzzle of calculating a hash value to get the right one to add the new block to the chain and get the reward as shown in figure 3. There are different variations of proof of work in literature. King [15] suggests a new type of PoW based on using searching for prime numbers in peer2peer designs instead of not hashcash proof of work. Cunningham and bitwin chain are used as a prime chain in the puzzle of proof of work. Another puzzle that is applied for proof of work is proposed in [16], it focused on applying the puzzle in two phases while in [17], Nonoutsourceable puzzles are proposed. Proof of work is a good approach to the agreement, but it has the main disadvantage regarding efficiency. Proof of work is expensive in computation. This motivates us to propose new consensus algorithms to solve this inefficiency in proof of work algorithm. Proof of stake (PoS) is coming to solve this issue.

Proof of stake
It has an advantage over proof of works that it is more energy-efficient algorithm. In proof of work, a massive amount of energy is consumed and huge computing power is used which will spend a big amount of resources on the blockchain while using proof of stake consensus algorithm there is less computation performed [18], [19]. The node has stake coins in order to get the chance to be one who has the right to add the next block to the chain. Proof of stake concept has been discussed extensively in different types of research with the main goal of how to provide secured blockchain against any future attacks [20].

Delegated proof of stake
Delegated proof of stake is another consensus algorithm. Its idea main about the stakeholders able to select a leader who votes for them and potentially passes some rewards as well. These leaders can be voted in or out at different times and they produce blocks in around robin fashions so they do not get to put them all in a row. This algorithm is more centralized, and it can operate much faster than other algorithms. One problem of this algorithm is the wealthy nodes have a lot of power in this approach and they can vote themselves in or put their friends in. [21].

Proof of activity
Proof of activity consensus algorithm is proposed, it is a hybrid approach that includes proof of work and proof of stake [22]. It starts with a proof of work allowing minors to mine empty template without any transactions then it switched to proof of stake where validators select a block to sign and rewards get split between both proof of work minor and the staker [22].

Proof of authority
This protoacol also solved the PoW energy consumtion. De Angelis et al. [23] proposed a proof of authority consensus, its idea focus on validators or notes are approved or public identities and they must publicly have verified and they must operate what it is called authority node. This protocol is not consecutive block approval and the incentive is not playing with error probability because the identity is known, this protocol can be used in public or private networks.

Proof of space or proof of capacity
The difference between the proof of work and this protocol is that here the blockchain node, instead of using computation power or the processing, it allocates an amount of disk space or memory in order to solve challenge terms to get the ability to add next block. It is a good approach that more resource that deeply apply proof of work [24].

Proof of importance
It is an expanded version of proof of stake, its idea focuses on not only the stake or amount of coins should be considered but instead, there are other metrics should be taken into consideration. It has the disadvantage that it is wasteful of resources [25].

Proof of burn
The node has to send a coin to burn address which is irretrievable in order to get a chance to mine, the chance that the node selected to mine increases with the number of coins you burn [26].

Practical byzantine fault tolerance
In case if there are malicious nodes in the system, a practical byzantine fault tolerance algorithm solves this issue. It is a replication algorithm to tolerate byzantine faults used by hyper ledger, the distributed computer network might be able to reach consensus despite the existence of some nodes that are failing or sending incorrect information. This protocol helps in reducing the effect of these nodes on the overall system [27].

Ripple
Ripple consensus algorithm is efficient within a larger network. It can utilize the presence of trusted sub-networks. It works in a cooperative manner rather than competitive; the nodes cooperate to agree on the ordering and validity of transactions in the network. This means that the nodes are working with each other instead of against each other which is a lot more efficient [28].
Nguyen et al [29], classified consensus protocols in two categories: proof-based and voting-based. Proof-based needs joining between nodes in verification to determine which nodes qualified than others to add blockchain block. Voting based needs that the blockchain node to exchange the results after a new block or transaction verification. Table 2 summarizes the consensus algorithms reference studies based on consensus classification in [29].

Blockchain Adaptation and Applications
Several organizations can take an advantage of blockchain major advantages: transparent, decentralized, efficient and secure. It is likely to disrupt many industries that have a middleman or third party. Many industries in this age direct to change their strategies and operations from a centralized approach to decentralized, such as banking and payments since blockchain may give financial services to people around the world [40]. There has also been widespread optimism regarding the application of blockchain such as supply chain management, human resources, forecasting, Internet of things, and healthcare [41]. Blockchain technology used in supply chain management to put the transaction in decentralized form, all distribution chain transactions are easily recorded and monitored, this minimizes the chance to errors and mistakes. Many charity organizations also used blockchain to distribute the aids in a way that assures the delivery of aids to whom deserves it, monitoring this can be done using blockchain. Blockchain technology is also applied to the Internet of Things (IoT) [42]. The traditional approach of IoT that there are many daily used devices or certain-application devices controlled by a central point, blockchain changes this approach to be distributed approach and the devices can communicate with others directly. Using smart contracts enables the buyer to buy from a seller without a central party such using the smart contract in certain industries such as retail, music, land registration and property transferring, insurance and energy management. Table 3 summarizes the blockchain applications and shows blockchain adaptation examples. Education Helps in online education, blockchain Technology can store learning records in a trusted, distributed manner, and provide credible digital certificates. It also helps in sharing information resources and enhance digital competence by the assessment of cooperative education E-Portfolio Full record of learning trajectory and trusted certification [78] Cloud-based Blockchain E-portfolio for cooperative education management system [79] 6

Conclusion and Future Work
Blockchain technology seems is a key technology for the future which has attracted business, and government sectors to use that technology to improve many offered services. It is originally introduced for the digital currency bitcoin then it has evolved into something bigger. Blockchain is a revolutionary technology that might change the current exchanging transactions especially the money and property transfer. In this survey, we presented a survey of blockchain technology and highlighted the latest studies in blockchain and consensus algorithms. Moreover, we discussed the latest adaptation of the blockchain. It is observed that developing blockchain is fast and spreads to cover a wide area of applications, and the system applications move away from centralization to decentralization and this concept is achieved by applying blockchain. As future work, we will consider the security of blockchain systems and address the attacks and privacy issues associated with blockchain to give a comparative analysis of different security mechanisms that are used to increase blockchain security and privacy. Moreover, we will focus on new research directions for two important blockchain applications: cloud computing and IoT.