# Secure PBFT Consensus-Based Lightweight Blockchain for Healthcare Application
## 3 Proposed Model
### Node Grouping and Primary Node Selection Using Verifiable Random Function (VRF)  
Verifiable random function is a cryptographic hash function that processes input considering public key and proof and generates verifiable pseudorandom output [34]. Only the private key holder can compute the hash; however, the correctness of the hash can be verified by anyone with the corresponding public key. VRF consists of key generation function, evaluator function, and verification function. The private VRF key (sk) and public VRF key (pk) are created during the key generation function of VRF. Every consensus node can generate a random output Y by hashing an input value X with its private VRF key sk as in Equation (5)  
\[\text{Y}=\text{V}_{-}\text{Hash(sk, X)} \tag{5}\]  
The V_Hash function is deterministic, i.e., Y remains the same for a given pair of inputs (sk, X). The consensus node will use the private key (sk) to create Z to prove Y is the correct output as in Equation (6)  
\[\text{Z}=\text{V}_{-}\text{Prove(sk, X)} \tag{6}\]  
Every consensus node can deterministically obtain the VRF hash Y from Z as in Equation (7)  
\[\text{Y}=\text{V}_{-}\text{Prove\_Hash\_(Z)} \tag{7}\]  
Substituting Equations (5) and (6) in Equation (7)  
\[\text{V}_{-}\text{Hash}\ (\text{sk, X}\ )=\text{V}_{-}\text{Prove\_Hash(V}_{-}\text{ Prove(sk, X)}\ ) \tag{8}\]  
The zero-knowledge proof Z enables every consensus node to verify the correctness of Y for an input X using their public key (pk) using Equation (9)  
\[\text{V}_{-}\text{Verify}\ (pk,X,Z) \tag{9}\]  
The output of Equation (7) is Valid if the Y = V_Prove_Hash(Z) is correct using VRF hash and input X under public key (pk) and Invalid otherwise. The various steps involved in the proposed PBFT consensus algorithm are as follows:  
**Step 1:**_Identify the Global Trust value of each node present in the network using the Algorithm 1_. Figure 3: Node architecture with direct and indirect transactions. **Step 2:**_Choose a Primary Node using the VRF algorithm and divide the nodes into consensus node list and backup node list using global trust value as parameter._  
**Step 3:**_Primary node will execute the PBFT Consensus algorithm using set of consensus nodes._  
**Step 4:**_At the end of the consensus mechanism, the primary node will create a block with a valid transaction._  
**Step 5:**_Primary node will broadcast the updated block to both consensus node list and backup node list._  
Input: \(node_{p}\), \(setofNodes\)  
Output: Global trust \(GT_{p}\) of \(node_{p}\)  
\(GT_{p}\gets 0\)  
for \(node_{j}\)\(\in\) setofNodes do  
\(GT_{p}=\sum T_{qp}T_{q}\)  
end  
**Algorithm 1** Pseudo-code for calculating global trust. Figure 4 illustrates the various steps involved in the proposed secure PBFT-based blockchain consensus algorithm for healthcare applications. Figure 5 represents the healthcare use-case for demonstrating the proposed algorithm where the real-time health-related data of a patient will be stored in the blockchain as transactions then it is made available to various healthcare users for further analysis. During the process, the secure PBFT consensus algorithm with VRF and trust model will perform the transaction validation before adding the transaction to the block. The node participating in the consensus operation should be a trusted node and it should not be vulnerable to malicious activities. However, the initial level of trust analysis is achieved by computing the global trust value for all nodes in the blockchain network, considering the local trust. In later stages, the secure cryptographic sorting algorithm VRF separates the initial node list as consensus node list and backup node list. Only the nodes of the consensus node list can take part in the consensus process and a random primary node is also selected from the same set. At first, the global trust value is used as an added parameter in the VRF algorithm for choosing the primary node and consensus node list for a particular view.