## 8 Anonymity and Security Analysis
### Sink Security  
ADV can learn that a sensor has received a message in two ways: (i) When the sensor retransmits the message, which was tracked beforehand to another sensor; (ii) the ADV is able to make a correlation between the captured ID and the physical recipient sensor. The adversary cannot locate the BS location by compromising only one neighboring sensor because each transmission uses a different pseudonym. It actually will need to compromise multiple colluding sensors along the path to the BS or many neighbors of the BS. While we cannot prevent having many physically fallen sensors, our framework's goal is to delay the capturing of the BS if there are many colluding captured sensors in the WSN. A very interesting _scenario_ is _exhibited_ in Figure 19. Let us presume SN\({}_{\text{r}}\)\(\in\) N\({}_{\text{cs}}\). It issues a message with D\({}_{\text{bomb}}\) such that: _APID\({}_{r}\)_ // _OHPID\({}_{r\leftrightarrow u}\)_ // _E\({}_{r\leftrightarrow u}\)_ (APID\({}_{r}\)_ // _PID\({}_{r}\)_ // _E\({}_{kr\leftrightarrow bs}\)_ (_D\({}_{\text{bomb}}\)_))_. IF ADV compromise multiple nodes along the path to the BS where each sensor decrypts the data to read this _signature_ at every hop: _(PID\({}_{r}\)_ // _E\({}_{kr\leftrightarrow bs}\)_ (_D\({}_{\text{bomb}}\)_)_. Providing the colluding sensors, in the path to the BS, read similar signature while it knows by design that every message should be directed uplink to the BS, the ADV could follow through to the BS. Having multiple compromised paths (with compromised sensors) reading the same pattern will give adversary more clues. Compromised nodes can even collude to force the real messages to route through fixed suspected areas in effort to focus the capturing process, which becomes a function of: (i) the size of the network; (ii) The traffic density; (iii) the number of compromised nodes. To solve this issue, we have to wipe out the signature before each transmission. Thus, every message will be forwarded to the next hop as below:  
\[\text{M}_{\text{u}\rightarrow\text{x}}=\text{APID}_{\text{u}}\parallel \text{OHPID}_{\text{u}\leftrightarrow\text{x}}\parallel\text{E}_{\text{u} \rightarrow\text{x}}\left(\text{APID}_{\text{u}}\parallel\text{PID}_{\text{ r}}\parallel\text{PID}_{\text{u}}\parallel\text{E}_{\text{k}\leftrightarrow\text{ bs}}\left(\text{E}_{\text{k}\leftrightarrow\text{bs}}\left(\text{D}_{\text{i}}\right)\right)\right) \tag{47}\]  
We have added a multiple levels of encryption, which will be done at every hop using the shared key between the hop and the BS. In addition, PID of the hop will be added in sequence so the BS can do the decryption in sequence. This solution increases the size of the message proportionally to the number of hops. We suggest having the onion encryption done for a distance of few hops, O\({}_{\text{h}}\). So, if\(\mathrm{O_{h}}=2\), then we have only two extra encryptions. In addition, we need to account for \(\mathrm{O_{h}}\) PID's added to the message. We have implemented using Matlab a WSN of 100 SNs uniformly distributed over 30 \(\times\) 30 area where the average distance between the SNs 3.7 as in Figure 12. The nodes are homogeneous in terms of initial energy. The WSN adopted one BS located at the side of the network. The SNs were preloaded with all the initial pseudonyms, so the simulation started right at the communication phase. Sensors issue real messages according to a normal distribution using SGAT. To simulate how the network behaves to protect the BS, the simulation inserted some random compromised sensors. The compromised sensors sent some bomb messages as exhibited in Figure 19 and colluded to track the location of the BS. We have protected the BS by using the onion encryption so, we have simulated for \(\mathrm{O_{h}}\) equals to 1, 2 and 3. The adversary succeeds when it identifiers all the nodes forming the curve around the BS; SNs have 1, 2 and 3 hc from the BS, consecutively. Figure 20 exhibits the number of transmissions required before the adversary can succeed.