|
Algorithm 2 Block Validation |
-
Require:
New EHR Block, Information of Last Block, Pool of Public Keys ()
-
Ensure:
Validity of the Block
-
1:
Step 1: Verify the uniqueness of the new block’s timestamp.
-
2:
if timestamp of the new block exists within the same timeframe in the chain then
-
3:
Deny the new block. return Invalid
-
4:
end if
-
5:
Step 2: Check if the new block was created after the last block in the chain.
-
6:
if timestamp of the new block ≤ timestamp of the last block in the chain then
-
7:
Deny the new block. return Invalid
-
8:
end if
-
9:
Step 3: Validate transactions within the block.
-
10:
for each transaction in the new block do
-
11:
Step 3.1: Verify the transaction signature using the pool.
-
12:
if signature of the transaction cannot be verified with any in the pool then
-
13:
Deny the new block. return Invalid
-
14:
end if
-
15:
Step 3.2: Ensure the transaction is signed by a single user.
-
16:
if transaction contains signatures from multiple users then
-
17:
Discard the new block. return Invalid
-
18:
end if
-
19:
end for
-
20:
Step 4: Verify the previous block’s hash value.
-
21:
if previous hash value in the new block ≠ hash value of the last block in the chain then
-
22:
Discard the new block. return Invalid
-
23:
end if
-
24:
Add the new block to the chain. return Valid
|