# Enhancing Resilience in Digital Twins: ASCON-Based Security Solutions for Industry 4.0
## 3 Proposed Solution
### Payload Encryption Algorithms  
Payload encryption is a technique for ensuring message confidentiality at the application level. In other words, this approach can be used to establish an end-to-end secure channel between the sender and receiver at the application level to provide confidentiality over transmitted data. However, in this paper, we extend the scope beyond message confidentiality and introduce the use of the ASCON ([4]), a family of authenticated encryption with associated data (AEAD) algorithms, to provide both message authenticity and confidentiality. We used both C implementations of both encryption algorithms, ASCON ([[https://github.com/ascon/ascon_collection](https://github.com/ascon/ascon_collection)]([https://github.com/ascon/ascon_collection](https://github.com/ascon/ascon_collection)) (accessed on 20 May 2023)) and AES-GCM ([[https://github.com/usnistgov/Lightweight-Crypto-graphy-Benchmarking/tree/main/implementations/_reference_/crypto_aead/aes-gcm/mbedtls](https://github.com/usnistgov/Lightweight-Crypto-graphy-Benchmarking/tree/main/implementations/_reference_/crypto_aead/aes-gcm/mbedtls)]([https://github.com/usnistgov/Lightweight-Crypto-graphy-Benchmarking/tree/main/implementations/_reference_/crypto_aead/aes-gcm/mbedtls](https://github.com/usnistgov/Lightweight-Crypto-graphy-Benchmarking/tree/main/implementations/_reference_/crypto_aead/aes-gcm/mbedtls)) (accessed on 20 May 2023)) and Java implementation of ASCON for Ditto. The C language was opted for ESP32, since C and C++ are more suitable for low-level programming in such resource-constrained devices. The ESP32's main application was developed in C++, whereas the encryption algorithms, ASCON and AES-GCM, were implemented in C. Since Ditto enables extending connectivity  
Figure 2: Scheme of Payload Encryption With Authentication Over MQTT Protocol. modules using jar packages, we chose to use the Java implementation of the ASCON. For performance analysis purposes, applying encryption algorithms to Ditto was not necessary, but to demonstrate a fully functional system, we incorporated ASCON on the Ditto side. We selected and deployed C implementations of ASCON ([[https://github.com/ascon/ascon_collection](https://github.com/ascon/ascon_collection)]([https://github.com/ascon/ascon_collection](https://github.com/ascon/ascon_collection)) (accessed on 23 May 2023)) and AES-GCM ([[https://github.com/usnistgov/Lightweight-Crypto-graphy-Benchmarking/tree/main/implementations/reference_/crypto_aead/aes-gcm/mbedts](https://github.com/usnistgov/Lightweight-Crypto-graphy-Benchmarking/tree/main/implementations/reference_/crypto_aead/aes-gcm/mbedts)]([https://github.com/usnistgov/Lightweight-Crypto-graphy-Benchmarking/tree/main/implementations/reference_/crypto_aead/aes-gcm/mbedts](https://github.com/usnistgov/Lightweight-Crypto-graphy-Benchmarking/tree/main/implementations/reference_/crypto_aead/aes-gcm/mbedts)) (accessed on 23 May 2023)) algorithms on the hardware IoT device was carried out using C and C++ programming languages within the Arduino for the ESP-IDF embedded development framework ([[https://github.com/ascon/ascon_collection](https://github.com/ascon/ascon_collection)]([https://github.com/ascon/ascon_collection](https://github.com/ascon/ascon_collection)) (accessed on 24 May 2023)). We chose C and C++ as implementation languages due to their suitability for low-level programming in resource-constrained devices.