## 3 The Security Mechanism
### Local Detection
#### 3.1.1 LD-1 Mechanism  
_Preparation phase:_ Node \(u\) is preallocated \(\mathrm{H}(ID_{u})\) and \(s_{1}H(ID_{u})\) before it is deployed in the network. \(\mathrm{H}(ID_{u})\) and \(s_{1}H(ID_{u})\) denote its identity-based public key and identity-based private key, respectively. \(s_{1}\) is the master key materials which are used in identity-based keys. The identity-based public key of sink node \(\mathrm{H}(ID_{\mathrm{SN}})\) is stored in node \(u\). Node \(u\) can get the location-based public key \(\mathrm{H}(ID_{u}||LOC_{u}^{T_{u}}||\Delta_{u})\) and the location-based private key \(s_{2}\mathrm{H}(ID_{u}||LOC_{u}^{T_{u}}||\Delta_{u})\) when it is deployed in the network; here \"\(||\)\" denotes the concatenation of message. \(LOC_{u}^{T_{u}}\) denotes the location of node \(u\) at time \(\mathrm{T}_{u}\). \(s_{2}\) is the master key materials which is used in location-based keys. \(\Delta_{u}\) denotes the radius value of node \(u\)'s MSA. It will change consistently when node is in different detection levels. Different values of \(\Delta\) could have an effect on network security. It will be detailed in Section 4. _Authentication Phase:_ Node u's MSA is a circular area which is to \(LOC_{u}^{T_{u}}\) as the center and a radius of \(\Delta_{u}\). All the keys of node \(u\) are legitimate when \(u\) is within its own MSA. It means that node \(u\) could communicate with other nodes in the MSA by using the authenticated keys. When node \(u\) wants to communicate with its neighbors, the authentication processes will be executed as follows. \begin{tabular}{l} \hline u\(\rightarrow\)*: \((SIG_{LK_{u}}(loc_{u}^{t_{u}}\parallel n_{u}),(loc_{u}^{t_{u}}\parallel n_{u }\parallel ID_{u}\parallel LOC_{u}^{T_{u}}\parallel\Delta_{u}))\) \\ v\(\rightarrow\)u: \((SIG_{LK_{u}}(loc_{v}^{t_{v}}\parallel n_{v}\parallel n_{u}\parallel 1),( loc_{v}^{t_{v}}\parallel n_{v}\parallel n_{u}\parallel ID_{v}\parallel LOC_{v}^{T_{v}} \parallel\Delta_{u}))\) \\ u\(\rightarrow\)v: \(SIG_{LK_{u}}(n_{u}\parallel n_{v}\parallel 2)\) \\ \hline \end{tabular}   
Node \(u\) signs its current location \(\mathrm{loc}_{u}^{t_{u}}\) at time \(t_{u}\) and a random number \(n_{u}\) by using its location-based key \(LK_{u}\), and then broadcasts the signed messages. Node \(u\)'s ID and \(\mathrm{LOC}_{u}^{T_{u}}\) are also included in the messages. \(\mathrm{LOC}_{u}^{T_{u}}\) is the center of MSA. It is also the location where it is authenticated when node \(u\) applies for getting or updating the location-based keys. \(SIG_{LK_{u}}\) denotes the messages that are signed with location-based private keys of node \(u\). Assume that node \(v\) is one of the node \(u\)'s neighbors. After node \(v\) receives the broadcasting messages from node \(u\), the public key \(LK_{u}\) of node \(u\) will be generated by using \(ID_{u}\) and \(\mathrm{LOC}_{u}^{T_{u}}\) in the messages and the value of \(\Delta\). Then node \(v\) will verify the signed message of node \(u\) by using \(LK_{u}\). It will also check whether node \(u\) is within its own MSA or not. If node \(u\) is out of its security area, node \(v\) would alert node \(u\) to update its location-based key. In contrast, node \(v\) would test whether \(\frac{\left|\mathrm{Loc}_{u}^{T_{u}}-\mathrm{loc}_{u}^{t_{u}}\right|}{\left| \mathrm{r}_{u}-t_{u}\right|}\leq v_{max}\) is established. If the inequation is established, node \(v\) would test whether \(\left|\mathrm{LOC}_{u}^{T_{u}}-\mathrm{LOC}_{v}^{T_{v}}\right|\leq\left| \Delta_{u}+\Delta_{v}+R\right|\) is established. If the inequation is not established, it means that node \(u\) is not a legitimate node. In this situation, node \(v\) discards the request from node \(u\), signs the message and broadcasts the alert message that node \(u\) is a malicious node. If all of the inequations are established, node \(v\) would sign the message including its current location \(loc_{v}^{t_{v}}\), a random number \(n_{v}\) that is generated by node \(v\), a random number \(n_{u}\) and a number \(1\).