# Blockchain Consensus Mechanism Based on Improved Distributed Consistency and Hash Entropy

Authors: Jue Ma
Journal: Scientific Programming
 (2021)

---

## Abstract

To improve the performance for distributed blockchain system, a novel and effective consensus algorithm is designed in this paper. It firstly constructs a more random additive constant through the generation matrix of the error correction code and uses the value of the hash entropy to prove that the constructed hash function can meet the requirements of high throughput and fast consensus in performance. In addition, a distributed consensus coordination service system is used in the blockchain system to realize the synchronization of metadata and ensure the consistency of block data, configuration information, and transaction information. The experiment results show that our proposed strategy can reduce the waste of computing resources, increase the block generation speed, and ensure the fairness of nodes participating in the competition, which is an effective solution to ensure the stable operation of the blockchain system.


---

## Body

## 1. Introduction

Blockchain is a technique of distributed database which is developed with the applications of digital encrypted currency [1]. A blockchain system has the characteristics of decentralization, nontampering, distributed consensus, provenance, and eventual consistency, which makes it be applied to solve data management problems of the encrusted environments [2].As a new distributed computing paradigm, it is the combination of point-to-point network, cryptography, distributed storage, and other technologies. It has attracted extensive attention from academia and industry and is mainly used in many fields such as finance, artificial intelligence, Internet of things, medical treatment, and so on [3].Consensus mechanism is an important part of blockchain technology. It is the key to building trust among untrusted participants. How to make each node efficiently reach a consensus on the effectiveness and consistency of block data in a decentralized system has always been the focus of blockchain technology research [4–7]. Consensus mechanism plays an important role in maintaining the security and efficiency of blockchain [5]. In other words, the correct consensus mechanism can improve the system performance. So far, many different types of blockchain consensus mechanisms have been developed, where the more classic is the proof of work (PoW) mechanism. Its core idea is that each node solves the hash problem through hash-rate competition, to ensure the consistency and consensus security of network distributed ledger. However, PoW needs to consume a lot of computing power and resources. In addition, due to the difference of computing power, there is an imbalance in the probability of packaging accounting right between each node [6].It is well-known that the consensus mechanism is closely related to the security, stability, and scalability of the blockchain system. The early Bitcoin system adopted the PoW mechanism, which took hash-rate computing power as a means of competition. At the same time, there were also problems such as excessive consumption of computing power, energy-power, and other resources [8, 9]. The proof of stake (PoS) consensus mechanism is an alternative solution to solve the security defects and resource waste of PoW consensus mechanism [10]. Coinage is introduced into the PoS mechanism as equity parameter, where the node with the highest equity (Coinage) rather than the highest computing power obtains the accounting right of the block. This greatly improves the consensus efficiency and throughput of the blockchain system to some extent but also intensifies the centralization trend for the blockchain system. The PoS mechanism essentially discloses the identity and wealth of stakeholders, so it seems to be incompatible with the cryptocurrency to protect privacy [11].Consensus mechanism is the algorithm for achieving distributed consensus on transactions in the blockchain system. It is the key to ensuring the consistency of transaction data management by each accounting node [12]. The current public blockchain system generally adopts consensus algorithms on basis of the improved PoW and PoS. The improved PoW algorithm prevents sybil attacks [13] by calculating complex mathematical problems, but it causes a decrease in consensus efficiency and a waste of computing resources, resulting in lower throughput and scalability of the blockchain system. With the gradual concentration of computing power, the computing power of a few mining pools can exceed 51% of the entire network’s computing power. It can be seen that PoW cannot guarantee against 51% attacks in the mode of computing power aggregation. Although the PoS consensus mechanism can solve the problem of 51% computing power attacks, there is a potential 51% equity monopoly problem, and there are still security issues when the block is forked. The DPoS consensus mechanism selects 101 nodes with equivalent accounting rights through equity voting, which solves the problem of the attacks on the computing power of PoW and the equity of PoS, but there are still 51% attacks on malicious nodes caused by the low participation voting.It can be seen from the above analysis that the consensus mechanism is one of the factors limiting the development of the current blockchain [14]. For the public-chain system, the consensus mechanism converges the computing power to a small number of nodes, resulting in a significant increase in the probability of 51% attacks. The essential reason is that the computing resources are easier to be concentrated to solve the decomposable centralized problem through the distributed processing environment. In other words, it can be seen that distributed technology brings security problems to blockchain system. In alliance chain and private chain systems, distributed consistency algorithms such as Pasox can be used to improve transaction verification throughput and reduce resource consumption. In terms of security, the problems faced by alliance chain and private chain systems are mainly Byzantine fault tolerance [15], which requires that the number of malicious nodes in the network should be less than 1/3 of the total number of nodes. In addition, a large number of improved consensus algorithms have been proposed to solve the efficiency and security problems of transaction verification in the blockchain system, including the proof of space (PoSp) [16], the authorized Byzantine fault-tolerant algorithm [17], hash graph and hierarchical consensus algorithm [18], etc. The core idea of PoSp is to determine the probability of obtaining the accounting right by proving the amount of data stored by the node, so as to solve the waste of computing resources and improve the verification efficiency. However, there is a potential 51% attack on storage space. Therefore, Hashgraph and HashNet algorithms are mainly aimed at Directed Acyclic Graph (DAG) blockchain system [16]. Hashgraph uses Gossip communication protocol and Byzantine protocol of virtual voting to realize transaction consensus. Its biggest feature is to realize asynchronous consensus. However, its main problem is that multiple rounds of voting verification may reduce the efficiency of consensus.Consistency is an important issue in distributed blockchain system. The center of the problem is to design appropriate protocols and algorithms so that nodes in the system can only use their own information and neighbors’ information under circumstances such as limited information, unreliable information exchanges, communication delays or input delays, and dynamic variations of communication typologies. In order to ensure data consistency and high availability which are the core features of a blockchain system, this paper will use BPFT protocol as the theoretical basis and design high availability scheme, which includes data synchronization, fault recovery, and synchronization. Therefore, our proposed algorithm firstly constructs a more random additive constant through the generation matrix of the error correction code and uses the value of the hash entropy to prove that the constructed hash function can meet the requirements of high throughput and fast consensus in performance. In addition, a distributed consensus coordination service system is used in the blockchain system to realize the synchronization of metadata and ensure the consistency of block data, configuration information, and transaction information.


