# Smart Devices Security Enhancement via Power Supply Monitoring +
## 3 Proposed Side-Channel Monitoring Device
### Proposed Setup  
In order to implement the proposed setup, we assembled, as the target device, a custom IP camera and used a low-cost micro-controller to monitor the power energy average of the targeted device. As a target device, we created an IP camera on a programmable micro-computer appropriate for our purposes. The micro-controller device was interposed between the power supply and the monitored device. The clarification is as follows:  
* The monitoring circuit includes a 1 Ohm resistor and a smaller calibrating resistor used for accuracy reasons. The resistor is located between the two inputs of the micro-controller in order to measure the average. The power amperage can be calculated through the measurement of the voltage at the two input points according to the following formula: \[I=\frac{V_{2}-V_{1}}{R}\] (1) where \(V_{1}\) and \(V_{2}\) are the two reference voltages as depicted in Figure 2, and R is the 1 Ohm resistor. * Two analog inputs of the micro-controller are connected to the circuit (Figure 2) in order to collect the power measurements. The first input is connected to the point before the resistor while the second is used to measures the voltage at the other end of the resistor. * Finally, the device to be monitored is connected serially to the resistor. The circuit is completed by connecting an Alternating Current (AC) power supply 5 V for the power jack. Additionally we improved the Signal-to-Noise Ratio (SNR or S/N) with a software technique. The monitoring device may be easily programmed and thus, a moving window algorithm was exploited to smoothen the signal deviations. Thus, spikes may be eliminated when occurring rarely, while a more frequent appearance of spikes is preserved for anomaly detection. This signal smoothing technique is called the moving average. From the raw data sequence [\(y_{1}\), \(y_{2}\),..., \(y_{N}\)], we created a corresponding smoothed data sequence. The smoothed point \((y_{k})_{s}\) is the mean of an odd number \(2n+1\) (\(n=1,2,3\),...) of the raw data sequences \(y_{k-n}\), \(y_{k-n+1}\),..., \(y_{k-1}\), \(y_{k}\), \(y_{k+1}\),..., \(y_{k+n-1}\), \(y_{k+n}\), i.e.,:  
\[(y_{k})_{s}=\sum_{i=-n}^{i=n}y_{k+i}/(2n+1) \tag{2}\]  
The odd number \(2n+1\) is the window width. The larger the window width, the more intense the smoothing. The SNR can be further enhanced by increasing the window width or by multiple window passes (smoothing at already smoothed points). During average moving window processing, a spike calculation is also conducted, comparing value \(y_{k}\) to the thresholds \(y_{thres.max}\) and \(y_{thres.min}\). Let us assume that the spike is positive, that is, the signal is ascending; then, \(sp_{k}\) is set to 1 only in case \(y_{k}\) is greater than \(y_{thres.max}\). The \(sp_{k}\) is also set to 1 in case the spike is negative, that is, the signal is  
Figure 2: Circuit of Monitoring Device. descending and the \(y_{k}\) is less than \(y_{thres.min}\). Then, the final population of spikes is calculated in a time window including an odd number of samples, e.g., 2_m+1_, where _m+n_. \[sp_{k}= \begin{cases}1&\text{if $y_{k}>y_{thres.max}$ and $y_{k}-y_{k-1}>0$,}\\ 1&\text{if $y_{k}<y_{thres.min}$ and $y_{k}-y_{k-1}<0$,}\\ 0&\text{if $otherwise$}\end{cases}  \tag{3}\]  
where the \(k\)-th sample has a value of \(y_{k}\), which is compared to the appropriate threshold \(y_{thres.max}\) or \(y_{thres.min}\), respectively, to its previous value. The calculation is performed for 2_m+1_ samples \(y_{k-m}\), \(y_{k-m+1}\),..., \(y_{k-1}\), \(y_{k}\), \(y_{k+1}\),..., \(y_{k+m-1}\), \(y_{k+m}\), where _m+n_. Then, a rough estimation of the identified spikes in the 2_m+1_ consecutive samples is performed with the following equation:  
\[spikes=\sum_{i=-m}^{i=m}sp_{k+i} \tag{4}\]  
The selection of \(m\), \(n\), \(y_{thres.max}\) and \(y_{thres.min}\) in this work was considered as information given by the manufacturer of the IoT device. The typical value for \(m\) is 5000 and for \(n\), it is 20.