# Secure PBFT Consensus-Based Lightweight Blockchain for Healthcare Application
## 3 Proposed Model  
### Practical Byzantine Fault Tolerance  
PBFT is designed based on the principle that the state machines result in the same output on any replica node for the same state and input parameter. The PBFT algorithm allows a distributed system to reach consensus even when a few nodes show malicious behaviors, i.e., if a distributed system consists of 3f+1 nodes (f represents the number of Byzantine nodes), a consensus can be reached as long as 2f+1 non-Byzantine nodes are functioning normally. The nodes in the algorithm have two roles, i.e., primary node and backup node. The primary node is in charge of segregating the transaction requests, sending transactions to backup nodes, and creating blocks after the verification process. The primary node is selected for a particular view using Equation (1)  
\[\text{primary\_node}=v\_num\mod|C| \tag{1}\]  
where \(v\_num\) is the view number, \(|C|\) is the total number of consensus nodes. The primary node will lead the PBFT consensus in the following three distinct phases:  
Pre-Prepare Phase: Based on the request received from the Client, the primary node will generate a prepared message \(<\)\(<\) PRE_PREPARE, \(v\_num\), N, D \(>\), t \(>\) for transactions and send it to each backup node by assigning a sequence number N, \(v\_num\) is the view number in which the message is sent, client's request message is t, and D is the message's digest. As soon as the backup receives the Pre-prepare message from the primary node, the messages are verified for the correctness and the primary node enters the Prepare phase. Prepare Phase: Each backup node in the network generates a Prepare Message \(<\) PREPARE, \(v\_num\), N, D, x \(>\) after accepting the Pre-Prepare Message, and sends the Prepare message to other backup nodes including the primary node. Soon after verifying the correctness of (t, \(v\_num\), N, x), all nodes will enter the Commit Phase. Commit Phase: Each and every backup node will generate the Commit message \(<\) COMMIT, \(v\_num\), N, D(t), x \(>\) and multicast it all other nodes by ensuring \(<\) PREPARE, \(v\_num\), N, D, x \(>\) is true for all backup nodes. After receiving 2F+1 Commit messages considering maximum faulty nodes F, from other backups the primary will create a block which is added to the blockchain. \begin{table}
\begin{tabular}{l l l l l l} \hline \hline \multirow{2}{*}{**Ref**} & \multirow{2}{*}{**Consensus Algorithm**} & \multicolumn{4}{c}{**Parameters**} & \multirow{2}{*}{**Remarks**} \\ \cline{3-4} \cline{6-6}  & & **Security** & & **Privacy** & **Communication Overhead** \\ \hline
[29] & Geographic-PBFT & MID & MID & HIGH & Proposed model selects geographically distributed, powerful, and authenticated IoT devices for consensus operation. \\ \hline
[30] & EPBFT & MID & LOW & HIGH & Proposed model does not perform a detailed assessment of the reliability of the nodes. \\ \hline
[21] & Reputation-based PBFT & MID & LOW & MID & Proposed model selects nodes with high reputation values which are given more priority in voting process. \\ \hline
[31] & HRPBT & MID & MID & LOW & Proposed model uses Hash ring to group the nodes. Primary node is elected based on the group. \\ \hline
[32] & MBFT & HIGH & MID & LOW & Proposed uses two-layered consensus algorithm. \\ \hline
[33] & Trust PBFT & HIGH & MID & LOW & Proposed model selects nodes based on the node trust value for the consensus operation \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Summary of existing PBFT consensus algorithms. The working of PBFT consensus algorithm is represented in Figure 2 by considering a primary node for the current view and backup nodes 1 to N, where backup node 3 is a faulty node identified during the process and which does not affect the actual process of the PBFT consensus. The existing model of PBFT has O(n\({}^{2}\)) communication complexity and the primary node is selected randomly from a set of nodes in the network. To design an optimized, secure, fault-tolerant PBFT consensus algorithm the VRF and Eigen trust algorithms are incorporated.