## 2. Related Works

### 2.1. Hash Entropy

The hash function is one of the important data encryption protocols in the blockchain. Since the hash function has irreversible characteristics, it is used to ensure the security and the authenticity of the data, so the data in the blockchain is generally encrypted by the hash function. The blockchain usually uses theSHA256 function, and its encryption process of the hash function is mainly shown in Figure 1, where Key represents the key of the hash function. After weighting by the hash function, the corresponding hash value is obtained and is stored in the corresponding location in the hash table.Figure 1
Diagram for SHA256 function.For the rapid positioning of block data, Satoshi Nakamoto [17] proposed a simple payment verification method based on Bloom filter to solve the problems of excessive storage demand and storage redundancy in the Bitcoin system, which allows users to store part of the information to verify the transaction. The Bloom filter is implemented through a hash function, the transaction is weighted by the hash function, and then the information obtained according to the hash function is placed in the location of the hash table corresponding to the Bloom filter. In addition, only the hash table needs to be verified for each transaction. Due to the existence of the hash function, the storage of the blockchain is easier.Users in the blockchain and their account addresses are encrypted by digital signatures, but for some digital currency platforms, users need to make real-name requirements. When real-name users want to cash out their own currency in the blockchain, the own information, the relationship network, and the identity will be exposed, where this behavior greatly affects the confidentiality and security of the blockchain system.Hash entropy is an encryption algorithm in the blockchain. It is mainly used for miners who package and view transactions, which do not need to know the relevant data of both parties to the transaction and only need to verify the correctness of the transaction according to the hash value of the transaction [18, 19]. These traditional hash entropies require trusted initialization settings, which must be performed by a trusted third party. During the initialization process, some additional variables are often generated. Once these variables are leaked, the attacker can use them to generate false proofs that cannot be detected. It should be noted that the initialization setting is a one-time credible setting for a specific circuit. After the circuit is changed, the initialization setting needs to be performed again.In order to solve the above problems, some scholars recently proposed several improved encryption mechanisms. For example, Akhtar designed an open and transparent initialization setting to generate a common reference string (CRS) without additional variables in [20]. However, it is still impractical for these new constructions to be applied to the blockchain because their proof size is larger than the traditional construction scheme. Based on hash entropy, an effective privacy protection proposal for account-model blockchain is hiding users’ private data such as account balances, transaction amounts, and sender/recipient addresses. More specifically, a hash commitment is adopted to hide account balance and transfer amount, which is a statistically hiding noninteractive commitment scheme with hiding and binding properties.


### 2.2. Classical Distributed Consensus Algorithm

The distributed consensus mechanism refers to the state machine replication of a group of nodes in the authorized network. It is mainly for some distributed blockchain systems. For example, the Paxos algorithm is mainly designed for the collapsed nodes that may appear in the network; Practical Byzantine Fault Tolerance (PBFT) [16, 21] algorithm can tolerate a certain Byzantine Error node. The classic distributed consensus algorithm has a primary node and other replica nodes. As shown in Figure 2, the PBFT consensus mechanism mainly consists of two parts: The first part is the achievement of a distributed consensus, which is completed by the three steps of preparation, preparation, and commitment; the second part is view-change; when the master node has a problem and cannot process the data request in time, other replica nodes initiate the view after conversion; the new master node starts to work after the conversion is successful. The master node is alternately replaced in a round robin manner. The client uploads the request message m to the nodes in the network, including the master node and other replica nodes. The master node receives the request message m uploaded by the client, assigns the message sequence number s, and then calculates the pre-prepare message (H (m), s, v), where H (·) is a one-way hash function, and v represents the view at this time. The view is generally used to record the replacement of the master node. When the master node is replaced, the view increases 1. The message sender node needs to use its own private key to digitally sign the message before sending the message. The master node sends the pre-preparation message to other replica nodes. The replica node receives the pre-preparation message from the master node and verifies the validity of H (m). In other words, as for view v and sequence number s, the replica node has not received previously other messages. After the verification is passed, the replica node calculates the preparation message (H (m), s, v) and broadcasts it on the entire network. Simultaneously, all nodes collect the preparation message. If the number of the collected legal preparation messages is greater than or equal to 2f + 1 (including its own preparation message), it will be composed of a prepared certificate. If the node collects enough preparation messages and generates a preparation certificate in the preparation phase, then the node will calculate and broadcast the committed message (s, v), where the message m is put into the local log. At the same time, the node collects the committed message in the network. If the number of the collected legal committed messages is greater than or equal to 2f + 1 (including its own promise messages), it will be combined into a committed certificate, which prove that the message m completes the final commitment. The replica node and the master node arbitrarily collect enough committed messages and form the committed certificate, and it is sent to the client as a reply to message m, so the client confirms the final promise of message m.Figure 2
Flowchart of practical Byzantine fault tolerance.


## 2.1. Hash Entropy

