# Enhancing Resilience in Digital Twins: ASCON-Based Security Solutions for Industry 4.0
## 3 Proposed Solution
### Ditto Java Base Payload Mapping
In resource-constrained devices, power consumption often needs to be measured in microamps or even nanoamps, which can be challenging for standard oscilloscopes. In this section, we outline the methods and outcomes of power measurements conducted on our proposed solution, implemented on the ESP32 device using the _Otii-arch tool_ that calculates power and energy consumption and integrates with software output [26]

Method of Power Measurement

Measuring the power consumption of an algorithm or a running application presents significant challenges, primarily due to power noise generated by other board components like Wi-Fi and Bluetooth. Obtaining an accurate measurement of the power consumption of machine code running on a chip necessitates a meticulously controlled laboratory environment, where the chip is isolated from other components. This process entails connecting a precise voltage source, often an expensive oscilloscope, and then capturing and measuring the power intake of the chip. Nevertheless, in this project, we estimate the power consumption of our proposed solution by employing the Otii arch from Quitech AB. This is achieved through the setup of UART recording techniques [27], enabling us to focus specifically on the power consumption of each function within the running application. The procedure for measuring power consumption using UART recording is outlined as follows and illustrated in Figure 11:

* The measuring device (Oti-arc) is connected to a power source of 3.7 volts. * The application of the proposed solution with UART logging code is built and deployed to the ESP32 device. * A jumper is used to connect GPIO 17 TX from ESP32 to the expansion port RX on the Oti-arch. * In the Otii application, the appropriate digital voltage level for our device is selected, and the UART channel with the correct Baud rate is configured. * The impact of each called function on power consumption is analyzed by marking the UART message from the UART log window to obtain the corresponding power graph from the main window. Table 5 shows the power analysis of three variants of our proposed solution in terms of current intake and energy consumption. The variant with no encryption exhibits lower average current intake and energy consumption compared with the other two variants. The AES-GCM variant consumes more current and energy, indicating its higher resource demands. On the other hand, ASCON maintains in between with average current consumption (116 mA) and energy (530 nWh). The power analysis shows that ASCON requires less power while providing an equivalent level of security compared with AES-GCM. This is also evident from the cycle count of the algorithms, as shown in Table 2. AES-GCM has a higher cycle count than ASCON and No-Encrypption, leading to higher current intake and energy consumption. On the other hand, the cycle count of ASCON falls in between No-Encrypption and AES-GCM, resulting in average current and energy consumption levels higher than No-Encrypption but lower than AES-GCM. Figure 12 shows the power consumption results of three implementations (No-Encrypption, ASCON, and AES-GCM). At around 9.56 s, the power consumption of the three implementations is approximately equal. However, as time progresses, the power consumption of AES-GCM increases significantly, while the power consumption of ASCON remains relatively constant at around 116 mA. This suggests that the AES-GCM algorithm requires more CPU cycles than ASCON, which results in a higher power spike. Figure 11: Power measurement set\(-\)up using Otii\(-\)arch. Figure 12: Power analysis read of LOLIN32 Lite ESP32 using the Otii-arch device. \begin{table}
\begin{tabular}{c c c c c} \hline
**Algorithm** & **Min** & **Avg** & **Max** & **Energy** \\ \hline No encryption is applied & 41.7 mA & 57.1 mA & 117 mA & 262 nWh \\ \hline ASCON & 116 mA & 116 mA & 116 mA & 530 nWh \\ \hline AES-GCM & 136 mA & 192 mA & 227 mA & 878 nWh \\ \hline \end{tabular}
\end{table}