## 2 Materials and Methods
### Proposed Scheme
#### 2.5.2 Registration Phase  
After the pre-deployment phase of the sensor nodes in the targeted agriculture field, the sensors are transmitted to the registered legal professional via HGWN and FGWN. The sensors and agriculture professionals must be registered with SA to access the desired services. The following sections outline how to register a sensor node and an agriculture professional:  
* **User/agriculture professional registration:*
* Before participating in any communication during this phase, the user or agriculture professional must register with one of the GWNs. Assuming that the user chooses to register with HGWN, he or she must follow the steps outlined in Figure 6:
* Agriculture Professional chooses \(U_{ID}\) as an identity and \(U_{PW}\), which is the password, and a random number \(R\) to computes \(PID_{i}=h(U_{ID}\parallel R)\) and \(PWR_{i}=h(U_{PW}\parallel R)\). Then, the parameters \(PID_{i}\), \(PWR_{i}\) are securely transmitted to the SA as a registration request.
* The SA receives the message and generates an identity \(TID_{i}\), which is 160-bit to compute \(A_{th}=h(HGW_{ID}\parallel PID_{i}\parallel HGW_{MSK})\oplus h(PID_{i} \parallel PWR_{i}\parallel TID_{i})\) for each user \(U_{i}\) in HGWN. It also computes \(A_{tf}=h(FGW_{ID}\parallel PID_{i}\parallel FGW_{MSK})\oplus h(PID_{i} \parallel PWR_{i}\parallel TID_{i})\) for the FGWN. The SA then issues an embedded smart-card \(SC_{i}:(HGW_{ID},A_{th})\), \((FGW_{ID},A_{tf})\), \(TID_{i}\), \(Gen(.),Rep(.),h(.),t\), where t is the error tolerance threshold. Finally, it sends the message to the user Ui via a secure channel.
* Now that the user \(U_{i}\) receives the embedded smart-card from SA securely, the \(U_{i}\) imprints their fingerprint \(U_{BIO}\) at the sensor of a specific terminal and computes \(Gen(U_{BIO})=(\sigma,\tau)\), which \(\sigma\) is the key of the biometric data and \(\sigma\) is the parameter. Then, the \(U_{i}\) computes \(T_{i}=h(U_{ID}\parallel\sigma)\oplus R,S_{i}=h(PID_{i}\parallel PWR_{i}\parallel\sigma)\) and \(A_{th}^{*}=A_{th}\oplus h(\sigma\parallel R)=(HGW_{ID}\parallel PID_{i} \parallel HGW_{MSK})\oplus h(PID_{i}\parallel PWR_{i}\parallel TID_{i}) \oplus h(\sigma\parallel R)\). The \(U_{i}\) then computes \(A_{tf}^{*}=A_{if}\oplus h(\sigma\parallel R)=h(FGW_{ID}\parallel PID_{i} \parallel FGW_{MSK})\oplus h(PID_{i}\parallel PWR_{i}\parallel TID_{i}) \oplus h(\sigma\parallel R)\). \(U_{i}\) stores \(\tau,T_{i}\) and \(S_{i}\) in the smart-card SC. The \(U_{i}\) then replaces \(A_{th}withA_{th}^{*}\), and \(A_{tf}\) with \(A_{tf}^{*}\) in the stored information of SC. The stored data will be as \((HGW_{ID},A_{th}^{*})\), \((FGW_{ID},A_{tf}^{*})\), \(TID_{i},Gen(.)\), \(Rep(.)\), \(h(.),t,\tau,T_{i},S_{i}\).
However, the pair \((PID_{i},TID_{i})\) are stored in the database of the corresponding HGWNs to the \(Ui\) and also sores them into all FGWNs by the SA if the user desires to access services from any sensor node through the FGWNs.
* **Newly Joined Sensors:*
* The newly joined sensor node must be registered with the SA for further communication services in this phase. The phase is performed after being deployed priorly in the pre-deployment phase. Figure 7 shows the steps of newly joined sensors. As we mentioned above, each sensor in the cluster has the information \((SN_{ID},A_{j})\) in its memory. Thus, to register the sensor node SNi into the SA, the sensor is required to apply the following steps:
* Firstly, the sensor \(SN_{i}\) chooses an identity \((SN_{ID}^{n})\), and a random number \(r_{sn}\) is generated for each sensor to compute \(N_{SN}=h(SN_{ID}^{n}\parallel r_{sn})\), and \(M_{SN}=h(N_{SN}\parallel r_{sn})\). Then, the sensor sends \(N_{SN}\) to the SA securely.
* Now, the SA receives the message and obtain a new sensor identity \(SN_{ID}^{n}\) and generate a master key \(SN_{MSK}^{n}\) for the newly joined sensor. Then, it calculates \(A_{j}^{n}=h(SN_{ID}^{n}\parallel SN_{MSK}^{n})\) and loads the \((A_{j}^{n},SN_{ID}^{n})\) into the sensor memory within its corresponding cluster.