The hash function is one of the important data encryption protocols in the blockchain. Since the hash function has irreversible characteristics, it is used to ensure the security and the authenticity of the data, so the data in the blockchain is generally encrypted by the hash function. The blockchain usually uses theSHA256 function, and its encryption process of the hash function is mainly shown in Figure 1, where Key represents the key of the hash function. After weighting by the hash function, the corresponding hash value is obtained and is stored in the corresponding location in the hash table.Figure 1
Diagram for SHA256 function.For the rapid positioning of block data, Satoshi Nakamoto [17] proposed a simple payment verification method based on Bloom filter to solve the problems of excessive storage demand and storage redundancy in the Bitcoin system, which allows users to store part of the information to verify the transaction. The Bloom filter is implemented through a hash function, the transaction is weighted by the hash function, and then the information obtained according to the hash function is placed in the location of the hash table corresponding to the Bloom filter. In addition, only the hash table needs to be verified for each transaction. Due to the existence of the hash function, the storage of the blockchain is easier.Users in the blockchain and their account addresses are encrypted by digital signatures, but for some digital currency platforms, users need to make real-name requirements. When real-name users want to cash out their own currency in the blockchain, the own information, the relationship network, and the identity will be exposed, where this behavior greatly affects the confidentiality and security of the blockchain system.Hash entropy is an encryption algorithm in the blockchain. It is mainly used for miners who package and view transactions, which do not need to know the relevant data of both parties to the transaction and only need to verify the correctness of the transaction according to the hash value of the transaction [18, 19]. These traditional hash entropies require trusted initialization settings, which must be performed by a trusted third party. During the initialization process, some additional variables are often generated. Once these variables are leaked, the attacker can use them to generate false proofs that cannot be detected. It should be noted that the initialization setting is a one-time credible setting for a specific circuit. After the circuit is changed, the initialization setting needs to be performed again.In order to solve the above problems, some scholars recently proposed several improved encryption mechanisms. For example, Akhtar designed an open and transparent initialization setting to generate a common reference string (CRS) without additional variables in [20]. However, it is still impractical for these new constructions to be applied to the blockchain because their proof size is larger than the traditional construction scheme. Based on hash entropy, an effective privacy protection proposal for account-model blockchain is hiding users’ private data such as account balances, transaction amounts, and sender/recipient addresses. More specifically, a hash commitment is adopted to hide account balance and transfer amount, which is a statistically hiding noninteractive commitment scheme with hiding and binding properties.


## 2.2. Classical Distributed Consensus Algorithm

The distributed consensus mechanism refers to the state machine replication of a group of nodes in the authorized network. It is mainly for some distributed blockchain systems. For example, the Paxos algorithm is mainly designed for the collapsed nodes that may appear in the network; Practical Byzantine Fault Tolerance (PBFT) [16, 21] algorithm can tolerate a certain Byzantine Error node. The classic distributed consensus algorithm has a primary node and other replica nodes. As shown in Figure 2, the PBFT consensus mechanism mainly consists of two parts: The first part is the achievement of a distributed consensus, which is completed by the three steps of preparation, preparation, and commitment; the second part is view-change; when the master node has a problem and cannot process the data request in time, other replica nodes initiate the view after conversion; the new master node starts to work after the conversion is successful. The master node is alternately replaced in a round robin manner. The client uploads the request message m to the nodes in the network, including the master node and other replica nodes. The master node receives the request message m uploaded by the client, assigns the message sequence number s, and then calculates the pre-prepare message (H (m), s, v), where H (·) is a one-way hash function, and v represents the view at this time. The view is generally used to record the replacement of the master node. When the master node is replaced, the view increases 1. The message sender node needs to use its own private key to digitally sign the message before sending the message. The master node sends the pre-preparation message to other replica nodes. The replica node receives the pre-preparation message from the master node and verifies the validity of H (m). In other words, as for view v and sequence number s, the replica node has not received previously other messages. After the verification is passed, the replica node calculates the preparation message (H (m), s, v) and broadcasts it on the entire network. Simultaneously, all nodes collect the preparation message. If the number of the collected legal preparation messages is greater than or equal to 2f + 1 (including its own preparation message), it will be composed of a prepared certificate. If the node collects enough preparation messages and generates a preparation certificate in the preparation phase, then the node will calculate and broadcast the committed message (s, v), where the message m is put into the local log. At the same time, the node collects the committed message in the network. If the number of the collected legal committed messages is greater than or equal to 2f + 1 (including its own promise messages), it will be combined into a committed certificate, which prove that the message m completes the final commitment. The replica node and the master node arbitrarily collect enough committed messages and form the committed certificate, and it is sent to the client as a reply to message m, so the client confirms the final promise of message m.Figure 2
Flowchart of practical Byzantine fault tolerance.


## 3. Our Proposed Consensus Strategy

### 3.1. Problem Description

Given a collectionP1,P2,…,Pn of data source suppliers and a collection U1,U2,U3 of data source users, the data source suppliers server group can constitute the data blockchain (DBC) and transaction blockchain (TBC) [17–22]. For a piece of raw data, a certain server node may be the data source supplier, and another piece of raw data is the data user. In addition, a bilinear mapping q,g,G1,GT,e is used to initialize the system parameters. H:0,1⟶0,1 is a one-way, anticollision hash function in cryptography and is instantiated using SHA-256. Let g1 be a generator different from g in G1, so the public parameters Param=q,g,G1,GT,e,g,1H can be obtained.The data source supplier divides the dataD to be uploaded into n blocks d1,d2,…,dn∈Zp, where p are a large prime number. In other words, the big data block D=dzz∈1,n is the basic unit of data sharing and flow path detection. A data source provider pi selects a random number x in zp∗ and generates a key pair pki,ski, where pk=gx and the random number x is the private key ski.


### 3.2. Reencryption with Hash Entropy

