# Exploiting Blockchain Technology for Enhancing Digital Twins' Security and Transparency
## 5 Working Example
### Stubs' Development  
The legacy code written in C++ and provided by the developers of _Tracker_ presents a complex structure originated from the necessity of extracting key information from the captured frames corresponding to the junctions of the recorded entities in the scene. A critical function of that module is the transformation of extracted data into structured JSON files, followed by their transmission to a designated Apache Kafka topic via an appropriate wrapper. The proposed hash validation architecture integrates with this process at the precise moment prior to data transmission through the Kafka topic. At this stage, the connection to the blockchain is initialized, and the data are stored within the smart contracts. However, due to compatibility issues with the C++ implementation of the Web3 library--used as a standard framework for the stub modules--a Python- wrapped solution was introduced. This solution, executed within the C++ code, was incorporated to enable communication with the system's unified blockchain infrastructure and allow access to the validation system's functionalities. As illustrated in Figure 10 the introduction of the blockchain communicating submodule through the Python-integrated portion of the code (on the right) allowed the  
Figure 9: Diagram of the AiWatch system architecture, emphasizing the integration points for blockchain-based security features. Black arrows indicate data flow, while the blockchain serves as a tamper-proof layer for communication validation. Tracker component to seamlessly communicate with the validating network while keeping its autonomy in its standard functionalities. Instead, the proposed integration of the Ditto sub-module involved the extension of its connectivity capabilities through the development of a dedicated Java software component for filtering incoming messages. This integration methodology was chosen to enable more advanced functionalities required for interaction with blockchain technologies. In fact, at the time of this work, the module included a component responsible for receiving messages via the transmission medium and subsequently converting the corresponding messages into the Ditto Protocol format. This transformation process was achieved through the use of a JavaScript mapping function. However, the original implementation exhibited significant limitations, particularly in terms of extensibility and the ability to incorporate external libraries. To address the encountered issues, the integration of the sub-module involved the elaboration of a newly introduced mapping component. This was achieved  
Figure 10: Portion of the class diagram extracted from the Tracker’s code. The highlighted subsection provides a clarification over the mounting point selected for the introduction of the blockchain-related functionalities by leveraging the introduction of a Python section for the integration of the sub-module. by incorporating the functionalities of the sub-module into a custom mapper implemented in Java, which retained the original core functionality while extending its capabilities. The redesigned component built upon the original mapper and is visually represented through the scheme in Figure 11.  
To further underline the symbiotic and transparent integration of blockchain communication, the proposed implementation ensured that all blockchain-related interactions were natively embedded within the Ditto sub-module. By avoiding reliance on external or third-party software, the design guaranteed seamless integration of blockchain functionalities directly into the core operational workflows. This tight coupling enhanced the transparency of data flow and reduced potential points of failure, enabling robust and secure communication. The approach capitalized on the inherent strengths of Ditto's modular architecture while preserving the autonomy and integrity of the blockchain connection mechanism. The final result was developed following the standard procedures outlined in the Eclipse Ditto documentation.