# GHEFL: Grouping Based on Homomorphic Encryption Validates Federated Learning
## 4 The Proposed Scheme
In addition, we select a trusted third party to generate a pair of shared Paillier cryptosystem key pairs \((pk,sk)\) for all users and distribute them to each participant. The trusted third party also initializes the necessary parameters for global model training, including the participant learning rate \(\eta\), the maximum number of times the training dataset can be entirely traversed \(T\), the loss function \(\mathcal{L}(W,D)\), and the global iteration number \(R\). ### Local Model Training and Parameter Uploading

* Local model training phase Each participant \(U_{i}\) begins local training using the initial model parameters \(w_{0}\) on its local dataset \(D_{i}\) based on the stochastic gradient descent (SGD) algorithm to obtain its local model parameters \(w_{i}\), as shown below: \[w_{i}=w_{0}-\eta*\mathcal{L}(w_{0},D_{i})\] (1) where \(i\in\{1,2,\ldots,n\}\). * Parameter upload stage The first participant in each group utilizes a pseudo-random generator to produce a random number \(r_{i}\), which serves as a mask for the local model parameters to obtain the obfuscated local model parameters \[w_{1}^{*}=w_{1}-r_{i},\] (2) and sends \(w_{i}^{*}\) to the next participant for aggregation \(w_{i+1}^{*}\) \[w_{i+1}^{*}=w_{i+1}+w_{i}^{*}.\] (3) The process is repeated until the last participant's local model parameter in the group also participates in the aggregation, resulting in the local model parameter \(W_{i}\) for the current group. \[W_{i}^{*}=w_{k}+w_{k-1}+\cdots+w_{1}-r_{i},\] (4) \(k\) denotes the total number of participants in the current subgroup. The first participant in each group homomorphically encrypts \(r_{i}\) to obtain \(H(r_{i})\), which is then sent to the dual servers in a secret sharing manner, with each server receiving a share as \(H(r_{i})^{x}\) and \(H(r_{i})^{y}\), where \(i\in{1,2,\ldots,m}\); the last participant in each group homomorphically encrypts \(W_{i}\) using \(sk\) to obtain the validation label \[\delta_{i}=H(W_{i})\] (5) The local model parameters \(W_{i}\) and the validation label \(\delta_{i}\) are sent to the dual servers in a secret sharing manner, with the servers receiving their respective shares as \(W_{i}^{x}\), \(W_{i}^{y}\), \(\delta_{i}^{x}\), and \(\delta_{i}^{y}\), where \(i\in{1,2,\ldots,m}\). After receiving their respective shares, the servers proceed to the next step. In this step, the operation of adding masks is performed exclusively by the first participant of each group and the operation of homomorphic encryption is performed only by the first and last participants within each group. ### The Servers Compute and Return the Aggregated Results

\(S_{1}\) uses a pseudo-random generator to restore the mask \(r_{i}\) for each group and performs an addition operation with the share \(W_{i}^{x}\) of the resulting local aggregation result for each group, calculating

\[W^{x}=\sum_{1}^{m}W_{i}^{x}+\sum_{1}^{m}r_{i}, \tag{6}\]

and also performs a multiplication operation on the validation labels, calculating

\[\delta^{x}=\prod_{1}^{m}\delta_{i}^{x}. \tag{7}\]

Similarly, \(S2\) performs an addition operation with the share \(W_{i}^{y}\) of the resulting local aggregation results of each grouping, calculating

\[W^{y}=\sum_{1}^{m}W_{i}^{y}, \tag{8}\]

and also performs a multiplication operation, computing

\[\delta^{y}=\prod_{1}^{m}\delta_{i}^{y}. \tag{9}\]

After the computation, the result is returned to each participant for validation. In this process, the secret shares received by the dual servers represent the data of each grouping. The servers only need to perform addition or multiplication operations on the data as required. After the calculation, the results are returned to the participants for final verification.