## 4 A Privacy-Aware and Secure Decentralized Framework
### Security of WSN Data Processing  
The decentralized framework presented in this contribution makes use of the technique described in [37] to distribute the processing load of training a data mining model among sensor network nodes while ensuring the security of data processing. In the following, we will refer to the General Purpose Data and Query Privacy Preserving Protocol for WSNs described in [37] as DQ3P. DQ3P was proposed for retrieving aggregated data from a WSN by securely conveying general-purpose computer code through a set of sensor nodes.  
In this contribution, we adopt the DQ3P to deliver data mining models to WSN nodes. Therefore, model training can be carried out in situ without endangering the data privacy of the sensor nodes. DQ3P relies on encryption to deliver the data mining model only to nodes that will carry out model learning. Furthermore, the identity of nodes carrying out model learning is hidden among a set of other nodes that receive the data mining model without encryption keys for accessing it. Thus, the identity of nodes contributing to model learning is known only to the origin, in [37] it is shown that DQ3P is secure even if some nodes associated with the network are intentionally collaborating to disclose data privacy of other sensor nodes. Moreover, DQ3P withstands traffic analysis attacks by generating uniformly distributed network traffic.  
The DQ3P defines a particular message; we refer to it as the onion message, which consists of the onion head and the onion body as shown in Figure 3. The onion head is a layered object made of several encryption layers similar to the one used in the Onion Routing [67]. The encryption layers of the onion head are formed using public-key cryptography; therefore, the message must travel through the exact path specified at message construction, each node in the message path unveiling one layer of the layered object. By the DQ3P design, layers of the onion head include: (a) the IP address of the next node in the  
Figure 2: Incremental learning with Hoeffding trees.  
message path OR (b) the next-hop IP address and two symmetric encryption keys. Onion messages are issued by sink nodes, and message processing at sensor nodes is conditional to the content obtained from layer decryption of the onion head, as follows: (a) Nodes that receive the onion message and obtain only the next-hop IP address from layer decryption of the onion head are not contributing to the model learning. These nodes retain only the onion message for a time interval to simulate model learning task. The onion message is then forwarded to the node at the next-hop IP address. (b) Nodes that also obtain the two symmetric encryption keys from layer decryption of the onion head are nodes that contribute to the model learning. These nodes use the first symmetric encryption key to decrypt the onion body and obtain the data mining model. Model learning is executed on data located on the sensor node, and the updated model is embedded in the onion body. The onion body is then encrypted using the second symmetric encryption key, and the onion message is forwarded to the node at the next-hop IP address.  
As shown in Figure 3, onion messages are transiting in the WSN following the path encoded in encryption layers of the onion head and processing model learning only on specific nodes in the message path. The onion message path ends at the same sink node that issued the onion message since the penultimate layer of the onion head always includes the sink's IP address. The last layer of the onion message includes the encryption key to access the content of the onion body and thus obtain the data mining model trained on the data of sensor nodes in the onion message path.