# CS-FL: Cross-Zone Secure Federated Learning with Blockchain and a Credibility Mechanism
## 4 CS-FL Method
### Probe Phase: Security Credibility Index Mechanism  
Due to the mobility and heterogeneity of ENs, a probe phase based on a secure credibility mechanism is designed to acquire knowledge of EN's locations and qualities before the formal training, as depicted in Step 1-2 in Figure 3. Each ZS dispatches a probe task message \(\bar{P}_{task}=\langle i,\bar{w}_{i-1},Q,|D_{test}|\rangle\) to ENs within its service coverage initially, where \(|D_{test}|\) denotes the size of test dataset, which is significantly smaller than the average \(|D_{n}|\). \(Q\) represents the extraction strategy updated in each round to prevent nodes from cheating in probe phase using a prepared dataset. Upon receiving the probe message, EN \(n\) extracts \(|D_{test}|\) number of data-label pairs from \(D_{n}\) according to strategy \(Q\) to generate test dataset \(D_{n}^{test}\). Data quality is calculated from the heterogeneity of data, reflecting the quality of local data through probe task and defined as follows:  
\[DQ_{n}=\frac{\sum_{d\in D_{test}^{test}}\text{Loss}(\bar{w}_{i-1},d)}{|D_{test}|} \tag{3}\]  
Figure 3: Detailed workflow of the CS-FL method. where \(d=\{x_{j},y_{j}\}\in D_{n,i}^{test}\) denotes each data-label pair in the test dataset. By recording the computation time of probe task \(t_{n,i}^{cpu}\), the real-time computational efficiency is assessed by:  
\[CE_{n}=\frac{|D_{test}|}{t_{n,i}^{cpu}} \tag{4}\]  
In most cases, the larger size of local datasets, the better training effect of local models. By this, the node quality index (NQI) is defined to measure the quality of EN \(n\), which should be directly proportional to \(CE_{n}\) and \(|D_{n}|\) and inversely proportional to \(DQ_{n}\):  
\[NQI_{n,i}=\tanh[\varphi\cdot\frac{|D_{test}|^{2}}{t_{n,i}^{cpu}\cdot\sum_{d \in D_{n,i}^{tot}}\text{Loss}(\bar{w}_{i-1},d)}\cdot|D_{n}|] \tag{5}\]  
where \(\varphi=\left[\max_{n}(|D_{n}|)\cdot|D_{test}|^{2}\right]^{-1}\) and \(\tanh\) is a normalized function used to standardize NQI within range (0,1). This paper focuses on 5G NR protocol-based wireless communication between ENs and ZSs. Since latency alone is insufficient to assess communication quality, channel quality indication (CQI), serving as the basis for downlink scheduling in 5G NR [31], is introduced at the edge side to reflect downlink channel quality. CQI is an integer ranging from 0 to 15. Under same channel conditions, a more sensitive user equipment (UE) receiver corresponds to a higher SINR and, consequently, a larger CQI value. ENs package and send reply message \(\bar{P}_{reply}=\left<ID_{n}|NQI_{n,i},CQI_{n,i},t_{n,i}^{com_{1}}\right>\) to ZSs, where \(t_{n,i}^{com_{1}}\) is the timestamp when the response message is sent. After receiving \(\bar{P}_{reply}\) from ENs within the maximum latency \(T_{m}\), the ZS records the timestamp \(t_{n,i}^{com_{2}}\) to obtain the communication duration \(t_{n,i}=t_{n,i}^{com_{2}}-t_{n,i}^{com_{1}}\). The concept of [PERSON]'s Law of Cooling [32] is used to define the communication resource index (CRI), as shown in Equation (6):  
\[T(t)=T_{0}\cdot e^{-\theta(t-t_{0})} \tag{6}\]  
where \(T_{0}\) is the temperature value at the initial moment. The exponential term \(e^{-\theta(t-t_{0})}\) is commonly used to describe attenuation or decay processes, such as the cooling of an object over time according to the law of heat conduction. In the context of the CRI, this term is introduced to model the gradual decrease in node communication resource availability as the communication transmission time increases. To encourage ENs with shorter transmission times to achieve higher CRI scores, the system employs a design inspired by [PERSON]'s Law of Cooling. This ensures that ENs which complete transmissions more quickly are awarded higher CRI scores, thus reducing the overall average waiting delay of the FL task. Here, \(\theta\) is set to 1. The CRI value of EN \(n\) is defined as:  
\[CRI_{n,i}=\left\{ \begin{matrix}\log_{16}\left(1+CQI_{n,i}\right)\cdot e^{-t_{ n,i}},&0<t_{n,i}\leq T_{m}\\ 0,&t_{n,i}>T_{m}\end{matrix} \right.