# An Improved Federated Learning-Assisted Data Aggregation Scheme for Smart Grids
## 5 Technical Intuition  
In this model, each user \(u\in\mathcal{U}\) possesses a private vector \(x_{u}\) of size \(m\), \(x_{u}\) includes the parameters of the model obtained by the user after local training using private data. We further assume that \(\sum_{u\in\mathcal{U}}x_{u}\) and its elements are for \(R\) in \(\mathbb{Z}_{R}\). The server (S) plays the role of an aggregator, which aggregates the data transmitted by each user (u) and trains the data to obtain a new model \(M\). The objective of this model is to ensure the privacy of the user's data during the FL process. The server only obtains the sum of the parameters provided by the users to the client \(\sum_{u\in\mathcal{U}}x_{u}\), while each user has the ability to verify the final model returned by the \(CS\).  
In order to provide privacy to the model parameters \(x_{u}\) of the users, we add two random vectors, \(s_{u,v}\) and \(b_{u}\), to each user's \(x_{u}\) to compute \(x_{u}\) in perfect secrecy. We assume that the list of users is ordered and that there is a random vector \(s_{u,v}\) between each pair of users \((u,v)\). Before a user sends \(x_{u}\) to the server, the random vector \(s_{u,v}\) between \(u\) and every other user \(v\) is added to \(x_{u}\), namely:  
\[y_{u}=x_{u}+\sum_{v\in\mathcal{U},u<v}s_{u,v}-\sum_{v\in\mathcal{U},u>v}s_{v,u} \tag{4}\]  
and, finally, the server calculates:  
\[X=\sum_{u\in\mathcal{U}}y_{u}=\sum_{u\in\mathcal{U}}(x_{u}+\sum_{v\in \mathcal{U},u<v}s_{u,v}-\sum_{v\in\mathcal{U},u>v}s_{v,u})=\sum_{u\in\mathcal{ U}}x_{u} \tag{5}\]  
To ensure that a user cannot quit midway before committing \(y_{u}\) to the server, leading to the server's inability to recover from \(X\), we implemented a Pseudorandom Generator (**PRG**) technique. This method involves generating random vectors using **PRG**[36; 37], and then sending the seeds used for generating these random vectors to all other usersthrough threshold secret sharing of Diffie-Hellman secret shares. By doing so, even if a user \(v\) decides to quit midway, the server can still reconstruct a random vector associated with \(v\) using the shares provided by other users. And to prevent the server from obtaining the private data \(x_{u}\) of user \(u\) by asking users for their shares of \(s_{u,v}\), we add another random vector \(\textbf{PRG}(b_{u})\) to \(x_{u}\), where \(b_{u}\) is seeded to a random vector that is unique to each user. Also, transferring these seeds for **PRG** between users saves more communication overhead than transferring the entire random vector. Then, before a user sends \(x_{u}\) to the server, the user needs to calculate the following:  
\[y_{u}=x_{u}+p_{u}+\sum_{v\in\mathcal{U}_{2}}p_{u,v} \tag{6}\]  
and the server needs to calculate  
\[X=\sum_{u\in\mathcal{U}^{\prime}}x_{u}=\sum_{u\in\mathcal{U}^{\prime}}y_{u}- \sum_{u\in\mathcal{U}^{\prime}}p_{u}+\sum_{u\in\mathcal{U}^{\prime},v\setminus \mathcal{U}^{\prime}}p_{v,u} \tag{7}\]  
In the above formula, \(\mathcal{U}^{\prime}\) means all surviving users, and \(p_{u,v}=\Delta_{u,v}\cdot\textbf{PRG}(s_{u,v})\), where \(\Delta_{u,v}=1\) when \(u>v\), \(\Delta_{u,v}=-1\) when \(u<v\), \(p_{u}=\textbf{PRG}(b_{u})\).  
Prior to the secure aggregation round, the server needs to make a specific decision for each user \(u\). The server can request either \(s_{u,v}\) or \(b_{u}\) shares, which are associated with \(u\) from each remaining user other than \(u\). It is important to note that an honest user will never disclose both shares of the same user. Once the server has collected at least \(t\) shares of \(s_{u,v}\) from the departing user and \(t\) shares of \(b_{u}\) from all remaining users, it can subtract the remaining masks to obtain the precise aggregation result.