## 3 Method
### Federated Domain Adaptation  
In order to realize secure computation without exchanging data, additively homomorphic encryption is adopted. We define a number \(x\), which becomes \([x]\) after additively homomorphic encryption. According to the properties of homomorphic encryption, for any two numbers \(x\) and \(y\), \([x]+[y]=x+y\) and \(x\times[y]=[x]\times[y]\) is valid. However, the loss function and gradient can not be directly calculated by additively homomorphic encryption. In order to solve this problem, we use the second-order Taylor approximation for the logistic loss  
\[\ell(y,\varphi)\approx\ell(y,0)-\frac{1}{2}y\varphi+\frac{1}{8}y^{2}\varphi^{2} \tag{12}\]  
and the gradient is  
\[\frac{\partial\ell}{\partial\varphi}=-\frac{1}{2}y+\frac{1}{4}y^{2}\varphi \tag{13}\]  
In this way, we obtain the encrypted loss and gradient. \[ \begin{split}[\mathcal{L}_{1}]=&\frac{1}{n}\sum_{i= 1}^{n}\left(\left[\ell_{1}(y_{i}^{A},0)\right]-\frac{1}{2}y_{i}^{A}\left[ \psi\left(u_{i}^{B}\right)\right]\right.\\ &\left.+\frac{1}{8}y_{i}^{A}\left[\psi\left(u_{i}^{B}\right)^{ \prime}\psi\left(u_{i}^{B}\right)\right]\right)\end{split}  \tag{14}\]\[ \begin{split}[\mathcal{L}_{2}]=&-\frac{1}{n}\sum_{i=1}^{n} \left(\llbracket\ell_{2}(z_{i}^{A},0)\rrbracket-\frac{1}{2}z_{i}^{A}\llbracket \omega\Big{(}u_{i}^{B}\Big{)}\rrbracket\\ +&\frac{1}{8}z_{i}^{A2}[\omega\Big{(}u_{i}^{B}\Big{)} ^{\prime}\omega\Big{(}u_{i}^{B}\Big{)}]\right)\\ &-\frac{1}{n^{\prime}}\sum_{i=n+1}^{n^{\prime}}\left(\llbracket \ell_{2}(z_{i}^{A},0)\rrbracket-\frac{1}{2}z_{i}^{A}\llbracket\omega\Big{(}u_{ i}^{B}\Big{)}\rrbracket\\ +&\frac{1}{8}z_{i}^{A2}[\omega\Big{(}u_{i}^{B}\Big{)} ^{\prime}\omega\Big{(}u_{i}^{B}\Big{)}]\right)\\ \llbracket\frac{\partial\mathcal{L}_{1}^{i}}{\partial\Theta_{i}} \rrbracket=&\frac{1}{n}\sum_{i=1}^{n}\frac{\psi\big{(}u_{i}^{B} \big{)}^{\prime}\psi\big{(}u_{i}^{B}\big{)}}{\partial u_{i}^{B}}\llbracket \Big{(}\frac{1}{8}y_{i}^{A2}\psi\Big{(}u_{i}^{B}\big{)}^{\prime}\psi\Big{(}u _{i}^{B}\Big{)}\Big{)}\rrbracket\frac{\partial u_{i}^{B}}{\partial\Theta_{i}} \\ &+\frac{1}{n}\sum_{i=1}^{n}\llbracket\frac{1}{2}y_{i}^{A}\psi\Big{(} u_{i}^{B}\Big{)}\rrbracket\frac{\partial\psi\big{(}u_{i}^{B}\big{)}}{ \partial u_{i}^{B}}\frac{\partial u_{i}^{B}}{\partial\Theta_{i}}\\ \llbracket\frac{\partial\mathcal{L}_{2}^{i}}{\partial\Theta_{i}} \rrbracket=&-\frac{1}{n}\sum_{i=1}^{n}\frac{\omega\big{(}u_{i}^{B} \big{)}^{\prime}\omega\big{(}u_{i}^{B}\big{)}}{\partial u_{i}^{B}}\llbracket \Big{(}\frac{1}{8}z_{i}^{A2}\omega\big{(}u_{i}^{B}\big{)}^{\prime}\omega \Big{(}u_{i}^{B}\Big{)}\Big{)}\rrbracket\frac{\partial u_{i}^{B}}{\partial \Theta_{i}}\\ &-\frac{1}{n}\sum_{i=1}^{n}\llbracket\frac{1}{2}z_{i}^{A}\omega \Big{(}u_{i}^{B}\Big{)}\rrbracket\frac{\partial\omega\big{(}u_{i}^{B}\big{)}}{ \partial u_{i}^{B}}\frac{\partial u_{i}^{B}}{\partial\Theta_{i}}\\ &-\frac{1}{n^{\prime}}\sum_{i=1}^{n}\omega\big{(}u_{i}^{B}\big{)} ^{\prime}\omega\big{(}u_{i}^{B}\big{)}\llbracket\Big{(}\frac{1}{8}z_{i}^{A2} \omega\Big{(}u_{i}^{B}\Big{)}^{\prime}\omega\Big{(}u_{i}^{B}\Big{)}\Big{)} \rrbracket\frac{\partial u_{i}^{B}}{\partial\Theta_{i}}\\ &-\frac{1}{n^{\prime}}\sum_{i=1}^{n}\llbracket\frac{1}{2}z_{i}^{A }\omega\Big{(}u_{i}^{B}\Big{)}\rrbracket\frac{\partial\omega\big{(}u_{i}^{B} \big{)}}{\partial u_{i}^{B}}\frac{\partial u_{i}^{B}}{\partial\Theta_{i}}\end{split}  \tag{17}\]  
Then, update the parameters according to the gradient direction  
\[\Theta^{x} \leftarrow\Theta^{x}-\eta gx \tag{18}\] \[\Theta^{y} \leftarrow\Theta^{y}-\eta gy\] (19) \[\Theta^{z} \leftarrow\Theta^{z}-\eta\lambda gz \tag{20}\]  
where \(\eta\) is the learning rate. With these parameters, we now design a federated Domain Adaptation network for solving the Domain Adaptation problem.As shown in Figure 2. First, Party A and Party B send public keys to each other, then initialize parameters \(\Theta^{x},\Theta^{y},\Theta^{z}\), calculate implicit representations \(u^{A}\) and \(u^{B}\), and then calculate, encrypt, and exchange intermediate results \(g\) and \(\mathcal{L}\).