# Federated Learning-Based Resource Management with Blockchain Trust Assurance in Smart IoT
## 4 Proposed FL-Based Resource Management with Blockchain Trust Assurance Algorithm  
Currently, most IoT applications are deployed in cloud servers in core networks. As MECs are deployed on a large scale and more and more small- and medium-volume IoT applications are launched, more IoT applications will be deployed in MEC servers at network edges. Of course, this does not preclude some large IoT applications from still being deployed in the core cloud servers. In this paper, we focus on the case of IoT applications deployed in MEC servers. FL servers and FL local devices share the same training models, and FL servers are deployed in MEC servers. Different IoT applications achieve distributed collaborative resource management by invoking FL service mechanisms. Suppose that there are \(N\) local devices involved in the FL training and there are \(K\) classes of different resources to be managed. \(\text{res}_{i,j}\) denotes the size of the \(j\)th class resource of local device \(i\), \(1\leq i\leq N;1\leq j\leq K\). The normalized representation of the resources of \(\text{res}_{i,j}\) is  
\[r(i,j)=\frac{\text{res}_{i,j}}{\sum_{i=1}^{N}\text{res}_{i,j}},0\leq r(i,j)\leq 1 \tag{1}\]  
The total resources of participant local device \(i\) are denoted as  
\[R(i,j)=\sum_{j=1}^{K}w_{j}\cdot r(i,j) \tag{2}\]  
\(R(i,j)\) is a weighted logical resource representation. \(w_{j}\) denotes the weight of the \(j\)th class resource in the participant selection, which satisfies  
\[\sum_{j=1}^{K}w_{j}=1,0\leq w_{j}\leq 1 \tag{3}\]  
To prevent the impact of malicious nodes on the FL training, this paper identifies the malicious nodes and removes them from the network before federated training. In this  
Figure 3: The data structure details of the blockchain. Figure 2: The proposed IoT resource management framework incorporating blockchain and federated learning technologies. paper, malicious nodes are detected using support vector machines (SVM), which is a supervised learning technique that enables binary classification of data [9; 23]. SVM finds a hyperplane (i.e., decision boundary) in \(N\)-dimensional space, and each \(N\)-dimensional data point is divided on both sides of the hyperplane, thus classifying these data points into two classes. In this paper, the goal of SVM is to compute the binary classification of different IoT nodes (including end devices, IoT gateways, IoT servers, etc. ), as shown in Equation (4):  
\[C=\{(X^{1},y^{1}),\cdots,(X^{N},y^{N})\},X\in\mathbb{R}^{K},y\in\{-1,+1\} \tag{4}\]  
where \(X\) denotes the input data vector consisting of \(K\) classes of different resources, and \(y\) is the binary classification value:  
\[X^{i}=[\text{res}_{i,1},\cdots,\text{res}_{i,j},\cdots,\text{res}_{i,K}] \tag{5}\]  
\(X^{i}\) is the local data input of the local model FL training algorithm performed by local device \(i\). Its size depends on the specific FL training task. The decision boundary of the local nodes is given by Equation (6):  
\[W^{T}X+b=0 \tag{6}\]  
where \(W=(w_{1},\cdots,w_{K})\) is the weight vector, and \(b\in\mathbb{R}\) is the threshold value, which is geometrically expressed as the intercept of this hyperplane. Hence, \(y\) in Equation (4) can be determined from Equation (7):  
\[ \begin{cases}W^{T}X^{i}+b\geq 0&y^{i}=+1\\ W^{T}X^{i}+b<0&y^{i}=-1\end{cases}  \tag{7}\]  
The local node trustworthiness trust is defined as the probability of successful interaction of the local node with the FL server and is calculated by Equation (8):  
\[\text{trust}=\frac{I_{s}}{I_{t}} \tag{8}\]  
where \(I_{t}\) is the total number of interactions between a local node and the FL server over a period of time, and \(I_{s}\) is the number of successful interactions. If \(y^{i}=-1\) or \(\text{trust}^{i}<\text{threshold}\), the local node \(i\) is considered as a malicious or untrustworthy node.