The compression function of SHA256 mainly operates on 512-bit message block and 256-bit intermediate hash value. In essence, it is a 256-bit encryption algorithm that encrypts the intermediate hash value by using the message block as a key. The data source supplierpi uses the public parameter param, public key pk and data plain-text dz to obtain the cipher-text after the first encryption. The encryption process is described as follows: A random number ri in zp∗ is selected, and the reencrypted cipher-text Cz can be calculated from the equation Cz=c1,c2,c3, where c1=gr1, c2=dz⋅eg1,pkir1, and c3=HHc1‖Hc1‖c2. And then, cipher-text set Czz∈1,n can be obtained, which can be stored into DBC through a consensus mechanism based on threshold cryptography. The decryption operation of data cipher-text first verifies whether the equation Cz=c1,c2,c3 is true. Otherwise, the data plain-text is calculated by the following equation:(1)dz=c2ec1.When the data source providerpi wants to share the data D with a data user or a data user buys the data D, pi needs to generate a reencryption key rki⟶j according to the public key pki, private key ski, and public parameter param; pi will use rki⟶j to convert the cipher-text encrypted by pki; then rki⟶j can be decrypted by private key of pi. The reencryption key generation process is written as follows:(2)rki⟶j=rk1,rk2,rk3,rk1=grj,rk2=g−skipkjrj,rk3=HHrk1Hrk1rk2,where rj is random number ri in zp∗.When the data source supplierpi broadcasts the reencryption key rki⟶j, the data sharing or delivery process is completed. The conversion of cipher-text can be completed after obtaining the reencryption key rki⟶j. The specific operations are as follows:(1)
Verify the following two equations. If the above equation does not hold, it indicates that there is a problem with the transmission and retransmission is requested. If the equation holds, continue step 2.(2)
Calculate the cipher-text setWjj∈1,n encrypted by the public key pkj of pi and convert the cipher-text in Wj=W^1,W^2,W^3,W^4, where W^1=c1;W^2=c2⋅ec1,rk2;W^3=rk1; and W^4=HHW^1‖HW^1‖W^2HW^2‖W^3.Ifpi wants to further obtain the plain-text of the data, it only needs to decrypt it with own private key. Firstly, it is verified whether equation (3) is true. If not, return to the initial verification. Otherwise, the plain-text dz=W^2/eW^1,W^3sk1 of the data block is calculated and output in turn.Similarly, the dataD=dzz∈1,n can be obtained to realize data sharing or transaction. After the data sharing or transaction is completed on the DBC, n data transaction record will be formed on the TBC (since the data is cut into n parts) and metadata records will be made. The nodes on the TBC query the authenticity of the transaction through the classic consensus mechanism based on threshold cryptography protocol. When it is true, the transaction will be placed in the transaction pool; otherwise, it will be discarded. Since the blockchain node will verify each transaction, the blockchain itself also has very good traceability, which will prevent the reselling of data and provide users with the function of data-flow path query.When the data source providerpi divides the raw data D to be uploaded into n data blocks d1,d2,…,dn, some of it could be embezzled. It is assumed that a data block dk is embezzled data. When the data block is packaged as an item and propagates on the TBC network, the node receiving the item will check one by one against a standard verification process list. If the data block dk is a shared data block, we can find the signature of ps from the signature pool and metadata information, which is to say the operation can complete the flow path query from ph to ps. Similarly, it can continue to trace the source of the original data block according to the signature stored in the item ofps. Therefore, log entries only flow from the leader to other servers, which simplifies the management of replicated logs. The reencryption key generation process uses a random timer for leader election, which only needs to add a small number of mechanisms to the heartbeats required by any consensus algorithm, while being able to resolve conflicts simply and quickly. In addition, our improved joint consensus method will allow the cluster to continue normal operation during configuration changes.


### 3.3. Improved Distributed Consistency

The matrix form of the standard weighted discrete consensus algorithm [18] model is(3)xk+1=pεwxk,pεw=In−εLnw,Lnw=W−1Ln,where x∈Rn is a consensus variable; ε is the iteration step; pεw is a nonnegative random matrix; W is a weighted matrix W=diagw1,w2,…,wn, wi≥1. When W is a unit matrix, it is the standard average discrete consensus algorithm; n is the number of vertices of the communication topology graph G; In is the n order unit matrix; Ln is the corresponding Laplacian matrix, where Ln=Dn−An. An is the adjacency matrix of the graph G and Dn is the dictionary matrix of the graph G.It can be emphasized that the value rangeε of the iteration step is often 0<ε<1/dmax in most literature, where dmax is the maximum vertex degree of the graph. The calculation equation of the range is simple, but relatively conservative. When Ln is unknown, the step size can be defined by this range; and when Ln is known, the value range of the iteration step size is denoted as follows:(4)0<ε<2ρW−1Ln,where ρ⋅ is the spectral radius of the matrix.It can be seen that the improved method takes the state difference between its own unit and the adjacent unit as the adjustment direction. It is a simple autonomous system. Through iterative calculation, the state variablex can be brought to the weighted average of the initial state x0.After continuous dynamic adjustment of nodes, the nodes in the alliance chain can achieve high credibility and rapid consensus, which increases the throughput of the blockchain system [23]. Before the consensus preparation stage, the improved consensus mechanism based on threshold cryptography algorithm uses weights to determine the probability of each node participating in the consensus.The ratio of the current weight to the initial weight is set as the probability distribution of the current node participating in the system consensus service [24], so as to reduce the number of nodes with more downtime and malicious behavior participating in the consensus as a whole, speed up the consensus efficiency and consensus communication process, and optimize the performance of blockchain system. The designed formula is written as follows:(5)P=wiW,where P represents the node’s participation probability, wi represents the current weight of the node, and W represents the initial value of the node’s weight.


