## 5 Security Analysis  
In this section, we analyze the confidentiality and integrity properties of our proposed scheme for the adversary model presented in Section 3.4.  
**Theorem 1**.: _Our scheme is robust against an adversary of **Type 1** and his attack as it provides end-to-end confidentiality of data._  
**Proof of Theorem 1.** In the proposed scheme, all data transmitted from sensor nodes to the access point are encrypted with a homographic encryption algorithm by using a shared secret key. Therefore, only parties that know the shared secret can decrypt it. In our scheme, only the access point storesthat shared secret and can obtain the plain data. So, even though an adversary of **Type 1** eavesdrops on the transmission between sensor nodes and CH or the transmission between CH and access point, he cannot reveal the content of the messages. This way, the scheme provides end-to-end confidentiality. \(\square\)  
**Theorem 2**.: _Our scheme provides end-to-end integrity in the presence of an adversary of **Type 2**._  
Proof of Theorem 2.: The scheme introduces a randomized watermarking technique that checks and verifies the integrity of all packets sent through the network. Any malicious act done to the packet will result in the rejection of that packet. In the following, we state how the scheme secures the network from an attack of the adversary of **Type 2**. \(\square\)  
1. **Injection Attack:** an adversary needs to generate a valid watermark to embed it into the injected data. This requires him to know the shared secret cluster key to generate it. Even if the shared secret is somehow disclosed, he will then need to know the random places to embed it. This requires knowledge of the secret PRNG parameters. This way, all injected false data are rejected either at the CH or the access point.
2. **Replay Attack:** an adversary resends old messages that he captures from the past. This will result in message drops, as all packets contain a timestamp to ensure that the packet is fresh.
3. **Modification Attack:** an attacker can modify the data sent and the packet will still look valid. That is due to the homomorphic encryption function's properties. For example, a message \(m\) can be altered to \(m+x\), where \(x\) is the modified value. The recipient can decrypt the message and obtain the modified value. In our scheme, the watermark is computed from the encrypted message and embedded inside the payload. So, any alteration done to the encrypted data will result in a failure of verification of the watermark.  
**Theorem 3**.: _Our scheme is robust against an internal adversary that can compromise a node even if he can control a node or CH from the network._  
Proof of Theorem 3.: In the proposed scheme, each cluster has its own security parameter. Therefore, even when an adversary compromises a sensor node or a CH, he will be able to manipulate and control one cluster alone. The access point verifies all clusters' data individually, and accepts the valid ones and rejects the others. \(\square\)  
**Theorem 4**.: _Our scheme provides en-route filtering for data injected into the network._  
Proof of Theorem 4.: The scheme verifies every packet from sensor nodes at CH. Therefore, any injected data at any level will be filtered at the next highest level. The end-to-end integrity that is provided by other schemes is not sufficient and can waste energy when forwarding false packets to the access point without verifying its integrity. \(\square\)