## 4 Joint Task Offloading, Resource Allocation, and Security Assurance Algorithm
### Joint Task Offloading and Resource Allocation  
As can be seen in (6), (9), and (11), for the optimization problem P2, in the case of given \(\mathbf{x}\), the joint resource allocation and task offloading problem can be written as  
\[\begin{split}\text{P5}:\min\limits_{\lambda,\mathbf{f}}T(\lambda, \mathbf{f})&=\min\limits_{\lambda,\mathbf{f}}\sum\limits_{i=1}^{N }\sum\limits_{j=1}^{M}x_{ij}t_{\Xi_{i}}\\ s.t.&\text{C5.1}:\sum\limits_{j=1}^{M}x_{ij}t_{\Xi_{ i}}\leq T^{th},\ \forall i\in\mathbf{N}\\ &\text{C5.2}:\sum\limits_{k=1}^{j}\frac{1}{v_{i}}+T^{s}_{ij}+ \frac{p^{\prime}_{ij}R+p^{\prime}_{ij}T^{s}_{ij}}{p^{\prime}_{ij}}\\ &\qquad+\frac{\lambda_{ij}c_{i}}{T_{ij}}\leq t_{\Xi_{i}},\ \forall i\in \mathbf{N},\ \forall j\in\mathbf{M}\\ &\text{C5.3}:\frac{\left(1-\lambda_{ij}\right)c_{i}}{f_{i}}\leq t _{\Xi_{i}},\ \forall i\in\mathbf{N},\ \forall j\in\mathbf{M}\\ &\text{C5.4}:0\leq\sum\limits_{i=1}^{N}x_{ij}t_{ij}\leq F_{j}, \ \forall j\in\mathbf{M}\\ &\text{C5.5}:0\leq\sum\limits_{i,j}\leq F_{j},\ \forall i\in\mathbf{N},\ \forall j\in\mathbf{M}\\ &\text{C5.6}:0\leq\lambda_{ij}\leq 1,\ \forall i\in\mathbf{N},\ \forall j\in \mathbf{M}\\ &\text{C5.7}:R_{e}\leq R_{th},\ \forall i\in\mathbf{N},\ \forall j\in \mathbf{M}.\end{split} \tag{19}\]  
As \(t_{\Xi_{i}}\) is nondifferentiable with respect to \(f_{i,j}\) and \(\lambda_{ij}\), \(t_{\Xi_{i}}\) can be transformed into  
\[\begin{split} t_{\Xi_{i}}&\leq T^{loc}_{ij}+T^{ LIAV}_{i,j}\\ &=\left(1-\lambda_{ij}\right)\frac{c_{i}}{f_{i}}+T^{1}_{i,j}+T^{ trans}_{i,j}+T^{Edge}_{ij}\\ &=\left(1-\lambda_{ij}\right)\frac{c_{i}}{f_{i}}+\sum\limits_{k=1 }^{j-1}\frac{t_{k}}{v_{i}}+T^{t}_{ij}+\varphi_{i}+\frac{p^{\prime}_{ij}R+p^{ \prime}_{ij}T^{s}_{ij}}{p^{\prime}_{ij}}+\frac{\lambda_{ij}c_{i}}{f_{i,j}}\\ =&\lambda_{ij}\Big{(}\frac{c_{i}}{f_{i}}+\varsigma_{i, j}\Big{)}+\kappa_{i,j},\end{split} \tag{20}\]  
where \(\varphi_{i}\), \(\varsigma_{i,j}\), and \(\kappa_{i,j}\) can be expressed as  
\[\varsigma_{i,j} =-\frac{c_{i}}{f_{i}}+\frac{d_{i}}{B_{j}\text{log}_{2}\left(1+ \frac{p^{2}_{ij}\varsigma_{ij}}{P_{\Xi_{i}}}\right)}, \tag{21}\]  
\[\kappa_{i,j} =\frac{c_{i}}{f_{i}}+\sum\limits_{k=1}^{j-1}\frac{L_{k}}{v_{i}}+\frac{ p^{\prime}_{ij}R+p^{\prime}_{ij}T^{s}_{ij}}{p^{\prime}_{i,j}}, \tag{22}\] \[\varphi_{i} =H_{\Xi_{i}}+4T^{p}_{i,j}+3T_{SIFS}+T_{ACK}+T_{DIFS}+T_{RTS}+T_{CTS}, \tag{23}\]  
where \(\lambda_{ij}\Big{(}\frac{c_{i}}{f_{i}}+\varsigma_{i,j}\Big{)}+\kappa_{i,j}\) is the upper bound of \(t_{\Xi_{i}}\).  
Substituting (20) into the optimization problem P5, the optimization problem P5 can be equivalently recast as  
\[\begin{split}\text{P6}:\min\limits_{\lambda,\mathbf{f}}T(\lambda, \mathbf{f})&=\min\limits_{\lambda,\mathbf{f}}\sum\limits_{i=1}^{N }\sum\limits_{j=1}^{M}x_{ij}\Big{(}\lambda_{ij}\varsigma_{i,j}\frac{c_{i}}{f_{ i}}+\kappa_{i,j}\Big{)}\\ s.t.&\text{C6.1}:\sum\limits_{j=1}^{M}x_{ij}\Big{[} \lambda_{ij}\Big{(}\frac{c_{i}}{f_{i}}+\varsigma_{i,j}\Big{)}+\kappa_{i,j} \Big{]}\leq T^{th},\ \forall i\in\mathbf{N}\\ &\text{C6.2}:0\leq\sum\limits_{j=1}^{N}x_{ij}f_{i,j}\leq F_{j}, \ \forall j\in\mathbf{M}\\ &\text{C6.3}:0\leq f_{i,j}\leq F_{j},\ \forall i\in\mathbf{N},\ \forall j\in \mathbf{M}\\ &\text{C6.4}:0\leq\lambda_{i,j}\leq 1,\ \forall i\in\mathbf{N},\ \forall j\in \mathbf{M}\\ &\text{C6.5}:R_{e}\leq R_{th},\ \forall i\in\mathbf{N},\ \forall j\in \mathbf{M}.\end{split} \tag{24}\]  
**Lemma 3**.: _The optimization problem P6 is a non-convex problem._Proof of Lemma 3.: See the Appendix C.  
Unfortunately, the resource allocation variables and the offload ratio variables are highly coupled with each other in both the objective function and constraints. To solve the problem in (24), we decouple the two variables. Specifically, we obtain \(\mathbf{f}\) under given \(\lambda\) and then obtain \(\lambda\) under given \(\mathbf{f}\), and repeat this process until convergence.