## 3.1. Problem Description

Given a collectionP1,P2,…,Pn of data source suppliers and a collection U1,U2,U3 of data source users, the data source suppliers server group can constitute the data blockchain (DBC) and transaction blockchain (TBC) [17–22]. For a piece of raw data, a certain server node may be the data source supplier, and another piece of raw data is the data user. In addition, a bilinear mapping q,g,G1,GT,e is used to initialize the system parameters. H:0,1⟶0,1 is a one-way, anticollision hash function in cryptography and is instantiated using SHA-256. Let g1 be a generator different from g in G1, so the public parameters Param=q,g,G1,GT,e,g,1H can be obtained.The data source supplier divides the dataD to be uploaded into n blocks d1,d2,…,dn∈Zp, where p are a large prime number. In other words, the big data block D=dzz∈1,n is the basic unit of data sharing and flow path detection. A data source provider pi selects a random number x in zp∗ and generates a key pair pki,ski, where pk=gx and the random number x is the private key ski.


## 3.2. Reencryption with Hash Entropy

The compression function of SHA256 mainly operates on 512-bit message block and 256-bit intermediate hash value. In essence, it is a 256-bit encryption algorithm that encrypts the intermediate hash value by using the message block as a key. The data source supplierpi uses the public parameter param, public key pk and data plain-text dz to obtain the cipher-text after the first encryption. The encryption process is described as follows: A random number ri in zp∗ is selected, and the reencrypted cipher-text Cz can be calculated from the equation Cz=c1,c2,c3, where c1=gr1, c2=dz⋅eg1,pkir1, and c3=HHc1‖Hc1‖c2. And then, cipher-text set Czz∈1,n can be obtained, which can be stored into DBC through a consensus mechanism based on threshold cryptography. The decryption operation of data cipher-text first verifies whether the equation Cz=c1,c2,c3 is true. Otherwise, the data plain-text is calculated by the following equation:(1)dz=c2ec1.When the data source providerpi wants to share the data D with a data user or a data user buys the data D, pi needs to generate a reencryption key rki⟶j according to the public key pki, private key ski, and public parameter param; pi will use rki⟶j to convert the cipher-text encrypted by pki; then rki⟶j can be decrypted by private key of pi. The reencryption key generation process is written as follows:(2)rki⟶j=rk1,rk2,rk3,rk1=grj,rk2=g−skipkjrj,rk3=HHrk1Hrk1rk2,where rj is random number ri in zp∗.When the data source supplierpi broadcasts the reencryption key rki⟶j, the data sharing or delivery process is completed. The conversion of cipher-text can be completed after obtaining the reencryption key rki⟶j. The specific operations are as follows:(1)
Verify the following two equations. If the above equation does not hold, it indicates that there is a problem with the transmission and retransmission is requested. If the equation holds, continue step 2.(2)
Calculate the cipher-text setWjj∈1,n encrypted by the public key pkj of pi and convert the cipher-text in Wj=W^1,W^2,W^3,W^4, where W^1=c1;W^2=c2⋅ec1,rk2;W^3=rk1; and W^4=HHW^1‖HW^1‖W^2HW^2‖W^3.Ifpi wants to further obtain the plain-text of the data, it only needs to decrypt it with own private key. Firstly, it is verified whether equation (3) is true. If not, return to the initial verification. Otherwise, the plain-text dz=W^2/eW^1,W^3sk1 of the data block is calculated and output in turn.Similarly, the dataD=dzz∈1,n can be obtained to realize data sharing or transaction. After the data sharing or transaction is completed on the DBC, n data transaction record will be formed on the TBC (since the data is cut into n parts) and metadata records will be made. The nodes on the TBC query the authenticity of the transaction through the classic consensus mechanism based on threshold cryptography protocol. When it is true, the transaction will be placed in the transaction pool; otherwise, it will be discarded. Since the blockchain node will verify each transaction, the blockchain itself also has very good traceability, which will prevent the reselling of data and provide users with the function of data-flow path query.When the data source providerpi divides the raw data D to be uploaded into n data blocks d1,d2,…,dn, some of it could be embezzled. It is assumed that a data block dk is embezzled data. When the data block is packaged as an item and propagates on the TBC network, the node receiving the item will check one by one against a standard verification process list. If the data block dk is a shared data block, we can find the signature of ps from the signature pool and metadata information, which is to say the operation can complete the flow path query from ph to ps. Similarly, it can continue to trace the source of the original data block according to the signature stored in the item ofps. Therefore, log entries only flow from the leader to other servers, which simplifies the management of replicated logs. The reencryption key generation process uses a random timer for leader election, which only needs to add a small number of mechanisms to the heartbeats required by any consensus algorithm, while being able to resolve conflicts simply and quickly. In addition, our improved joint consensus method will allow the cluster to continue normal operation during configuration changes.


## 3.3. Improved Distributed Consistency

