# Enhancing Resilience in Digital Twins: ASCON-Based Security Solutions for Industry 4.0
## 3 Proposed Solution
### Ditto Java Base Payload Mapping
To obtain accurate measurements, we allow our programs to run 1000 function calls sending data after encryption for each case scenario. We then calculate the average execution time using a Python script that processes the dump file we collected from the device. As it can be seen from Figure 5(a), ASCON's execution time is lower than AES-GCM. Similarly, Figure 5(b) shows that our proposed solution performs well when ASCON is used. These results suggest that ASCON is a promising candidate for use in our proposed solution. To measure the execution time of the algorithms, we utilized the built-in function esp_timer_get_time() from the ESP-IDF framework. By capturing the start time before executing the function and the end time after the function completes, we calculated the execution time by subtracting the start time from the end time. Our experimental setup comprised three distinct case scenarios. Firstly, we measured the execution time when the application ran without any encryption algorithm. Next, we measured the execution time when messages were encrypted using ASCON and AES algorithms. It's important to note that we evaluated the performance of the proposed solution from two perspectives:

1. The _time_ required to run the encryption algorithm within the application program
2. The _total time_ needed to process the message and send it to the Digital Twin (Cloud)

As Figure 5(a) illustrates, ASCON's execution time was lower than that of AES-GCM. Similarly, Figure 5(b) demonstrates that our proposed solution performed well when ASCON was used. These results strongly suggest that ASCON is a promising candidate for integration into our proposed solution. Throughput and Cycle Byte Ratio

Throughput is a performance indicator of a system that measures the number of bytes processed per unit of time (typically seconds). It is a measure of how efficiently a system can process data. The more bytes that are processed per unit of time, the better the system performs. Throughput is typically measured in bytes per second (Bps) or kilobytes per

Figure 6: Performance of three case scenarios from algorithm execution speed and application running time. second (Kbps). The Cycle Byte Ratio is another performance metric that measures the number of CPU cycles needed to process a single byte. Table 2 presents the cycle counts for different scenarios: (1) without employing any encryption algorithm, (2) utilizing the ASCON encryption algorithm, and (3) employing the AES-GCM encryption algorithm. Throughput serves as a crucial performance indicator for a system, quantifying the number of bytes processed within a specific time frame, typically measured in seconds. It gauges a system's efficiency in handling data; the higher the throughput, the more efficiently the system processes information. Additionally, the Cycle Byte Ratio, another vital performance metric, calculates the number of CPU cycles required to process a single byte of data. Table 2 displays cycle counts for the three different scenarios mentioned in Section 4.1:

\[\text{Throughput}=\frac{\text{Byte processed}}{\text{Total Time}} \tag{1}\]

\[\text{Cycle Byte}=\frac{\text{Cycle Count}}{\text{Byte processed}} \tag{2}\]

The total time taken by the CPU to perform an operation can be derived using cycle count and the CPU clock frequency using the following formula:

Figure 3:0

In this experiment, we use \(xthal\_get\_count()\) from esp32/ck.h library to obtain the cycle count at a given time, and the \(getCpuFrequencyMhz()\) function to obtain the current set CPU frequency of the device from esp32-hal-cpu.c source file. We calculated the throughput and Cycle Byte Ratio of each algorithm in the proposed solution processing 16 bytes of messages and 16 bytes of associated data, using Equations (1) and (2). The results are shown in Figure 6(a),b.