| Algorithm 3. BSF-EHR Blockchain Validation Algorithm | ||
| Input | : | Patient Pat1 blockchain |
| Output | : | Safe or not |
| Step 1 | : | Blockchain BC ← Download Blockchain of Patient Pat1 |
| Step 2 | BlockchainStatus = “Safe” | |
| Step 3 | : | FOR each Block B from BC |
| Step 4 | : | Block → Retrieve encryptedEHR, hash with Bilinear Map from the block |
| Step 5 | : | newHash ← Generate new hash for encryptedEHR based on HMAC-SHA1 |
| Step 6 | : | newBilinearMap ← Generate new bilinear maping for encryptedEHR with patient ID |
| Step 7 | : | IF ((hash == New Hash)&(Bilinear Map = newBilinearMap)) |
| Step 8 | : | Block is safe |
| Step 9 | : | ELSE |
| Step 10 | : | Block is not safe |
| BlockchainStatus = “Not Safe”. | ||
| Step 11 | : | Break |
| Step 12 | : | END FOR |