Skip to main content
. 2018 Nov 12;18(11):3894. doi: 10.3390/s18113894
Algorithm 3 Building the Merkle Tree and Currency Allocation
Require: 9 encoded user information and a minner (u1,u2...u9 and miner)
Ensure: Merkle tree and currency allocation
repeat
   Continue to find new block;
until miner find the new block
u10miner
for i=1;i<=10;i++ do
   H(ui)SHA256(SHA256(Informationui)
end for
for i=1;i<=9;i+2 do
   H(ui,ui+1)SHA256(H(ui),H(ui+1))
end for
for i=1;i<=9;i+4 do
   if i<=8 then
    H(ui,ui+1,ui+2,ui+3)SHA256(H(ui,ui+1),H(ui+2,ui+3))
   else
    H(ui,ui+1)SHA256(SHA256(H(ui),H(ui+1)))
   end if
end for
H(u1,u2,u3,u4,u5,u6,u7,u8,u9,u10)SHA256(H(u1,u2,u3,u4),H(u5,u6,u7,u8),H(u9,u10))
if H(u1,u2,u3,u4,u5,u6,u7,u8,u9,u10) is legal then
   Reward10
   for j=1;j<=10;j++ do
    Rewarduj1
   end for
else
   Reassemble data;
end if