# A Blockchain-Assisted Security Protocol for Group Handover of MTC Devices in 5G Wireless Networks
## 5 The Proposed BSPGH
### First MTCD Handover Authentication  
This phase involves one handover authentication that occurs when the first MTCD enters the range of the t-gNB. After the handover authentication of the first MTCD is successful, subsequent group handover authentication processes will be carried out. This phase is shown in Figure 4.  
\[Step\text{-}1:MTCD\to s\text{-}gNB:\{TID_{1},TS_{1},n_{1}\text{-}P, Sig_{1}\}\]  
When the first MTCD enters the coverage range of t-gNB within the group, \(MTCD_{1}\) selects a random number \(n_{1}\in Z_{q}\) and computes its signature as \(Sig_{1}=h_{13}msk_{1}+n_{1}+h_{12}psk_{1}\). Where \(h_{12}=H_{3}(TID_{1},TS_{1},PK_{1},n_{1}\text{-}P)\) and \(h_{13}=H_{4}(TID_{1},n_{1}\text{-}P)\). Afterwards, \(MTCD_{1}\) sends its \(TID_{1}\), timestamp \(TS_{1}\) and \(n_{1}\text{-}P\), and \(Sig_{1}\) to s-gNB.  
\[Step\text{-}2:s\text{-}gNB\to s\text{-}\text{AMF}:\{TID_{1},TS_{1},n_{1}\text {-}P, Sig_{1}\}\]  
s-gNB checks the timestamp in the received message and forwards the message to s-AMF.  
\[Step\text{-}3:s\text{-}\text{AMF}\to t\text{-}gNB:\{GID,TS_{1},(TID_{1}|| \ldots||TID_{i},n_{1}\text{-}P,Sig_{1}\}\]  
Figure 3: Handover preparation.  
When the handover authentication occurs within the same AMF, after receiving the handover request, s-AMF responds by sending the temporary identity identifiers \(TID_{1}\ldots TID_{\text{i}}\) of all group members, along with the \(GID\) as the group key material, and forwards \(n_{1}\cdot P\) and \(Sig_{1}\) to t-gNB. And after receiving the handover response from s-AMF, t-gNB queries the public key of \(MTCD_{1}\) on the blockchain and calculates \(h_{11}=H_{2}\Big{(}TID_{1},mpk_{1},R_{1},T_{pub}\Big{)}\), \(h_{12}=H_{3}(TID_{1},TS_{1},PK_{1},n_{1}\cdot P)\), and \(h_{13}=H_{4}(TID_{1},n_{1}\cdot P)\). It verifies the signature \(Sig_{1}\cdot P=h_{13}\cdot mpk_{1}+n_{1}\cdot P+h_{12}\cdot R_{1}+h_{11}\cdot h _{12}\cdot T_{pub}\), and if the equation holds, \(MTCD_{1}\)'s signature is successfully verified. t-gNB then selects a random number \(n_{t}\in Z_{q}\) and generates the session key \(K_{lt}=n_{1}\cdot n_{t}\cdot P\). It also creates the signature \(Sig_{t}=H_{0}(GID,TID_{t},TS_{t},n_{t}\cdot P)\) and computes \(GID_{1}=\sum_{t=2}^{n}H(TID_{1})\) as the group key material to authenticate \(MTCD_{1}\). It then sends a message to \(MTCD_{1}\).  
\[Step\text{-}4:s\text{-AMF}\to t\text{-AMF}:\{GID,TS_{1},TS_{t},(TID_{1}|| \ldots||TID_{\text{i}},n_{1}\cdot P,Sig_{1}\}\]  
When the handover authentication occurs between different AMFs, the s-AMF forwards the message to the t-AMF.  
\[Step\text{-}5:t\text{-AMF}\to t\text{-gNB}:\{GID,TS_{1},(TID_{1}|| \ldots||TID_{\text{i}},n_{1}\cdot P,Sig_{1}\}\]  
Similarly, upon receiving the forwarded handover request, the t-AMF sends the temporary identity identifiers \(TID_{1}\ldots TID_{i}\) of all group members, along with the \(GID\) as group key material, in response. It then forwards \(n_{1}\cdot P\) and \(Sig_{1}\) to t-gNB. Upon receiving the message, the t-gNB proceeds with the verification.  
\[Step\text{-}6:t\text{-gNB}\to MTCD:\{TID_{t},GID_{1},TS_{t},n_{t}\cdot P,Sig_{t}\}\]  
After receiving the message from t-gNB, \(MTCD_{1}\) generates the signature \(Sig^{\prime}_{t}=H_{0}(GID,TID_{t},TS_{t},n_{t}\cdot P)\). If \(Sig^{\prime}_{t}=Sig_{t}\), the identity verification of t-gNB is successful. Then, \(MTCD_{1}\) generates the session key \(K_{lt}=n_{1}\cdot n_{t}\cdot P\). At this point, the mutual authentication and key negotiation between \(MTCD_{1}\) and t-gNB are complete.