The matrix form of the standard weighted discrete consensus algorithm [18] model is(3)xk+1=pεwxk,pεw=In−εLnw,Lnw=W−1Ln,where x∈Rn is a consensus variable; ε is the iteration step; pεw is a nonnegative random matrix; W is a weighted matrix W=diagw1,w2,…,wn, wi≥1. When W is a unit matrix, it is the standard average discrete consensus algorithm; n is the number of vertices of the communication topology graph G; In is the n order unit matrix; Ln is the corresponding Laplacian matrix, where Ln=Dn−An. An is the adjacency matrix of the graph G and Dn is the dictionary matrix of the graph G.It can be emphasized that the value rangeε of the iteration step is often 0<ε<1/dmax in most literature, where dmax is the maximum vertex degree of the graph. The calculation equation of the range is simple, but relatively conservative. When Ln is unknown, the step size can be defined by this range; and when Ln is known, the value range of the iteration step size is denoted as follows:(4)0<ε<2ρW−1Ln,where ρ⋅ is the spectral radius of the matrix.It can be seen that the improved method takes the state difference between its own unit and the adjacent unit as the adjustment direction. It is a simple autonomous system. Through iterative calculation, the state variablex can be brought to the weighted average of the initial state x0.After continuous dynamic adjustment of nodes, the nodes in the alliance chain can achieve high credibility and rapid consensus, which increases the throughput of the blockchain system [23]. Before the consensus preparation stage, the improved consensus mechanism based on threshold cryptography algorithm uses weights to determine the probability of each node participating in the consensus.The ratio of the current weight to the initial weight is set as the probability distribution of the current node participating in the system consensus service [24], so as to reduce the number of nodes with more downtime and malicious behavior participating in the consensus as a whole, speed up the consensus efficiency and consensus communication process, and optimize the performance of blockchain system. The designed formula is written as follows:(5)P=wiW,where P represents the node’s participation probability, wi represents the current weight of the node, and W represents the initial value of the node’s weight.


## 4. Experiment and Result Analysis

### 4.1. Experiment Configuration

The improvement strategy designed in this paper is coded inPython 3 on basis of Python FlaskWeb framework, and the efficiency of node communication and data interaction is realized through socket network programming and JSON data exchange format [22]. A test blockchain with 8 nodes is built according to the consensus mechanism. Through experiments the block generation time, hash value of the improved consensus algorithm, the influence of the number of node accounting rights, and the influence on the number of node accounting rights are verified. This experiment also compares the results of other consensus algorithms to verify the performance of the consensus algorithm. The configuration information is shown in Table 1.Table 1
Configuration information.
Node nameAddressCPURAMOSNode_10fd78b963...I5-106008Win 10Node_23ed8fr23a1...I3-62008Win 7Node_34ebde2ed3...I5870016Win 10Node_431cb2cd41...AMD-6800M8MacOS 11.2Node_5c1d2ab123d...I7-61004Win 7Node_638d057840...I5-1060016MacOS 11.2Node_7a3c6a92da...I3-62008Win 7Node_84d6f9fh85...I5-87008Win 10In the experiment, the client node sends a request to the consensus nodes through the interface, the request contains the required JSON format data, the consensus completion result is stored in the database, and the client query directly queries the database through the interface. In practical applications, the packaged consensus module, storage module, access module, etc. can be directly used to modularize the distributed system, and the systems can call each other through the request interface. In order to verify the superiority of the improved consensus strategy, some comparison algorithms are tested through the blockchain system. In the system, the Random function is used to randomly determine whether a node has malicious or downtime behavior during the current consensus process.


### 4.2. Time-Delay Analysis

Time-delay is one of the important indicators to evaluate the performance of consensus algorithms. Time-delay mainly refers to the time it takes for a user to submit a request to reach a consensus. A lower delay can improve the commercial performance of the alliance chain system and complete more business processing.Different block generation time in the blockchain system means that the size of the transaction information accumulated during this period is different. Different data sizes will directly affect the system’s network communication time, so the block generation time has a strong impact on the consensus delay. This experiment uses a combination of multiple node numbers in the consensus network, a single test is performed 10 times, and the average value of the 10 times is used as the final experimental data of the current block generation time to test the impact of different block generation times on the consensus time-delay.From the above results in Table2, it can be found that the average delay of our proposed model is 17.59% lower than that of HPoW and 12.1% lower than that of HPoS.Table 2
Average time-delay.
4 nodes8 nodes12 nodes16 nodesAverageResult_1Result_2PoW156168175198172.1——PoS148152168174165.27.11%—Proposed129136145152148.117.59%12.11%With the increase of generation time, the consensus delay of the blockchain system also increases. When the system block generation time is greater than a certain value, the consensus delay increases exponentially. The increase of block generation time means that more transaction information will be generated in this time interval, resulting in the increase of consensus delay. Due to the multiple forwarding of transaction information in the consensus process, when the amount of data acceptable to the system node is exceeded, the system consensus will be blocked, and the consensus delay increases exponentially. Compared with HPoW and H PoS, our proposed model increases the node reward and punishment mechanism, optimizes the consensus process, and reduces the steps of consensus communication. In the experiment, we assume that the amount of transaction information is fixed, set the same block generation time, and conduct 20 consensus experiments. The simulation machine carries out the control experiment in the real environment. The experimental results of the three algorithms are shown in Figure3.Figure 3
Time-delay for different algorithm. (a) 10 blocks, (b) 20 blocks.
(a)(b)Our proposed model reduces the time cost of calculating the random number by dynamically adjusting the difficulty value. The difficulty value is set to 6 and the first 6 bits of the calculated hash value are obtained. The average time of each block is about 1 min. Set up the operation experiment of the blockchain system and record the time spent for each block. In the first 100 blocks, every 10 blocks are interval, and calculate the average value of block time. The statistical results are shown in Figure4. It can be seen from the experimental results that the fluctuation range of the obtained curve is small. Except that the blocking time of some blocks exceeds 1 min, most of the blocking time is about 1 min. At the same time, the concept of variance is introduced to calculate the variance of the blocking time of our proposed model. The average blocking time of the first 100 blocks is 58.1 s. After calculation, the variance is 45.89. This is because a small part of the data fluctuates greatly. Therefore, the variance is relatively large. However, the experimental results basically meet the requirements, improve the transaction efficiency of the blockchain system, and save a lot of time and computing resources.Figure 4
Comparison of consensus times for different algorithms.


