## 5 Processing Data in the Encrypted Domain: Secure Data Aggregation  
In-network data aggregation in wireless sensor networks consists in executing certain operations (such as sums and averages) at intermediate nodes in order to minimize the amount of transmitted messages and the processing load at intermediate nodes, so that only significant information is passed along in the network. This leads to several benefits, such as energy savings, which are crucial for constrained environments, such as low-power and lossy networks. Data aggregation refers to a multipoint-to-point communication scenario, which requires intermediate nodes to operate on received data and forward the output of a suitable function applied to such input data. In those scenarios, where privacy on transmitted data is an issue, it might be required to send encrypted data. Encryption can be adopted not only to achieve confidentiality, but also to verify the authenticity and integrity of messages. While secure data aggregation is certainly an application-related aspect also in WSNs, optimized communication can have a positive impact also in some IoT scenarios. Smart parking or critical infrastructures scenarios could benefit from minimizing transmitted data, possibly by adopting privacy homomorphism algorithms, discussed in Section 3. A simple aggregation strategy can be to queue the payloads of the received packets and send out only one packet with all the information. This approach can bring only limited gains, since only the payloads are considered. Another, more efficient, approach can be used if the aggregator is aware of the type of operation that the final recipient is willing to perform. Consider a scenario where a node is interested in counting all the nodes in the network. Nodes send a packet with \"1\" as a content. Aggregators receive these packets and can just sum the \"1\"s received and send out one packet with the same size whose content is the number of \"1\"s received. By doing this, the information sent across the network is minimal and the final recipient must perform simpler processing. Typically, secure data aggregation mechanisms require nodes to perform the following operations:  
1. at the transmitting node, prior to transmission, data are encrypted with some cryptographic function \(E\);2. at the receiving node, all received data packets are decrypted with the inverse cryptographic function \(D=E^{-1}\) to retrieve the original data;
3. data are aggregated with an aggregation function;
4. prior to retransmission, aggregated data are encrypted through \(E\) and relayed to the next hop. This process is iterated at intermediate nodes until the data reach the destination node that is interested in receiving the result of aggregation, as shown in Figure 4. Both symmetric and asymmetric cryptographic schemes can be applied. The aggregation procedure just explained raises the following issues, especially if we consider a scenario where the aggregators are not special nodes, but have the same features as other nodes in the network. 1. Aggregators must decrypt each incoming piece of information before processing, in order to perform the aggregation and, subsequently, encrypt the result before transmission to the next hop. This has clearly an impact on the computation and, therefore, on the energy consumption of the aggregator. 2. An aggregator must keep a secure association (_i.e._, share a symmetric key) with any node that either sends data to or receives data from it. This further introduces the need for increased complexity at the aggregator. 3. Intermediate aggregators access the data that they receive, even though they are not intended to do so, since the actual recipient of the data is another node. This might introduce privacy concerns, especially in scenarios where intermediate nodes might not have a trust relationship with the sender. In order to cope with the problems sketched above, some actions can be considered. All these issues can be addressed by using homomorphic encryption schemes, introduced in Section 3.4.