## 4 Implementation and Evaluation
### Experimental Results  
In the configuration of the proposed Trust-Based algorithm, Speak-128 [11] will be used for encryption. Details of this algorithm and its impact on WSNs are explained in [14; 45]. Details of the effect of block size and the number of rounds on encryption complexity, as well as the amount of power consumed, are also described in [26]. Furthermore, the scenario used in the simulation does not have the effect of sleep mode on the sensors CPU, as they are all in working mode for the duration of the execution. The relationship between security and trust to be used is shown in Figure 7. The Figure shows the relationship between increased trust between WSN nodes and reduced security complexity in generating different keys and the effect of reducing block size on Speak-128 algorithm. If the Trust-level reaches 50%, the security complexity will decrease by 10%. When Trust-level reaches 70%, security will decrease by 30%. When Trust-level reaches 90%, the security will drop to 30%. Finally, if the Trust-level reaches one value, the security complexity is reduced to 20%. As we also mentioned, the authentication process will use only one encrypted key management. Figure 6: WSN nodes distribution in the Cooja simulator. In order to measure the effect of block size automation in cryptography on the proposed method and its effect on reducing power consumption, Figures 8 and 9 illustrate this relationship. In the first scenario, we will examine the power consumption rate of the proposed algorithm (Trust-CH) with the effect of the encryption algorithm (Speck-128) if its encryption is used fully or dynamically. In this scenario, the amount of energy at each node is set at 1 joule and the number of nodes is set at 200 in all scenarios. Execution times were also chosen between 10 s and 40 s to show the effect of increased Trust-level on WSN node power consumption. Figure 8 illustrates this scenario. From Figure 8, we notice that at the beginning of the execution, the Trust level is close to 0, so in 10 s we notice a convergence of power consumption between full (static) and dynamic encryption. Furthermore, because the encryption process depends on the second type (cyprot1) for the most part. After that, the Trust-level increases and the complexity of the encryption decreases, so the differences between static and dynamic encryption increase, reaching a maximum of 40 s, where the difference is 28%. It is also known that with the increase of time the Trust-level increases to reach in most of them (WSN nodes) 100% and this means more savings in the rate of depreciation. Figure 8: The Trust-CH power consumption analysis. Figure 7: The relationship between the level of trust and the level of security complexity. Moreover, Figure 9 presents an analysis of the Trust-CH network lifetime. Increasing the initial power of the network nodes in a time period of about 100 s increases the level of trust between the nodes, resulting in greater energy savings compared to static Trust-CH encryption. In defense operations against malicious attacks, the proposal used the technology of symmetric encryption and symmetric authentication (FlexCrypt) in the event of new WSN nodes join to the CH. Eavesdropping, replay and brute force attacks are subject to protection from these attacks. Other attacks such as black holes are also monitored by monitoring incoming and outgoing messages to and from the CH. Therefore, the suspicion of the WSN node results in a decrease in Trust-level and an increase in the rate of power consumption, which is also the result of the increase in the re-transmission of the packets between the two communication ends (nodes). Figure 10 shows the effect of different percentages of attacks on the network, as the increase in attacks results in a decrease in the life of the network. Figure 10 shows the percentages of WSN nodes under attack between 5% and up to 30% of the total WSN nodes. Trust-CH network lifetime decreases by 12% when malicious WSN nodes increase from 5% to 30%.