### 4.3. Throughput Analysis

Data throughput is also an important indicator to measure the consensus algorithm. Throughput is a measure to process transactions, requests, and transactions per unit time. In the blockchain, it is expressed as the number of transactions packaged in a unit of time. Figure5 shows the relationship between the time of different algorithms and the number of packaged transactions. The slope of its tangent line at a certain point indicates the data throughput of the time period. From the slope of the curve, it can be seen that as time increases, the average data throughput gap of the four algorithms gradually increases. The throughput of the proposed algorithm is relatively close to that of the HPoS algorithm, but slightly larger than the throughput of the HPoS algorithm, and is always much greater than the throughput of the HPoW algorithm. Compared with the HPoW algorithm, the throughput of the HPoW algorithm is not as good as the proposed algorithm, so the proposed algorithm has better throughput performance.Figure 5
Comparison of the number of transactions for different algorithms.In the alliance chain system, the consensus requires multiple complicated communication between nodes. The proposed strategy optimizes the communication process. In the experiment, the improved model is used in a simulated environment, where variables such as block time, number of nodes, and transaction information are set to fixed values. The experimental results of the throughput of the three algorithms can be analyzed in Figure5, where we also analyze the performance of the proposed strategy without hash entropy. Compared with these comparison algorithms, the consensus throughput of our proposed algorithm is significantly improved.


### 4.4. Security Analysis

The consensus algorithm mainly refers to the incidence of malicious behavior. In the current complex network environment, ensuring the safe and stable operation of the blockchain is the focus of current research. The security performance analysis of the proposed consensus blockchain system is as follows: Blockchain is a special distributed database system in which each node stores a copy of transaction information. When a node in the blockchain is attacked, other nodes can verify the misinformation data spread by the malicious node so as to ensure the correctness of the entire blockchain system. Therefore, for a single attack on a node, the system has the capability of Denial-of-Service attack.The proposed consensus algorithm can provide the corresponding consensus participation access mechanism for the nodes in the system. The system can decide whether to participate in the current consensus on the basis of the historical data of the nodes, thereby shielding possible malicious behaviors and reducing the overall number of occurrences of malicious behaviors. The proposed strategy can help the blockchain system to improve its robustness, so that the system can operate more efficiently.Under the improved mechanism, the hash value of the node that successfully obtains the package accounting right (PAR) will be reduced by about half, and it will take a long time to accumulate to reach the level of competition with a higher probability of the package accounting right. If there is a collusion attack, the node will transfer its own hash value to other benefiting nodes. Even if the benefiting node obtains the right to package accounting and obtains the benefits, it does not matter to the node that transfers the value or to the benefiting node.As shown in Figure6, the average malicious behavior rates of comparison algorithms are 30%, 18.72%, and 15.65%, respectively. The experimental results show that the improved strategy has obvious advantages in reducing the probability of malicious behavior in the blockchain system and effectively improves the security of the system.Figure 6
Average malicious behavior rates of comparison algorithms.


## 4.1. Experiment Configuration

The improvement strategy designed in this paper is coded inPython 3 on basis of Python FlaskWeb framework, and the efficiency of node communication and data interaction is realized through socket network programming and JSON data exchange format [22]. A test blockchain with 8 nodes is built according to the consensus mechanism. Through experiments the block generation time, hash value of the improved consensus algorithm, the influence of the number of node accounting rights, and the influence on the number of node accounting rights are verified. This experiment also compares the results of other consensus algorithms to verify the performance of the consensus algorithm. The configuration information is shown in Table 1.Table 1
Configuration information.
Node nameAddressCPURAMOSNode_10fd78b963...I5-106008Win 10Node_23ed8fr23a1...I3-62008Win 7Node_34ebde2ed3...I5870016Win 10Node_431cb2cd41...AMD-6800M8MacOS 11.2Node_5c1d2ab123d...I7-61004Win 7Node_638d057840...I5-1060016MacOS 11.2Node_7a3c6a92da...I3-62008Win 7Node_84d6f9fh85...I5-87008Win 10In the experiment, the client node sends a request to the consensus nodes through the interface, the request contains the required JSON format data, the consensus completion result is stored in the database, and the client query directly queries the database through the interface. In practical applications, the packaged consensus module, storage module, access module, etc. can be directly used to modularize the distributed system, and the systems can call each other through the request interface. In order to verify the superiority of the improved consensus strategy, some comparison algorithms are tested through the blockchain system. In the system, the Random function is used to randomly determine whether a node has malicious or downtime behavior during the current consensus process.


## 4.2. Time-Delay Analysis

