# Joint Resource Allocation in Secure OFDMA-Based Networks Taking a Base Station as a Two-Way Relay
## 2 System Model
\(\alpha=P_{A_{m}}^{i}{|{{h_{A_{m},R}^{i}}}|}^{2}+{p_{B_{m}}^{i}}{|{{h_{B_{m},R}^{i}} }|}^{2}+\sigma^{2}\), the received signal at \(A_{m}\) and \(B_{m}\) over subcarrier \(j\) in the second time slot are \(y_{A_{m}}^{ij}\) and \(y_{B_{m}}^{ij}\) respectively. \[y_{A_{m}}^{ij} = \sqrt{P_{R,(A_{m},B_{m})}^{j}}{\delta_{A_{m}}^{j}}y_{R}^{i}/\alpha +n_{A_{m},j}\] \[y_{B_{m}}^{ij} = \sqrt{P_{R,(A_{m},B_{m})}^{j}}{\delta_{B_{m}}^{j}}y_{R}^{i}/\alpha +n_{B_{m},j}\]  
Substituting \(y_{R}^{i}\) into the above two equations, we get:  
\[ \begin{array}{l}y_{A_{m}}^{ij}=\sqrt{P_{R,(A_{m},B_{m})}^{j}}{\delta_{A_{m}} ^{j}}{\left({\sqrt{P_{A_{m}}^{i}}}h_{A_{m},R}^{i}{x_{A_{m},j}}+\sqrt{P_{B_{m}}^ {i}}h_{B_{m},R}^{i}{x_{B_{m},i}}+n_{R,j}\right)/\alpha+n_{A_{m},j}}\\ =\sqrt{P_{R,(A_{m},B_{m})}^{j}}{\delta_{A_{m}}^{j}}\sqrt{P_{A_{m}}^{i}}h_{A_{m},R}^{i}{x_{A_{m},i}}/\alpha+\sqrt{P_{R,(A_{m},B_{m})}^{j}}{\delta_{A_{m}}^{j}} \sqrt{P_{B_{m}}^{i}}h_{B_{m},R}^{i}{x_{B_{m},i}}/\alpha\\ +\sqrt{P_{R,(A_{m},B_{m})}^{j}}{\delta_{A_{m}}^{j}}n_{R,i}/\alpha+n_{A_{m},j} \end{array}  \tag{4}\]  
and  
\[ \begin{array}{l}y_{B_{m}}^{ij}=\sqrt{P_{R,(A_{m},B_{m})}^{j}}{\delta_{B_{m}} ^{j}}{\left({\sqrt{P_{A_{m}}^{i}}}h_{A_{m},R}^{i}{x_{A_{m},i}}+\sqrt{P_{B_{m}} ^{i}}h_{B_{m},R}^{i}{x_{B_{m},i}}+n_{R,j}\right)/\alpha+n_{B_{m},j}}\\ =\sqrt{P_{R,(A_{m},B_{m})}^{j}}{\delta_{B_{m}}^{j}}{\sqrt{P_{A_{m}}^{i}}}h_{A_ {m},R}^{i}{x_{A_{m},i}}/\alpha+\sqrt{P_{R,(A_{m},B_{m})}^{j}}{\delta_{B_{m}}^{ j}}\sqrt{P_{B_{m}}^{i}}h_{B_{m},R}^{i}{x_{B_{m},i}}/\alpha\\ +\sqrt{P_{R,(A_{m},B_{m})}^{j}}{\delta_{B_{m}}^{j}}n_{R,i}/\alpha+n_{B_{m},j} \end{array}  \tag{5}\]  
\({\delta_{A_{m}}^{j}}\) and \({\delta_{B_{m}}^{j}}\) are the downlink channel gain over subcarrier \(j\) from the base station to \(A_{m}\) and \(B_{m}\) respectively; \(n_{A_{m},j}\) and \(n_{B_{m},j}\) are Additive White Gaussian Noise over subcarrier \(j\) at \(A_{m}\) and \(B_{m}\) with a mean of zero and a variance of \(\sigma^{2}\). The received signal on subcarrier \(j\) at the eavesdropper in the second time slot is \(y_{E}^{ij}=\sqrt{P_{R,(A_{m},B_{m})}^{j}}{\delta_{R,E}^{j}}y_{R}^{i}/\alpha+n_ {E,j}\). Substituting \(y_{R}^{i}\) into this equation, we get:  
\[\begin{array}{l}y_{E}^{ij}=\sqrt{P_{R,(A_{m},B_{m})}^{j}}{\delta_{R,E}^{j}}{ \left({\sqrt{P_{A_{m}}^{i}}}h_{A_{m},R}^{i}{x_{A_{m},i}}+\sqrt{P_{B_{m}}^{i}}h_ {B_{m},R}^{i}{x_{B_{m},i}}+n_{R,j}\right)/\alpha+n_{E,j}}\\ =\sqrt{P_{R,(A_{m},B_{m})}^{j}}{\delta_{R,E}}\sqrt{P_{A_{m}}^{i}}h_{A_{m}  
\[ \begin{split}\mathbf{Q}_{E}=\sigma^{2}\left[\begin{array}{cc}1&0\\ 0&1+P_{R,(A_{m},B_{m})}^{j}|s_{R,E}^{j}|^{j}/\alpha^{2}\end{array}\right] \end{split}  \tag{12}\]  
\[ \begin{split} SNR_{A_{m}}^{ij}&=\frac{P_{R,(A_{m},B_{m})}^{j}|s_ {A_{m}}^{j}|^{2}P_{B_{m}}^{i}|^{j}|^{j}_{B_{m},R}|^{j}/\alpha^{2}}{\left(P_{R,(A_{m},B_{m})}^{j}|s_{A_{m}}^{j}|^{2}/\alpha^{2}+1\right)\sigma^{2}},\\ SNR_{B_{m}}^{ij}&=\frac{P_{R,(A_{m},B_{m})}^{j}|s_{B_{m}}^{j}|^{2}P_{A _{m}}^{i}|^{j}_{A_{m},R}|^{j}/\alpha^{2}}{\left(P_{R,(A_{m},B_{m})}^{j}|s_{B_{ m}}^{j}|^{2}/\alpha^{2}+1\right)\sigma^{2}}\\ \end{split}  \tag{13}\]  
\[ \begin{split}&\det(I+\mathbf{H}_{E}\mathbf{H}_{E}^{H}\mathbf{Q}_{ E}^{-1})\\ &=\frac{P_{A_{m}}^{j}P_{B_{m}}^{j}(|t_{A_{m},E}^{j}|^{j}_{B_{m},R}| ^{2}+|t_{B_{m},E}^{j}|^{2}|u_{A_{m},R}^{j}|^{2})+\sigma^{2}(P_{A_{m}}^{j}|t_{A _{m},E}^{j}|^{2}+P_{B_{m}}^{j}|t_{B_{m},E}^{j}|^{j}_{B_{m},R}|^{2}+P_{A_{m}}^{ j}|u_{A_{m},R}^{j}|^{2}+P_{B_{m}}^{j}|u_{B_{m},R}^{j}|^{2})}{\sigma^{4}}\\ \end{split}  \tag{14}\]  
Substituting the above equations into (7), the achievable secure rate for the paired user is expressed as:  
\[