# GHEFL: Grouping Based on Homomorphic Encryption Validates Federated Learning
## 4 The Proposed Scheme  
This section presents the overall framework diagram of GHEFL, as illustrated in Algorithm 1, and elaborates on the technical details of the proposed scheme. In the system initialization phase, the primary tasks include initializing public parameters, generating keys, and grouping participants. The second phase involves local model training by participants, intra-group parameter aggregation, and uploading aggregated parameters. In the third phase, the server receives the parameters, computes the global aggregation, and returns the results. Finally, in the fourth phase, participants verify the correctness of the obtained aggregation results. The detailed steps are as follows:```
1:learning rate \(\eta\), number of iterations \(T\), loss function \(\mathcal{L}(W,D)\), users \(\mathcal{U}\), data sets \(\mathcal{D}\). 2:a secure global model \(W\). 3:Setup Phase
4:TA generates a pair of key \((pk,sk)\) of Paillier cryptosystem for users, The servers send the global model \(w_{0}\) to each user \(U_{i}\), and group users into group \(\mathcal{G}\), server \(S_{1}\) picks up a random seed seed. 5:Local Training Phase
6:for each group \(G_{i}\in\mathcal{G}\)do
7:for each user \(U_{j}\in G_{i}\)do
8:\(w_{ij}\gets w_{0}-\eta*\mathcal{L}(w_{0},D_{i})\)
9:endfor
10:endfor
11:Group Aggregation And Upload Phase
12:for each group \(G_{i}\in\mathcal{G}\)do
13:\(S_{0}\) sends seed to the first user in each group \(G_{i}\). 14:for each first user \(G_{i1}\in G_{i}\)do
15:\(r_{i}\gets PRG(seed)\), \(w_{i1}^{*}=w_{i1}-r_{i}\), \(H(r_{i})\gets Enc(sk,r_{i})\)
16:Computes \(H(r_{i})=H_{i}^{0}+H_{i}^{1}\), then respectively sends to the server \(S_{1}\) and \(S_{2}\). 17:endfor
18:\(G_{i1}\) sends \(w_{i1}^{*}\) to the next user, until the last one. 19:for each last user \(G_{k}\in G_{i}\)do
20://Group Aggregation
21:\(W_{i}=\sum_{j=1}^{k}w_{ij}-r_{i}\)
22://Verification tag
23:\(\sigma_{i}\gets Enc(sk,W_{i})\)
24:Computes \(W_{i}=W_{i}^{0}+W_{i}^{1},\sigma_{i}=\sigma_{i}^{0}+\sigma_{i}^{1}\), then respectively sends to the server \(S_{1}\) and \(S_{2}\). 25:endfor
26:Server Aggregation Phase
27:for server \(S_{1}\)do
28: constructs \(r_{i}\gets PRG(seed)\)
29://Global Aggregation
30:\(W^{0}=\sum W_{i}^{0}+\sum r_{i}\)
31://Verification tag Aggregation
32:\(\sigma^{0}=\prod\sigma_{i}^{0}\)
33:endfor
34:for server \(S_{2}\)do
35:\(W^{1}=\sum W_{i}^{1},\sigma^{1}=\prod\sigma_{i}^{1}\)
36:endfor
37:Send \(W^{0},W^{1}\) and \(\sigma^{0},\sigma^{1}\) to the users. 38:Verification Phase
39:for each users \(i_{1}\)do
40:\(W=W^{0}+W^{1},\sigma=\sigma^{0}*\sigma^{1}\)
41:if\(Enc(sk,W)=\sigma\)then
42: The users accept the aggregated result and start the next round of training. 43:else
44: The users reject the aggregated result. 45:endif
46:endfor
47:return\(W\)
```

**Algorithm 1** The detailed procedures of GHEFL. ### System Initialization

Suppose there are \(n\) participants in the system, denoted as \(U_{i}\), each with a local dataset \(D_{i}\), where \(i\in N\) and \(N=\{1,2,\ldots,n\}\). The server initializes the global model parameters to \(w_{0}\), thus providing a unified model structure to each participant and ensuring that all participants work under the same model framework during subsequent local training and model updates. The participants are then grouped into \(k\) groups (this paper proposes simulating the grouping of participants based on their computational resources), denoted as \(G_{j}\), where \(j\in K\) and \(K=\{1,2,\ldots,k\}\). The essence of grouping is to organize the participants in a group into a participant chain,so the aggregation server should send the neighbor node information of the participants to each participant, thereby facilitating the transfer of training parameters within the group. It is assumed that the neighbor node information of each participant is established before the start of local training. A random _seed_ is generated by \(S_{1}\) and sent to the first participant of each group to assist in the generation of masks by the participants.