Time-delay is one of the important indicators to evaluate the performance of consensus algorithms. Time-delay mainly refers to the time it takes for a user to submit a request to reach a consensus. A lower delay can improve the commercial performance of the alliance chain system and complete more business processing.Different block generation time in the blockchain system means that the size of the transaction information accumulated during this period is different. Different data sizes will directly affect the system’s network communication time, so the block generation time has a strong impact on the consensus delay. This experiment uses a combination of multiple node numbers in the consensus network, a single test is performed 10 times, and the average value of the 10 times is used as the final experimental data of the current block generation time to test the impact of different block generation times on the consensus time-delay.From the above results in Table2, it can be found that the average delay of our proposed model is 17.59% lower than that of HPoW and 12.1% lower than that of HPoS.Table 2
Average time-delay.
4 nodes8 nodes12 nodes16 nodesAverageResult_1Result_2PoW156168175198172.1——PoS148152168174165.27.11%—Proposed129136145152148.117.59%12.11%With the increase of generation time, the consensus delay of the blockchain system also increases. When the system block generation time is greater than a certain value, the consensus delay increases exponentially. The increase of block generation time means that more transaction information will be generated in this time interval, resulting in the increase of consensus delay. Due to the multiple forwarding of transaction information in the consensus process, when the amount of data acceptable to the system node is exceeded, the system consensus will be blocked, and the consensus delay increases exponentially. Compared with HPoW and H PoS, our proposed model increases the node reward and punishment mechanism, optimizes the consensus process, and reduces the steps of consensus communication. In the experiment, we assume that the amount of transaction information is fixed, set the same block generation time, and conduct 20 consensus experiments. The simulation machine carries out the control experiment in the real environment. The experimental results of the three algorithms are shown in Figure3.Figure 3
Time-delay for different algorithm. (a) 10 blocks, (b) 20 blocks.
(a)(b)Our proposed model reduces the time cost of calculating the random number by dynamically adjusting the difficulty value. The difficulty value is set to 6 and the first 6 bits of the calculated hash value are obtained. The average time of each block is about 1 min. Set up the operation experiment of the blockchain system and record the time spent for each block. In the first 100 blocks, every 10 blocks are interval, and calculate the average value of block time. The statistical results are shown in Figure4. It can be seen from the experimental results that the fluctuation range of the obtained curve is small. Except that the blocking time of some blocks exceeds 1 min, most of the blocking time is about 1 min. At the same time, the concept of variance is introduced to calculate the variance of the blocking time of our proposed model. The average blocking time of the first 100 blocks is 58.1 s. After calculation, the variance is 45.89. This is because a small part of the data fluctuates greatly. Therefore, the variance is relatively large. However, the experimental results basically meet the requirements, improve the transaction efficiency of the blockchain system, and save a lot of time and computing resources.Figure 4
Comparison of consensus times for different algorithms.


## 4.3. Throughput Analysis

Data throughput is also an important indicator to measure the consensus algorithm. Throughput is a measure to process transactions, requests, and transactions per unit time. In the blockchain, it is expressed as the number of transactions packaged in a unit of time. Figure5 shows the relationship between the time of different algorithms and the number of packaged transactions. The slope of its tangent line at a certain point indicates the data throughput of the time period. From the slope of the curve, it can be seen that as time increases, the average data throughput gap of the four algorithms gradually increases. The throughput of the proposed algorithm is relatively close to that of the HPoS algorithm, but slightly larger than the throughput of the HPoS algorithm, and is always much greater than the throughput of the HPoW algorithm. Compared with the HPoW algorithm, the throughput of the HPoW algorithm is not as good as the proposed algorithm, so the proposed algorithm has better throughput performance.Figure 5
Comparison of the number of transactions for different algorithms.In the alliance chain system, the consensus requires multiple complicated communication between nodes. The proposed strategy optimizes the communication process. In the experiment, the improved model is used in a simulated environment, where variables such as block time, number of nodes, and transaction information are set to fixed values. The experimental results of the throughput of the three algorithms can be analyzed in Figure5, where we also analyze the performance of the proposed strategy without hash entropy. Compared with these comparison algorithms, the consensus throughput of our proposed algorithm is significantly improved.


## 4.4. Security Analysis

The consensus algorithm mainly refers to the incidence of malicious behavior. In the current complex network environment, ensuring the safe and stable operation of the blockchain is the focus of current research. The security performance analysis of the proposed consensus blockchain system is as follows: Blockchain is a special distributed database system in which each node stores a copy of transaction information. When a node in the blockchain is attacked, other nodes can verify the misinformation data spread by the malicious node so as to ensure the correctness of the entire blockchain system. Therefore, for a single attack on a node, the system has the capability of Denial-of-Service attack.The proposed consensus algorithm can provide the corresponding consensus participation access mechanism for the nodes in the system. The system can decide whether to participate in the current consensus on the basis of the historical data of the nodes, thereby shielding possible malicious behaviors and reducing the overall number of occurrences of malicious behaviors. The proposed strategy can help the blockchain system to improve its robustness, so that the system can operate more efficiently.Under the improved mechanism, the hash value of the node that successfully obtains the package accounting right (PAR) will be reduced by about half, and it will take a long time to accumulate to reach the level of competition with a higher probability of the package accounting right. If there is a collusion attack, the node will transfer its own hash value to other benefiting nodes. Even if the benefiting node obtains the right to package accounting and obtains the benefits, it does not matter to the node that transfers the value or to the benefiting node.As shown in Figure6, the average malicious behavior rates of comparison algorithms are 30%, 18.72%, and 15.65%, respectively. The experimental results show that the improved strategy has obvious advantages in reducing the probability of malicious behavior in the blockchain system and effectively improves the security of the system.Figure 6
Average malicious behavior rates of comparison algorithms.


## 5. Conclusion

The improved distributed consensus algorithm constructs a more random additive constant through the generation matrix of the error correction code and uses the value of the hash function information entropy to prove that the constructed hash function can meet the requirements of high throughput and fast consensus in performance. In addition, a distributed consensus coordination service system is used in the blockchain system to realize the synchronization of metadata and ensure the consistency of block data, configuration information, and transaction information. The experiment results show that the proposed strategy can reduce the waste of computing resources, increase the block generation speed, and ensure the fairness of nodes participating in the competition, which is an effective solution to ensure the smooth operation of the blockchain.However, our proposed algorithm still needs to be actively explored and improved. The design of consensus algorithm with high-throughput and low-delay performance is the focus of blockchain technology development. The transaction processing capacity of our proposed algorithm needs to be improved. For example, the cross-chain consensus of multichain architecture (including isomorphic or heterogeneous blockchain) can greatly improve transaction performance, which will be one of our research directions in the future [25].



---

*Source: 2030810-2021-11-23.xml*