# AI Training Data Management for Reliable Autonomous Vehicles Using Hashgraph
## 4 Proposed System
### Smart Contract  
A smart contract is a self-governing, automatically executed program deployed on a blockchain that enforces predefined rules without dependence on centralized authorities. It improves data reliability, transparency, and security by automating transaction workflows and maintaining immutable records across the distributed ledger. Unlike conventional software systems that require administrative involvement or manual supervision, smart contracts are executed uniformly across all network nodes. This decentralized consensus framework ensures deterministic behavior and verifiable execution, regardless of the system's conditions or user's privileges. In the proposed system architecture, the smart contract is designed to manage cryptographic hash values instead of directly storing raw datasets. This approach significantly reduces storage overhead while ensuring data integrity and supporting system scalability. In contrast to traditional database systems that rely on centralized management and that are prone to single points of failure or unauthorized changes, smart contracts function in a distributed environment. They inherently offer immutability and trustless verification, guaranteeing that once the integrity of a dataset is recorded, it cannot be modified or deleted. To support these functionalities, the smart contract implemented in our framework consists of two primary components, namely state variables and execution logic. The state variables fulfill the following roles: they store basic text entries for demonstration or testing purposes; associate dataset identifiers with their respective cryptographic hash values; and record the total number of hashes registered in the system. Additionally, the contract defines two fundamental processes to facilitate hash-based verification. The first process records a newly computed hash on the blockchain and links it with a unique internal reference. The second process confirms dataset integrity by comparing the current hash with the previously stored one, thereby verifying whether the data have remained unchanged. Figure 3 uses color-coded blocks to distinguish between storage-related variables and verification methods. Taken together, these components enable the smart contract to manage dataset authenticity and integrity. The contract is designed to support the following two main operations:  
Figure 3: Structure of a smart contract. Hash registration records cryptographic hashes on the blockchain to generate unique and immutable identifiers for each dataset. This process ensures that all datasets are verifiably protected against unauthorized alterations. * Integrity verification retrieves and compares stored hashes with newly computed ones to detect discrepancies, thereby validating the dataset's integrity prior to AI training. Algorithms 1 and 2 formally describe the uploading and verification logic implemented in the smart contract. The process begins with the computation of a dataset's hash value, which is then registered on the blockchain. Later, the system recomputes the hash and compares it with the stored value to verify whether the dataset has remained intact. ```
1:Input: Dataset folder path, smart contract instance
2:for all files in dataset folder do
3: Read file contents
4: Compute SHA-256 hash
5: Contrirm transaction
6:endfor
```  
**Algorithm 1** Uploading Process  
In the registration phase, the smart contract generates a cryptographic digest for each dataset and immutably stores it on the blockchain. This ensures that any subsequent attempt to alter the data can be reliably detected by comparing the original hash with a newly generated one. The process establishes a verifiable snapshot of the dataset's state at the time of its initial upload. During the verification phase, a new hash is computed from the current dataset and checked against the original. A match confirms that the dataset is authentic and suitable for use in AI model training.