## 3 Proposed Solution
### Gini Index-Based Trust Model  
The Gini index describes the degree of income dispersion across the whole income spectrum by integrating specific share data into a single statistic [72]. The Gini coefficient ranges from 0 to 1, with 0 denoting perfect equality and 1 denoting perfect inequality. It measures the difference between the observed cumulative income distribution, or Lorenz curve, and the idealized case of completely equitable income distribution. Gini impurity, another name for the Gini index, is used to measure the likelihood or severity of misclassification when a variable is chosen at random. When all the elements fall into a single class, a state of purity results, and the idea of \"impurity\" is introduced. The core idea of the proposed Gini countermeasure is to exploit the statistical properties of entities for the detection and mitigation of blackhole and greyhole attacks. The Gini countermeasure, in particular, evaluates the variation in received DAO messages using the Gini index-based theory, allowing the identification of probable blackhole or greyhole attacks, as depicted in Figure 2. The Gini countermeasure launches the appropriate mitigation steps to lessen the impact of such attacks as soon as they are discovered. The generic mathematical notation of the Gini index for attack detection in a CPS is given below:  
1. The Gini index's degree ranges from 0 to 1. 2. \"0\" indicates that there is only one class (pure) or that all elements fall under that class. 3. The number \"1\" indicates that the elements are dispersed at random (impure) throughout the classes. 4. An equal distribution of elements into some classes is indicated by a Gini index value of 0.5. Let \(I\) be the Gini index, which represents the inequality of flow distribution in the CPS network, as shown in the Equation (1). \[I=1-\sum_{i=1}^{n}(a_{i})^{2} \tag{1}\]  
where \(a_{i}\) denotes the proportion of flow \(i\) in a network. The Gini index idea can be used to evaluate resource allocation and spot potential weaknesses in the context of CPS security [73]. Computational power, bandwidth, and storage are among the resources that are distributed among different system components and entities in CPS. However, an uneven distribution of resources might provide attackers  
Figure 2: Trust thresholds for Gini index in CPS. access to vulnerable points, jeopardizing the system's overall security and functionality. The Gini index becomes important in this situation. By computing the ratio between the cumulative differences in resource allocation and the total allocation, the Gini index gives a quantitative indicator of resource distribution. A higher Gini index value denotes a system with more resource inequality or imbalance. Researchers and practitioners in CPS security can learn more about resource distribution trends and spot potential weak spots by using the Gini index. The capacity of the Gini index to identify resource imbalances that potential attackers can exploit makes it relevant to CPS security. Security teams can identify and investigate resource allocation abnormalities that could be signs of attacks or unauthorized resource use by tracking the Gini index over time. In order to discover weaknesses and improve the overall security posture of CPS, the Gini index functions as a metric that supplements conventional security measures. The Gini index can also be used to increase security measures and give priority to resource allocation in vulnerable areas [74]. The Gini index assists in reducing the danger of blackhole and greyhole attacks, in which resources are fraudulently devoured or purposely diverted, by correcting resource imbalances and ensuring a more equitable distribution. Given that it provides a quantitative evaluation of resource allocation and risk inside the system, the Gini index notion is extremely pertinent to CPS security. Security professionals can identify potential attack vectors, understand resource imbalances, and prioritize security solutions by using the Gini index [75].