## 3 Proposed Solution
### Smart Contracts for Node Registration  
In the node-registration process, enhancing security and trust management is made possible by the use of blockchain technology at fog nodes in the fog layer of a CPS. However, implementing blockchain technology and maintaining a global trust list requires resourceful nodes that can be installed at the fog layer. Fog servers can create a safe and automated procedure for adding additional nodes to the CPS network by using smart contracts. In such a scenario, the registration procedure is governed by the smart contract, which serves as a predetermined set of guidelines and requirements. The smart contract receives information from the new node when it tries to join the network, including the node's identification and any associated metadata. The smart contract then verifies the supplied data using predefined criteria. When the validation is successful, the smart contract creates a blockchain transaction that includes the new node's identification and any pertinent information. Algorithm 4 represents the functional description of the smart contract module to execute a new transaction and update the blockchain-based revised global trust list (BRGTL). The time complexity of the algorithm is O(1), while the space complexity is O(n).  
There are a number of security advantages to node registration utilizing smart contracts. First, because the procedure is automated, there is less chance of human error. By confirming the legality of the joining nodes, the smart contract's validation procedure adds an extra degree of protection. Second, the blockchain's transparency enables other fog nodes of the same CPS network to audit and validate the registration process. In order to confirm that the registration procedure complies with the established norms and circumstances, they can independently review the transactions that have been recorded on the blockchain. Below is a step-by-step explanation of how smart contracts are implemented at the fog layer, and Figure 3 shows the same.  
1. Smart contract deployment: The fog server compiles the smart contract code and then deploys it to the blockchain.
2. Node registration request: A registration request is sent to the fog server by a new node when it wants to join the network. The request contains the data needed for the registration procedure, such as the node's identification and associated metadata.
3. Smart contract interaction: By calling functions or methods specified in the deployed smart contract's code, the fog server communicates with it.
4. Validation and verification: After receiving the registration request, the smart contract runs validation and verification tests. The node's identification is validated by the smart contract, which then confirms its veracity.
5. Updating the registration list: The smart contract updates the node registration list if the registration request is validated successfully. The updated registration information is included in a new transaction that the smart contract makes on the blockchain network.
6. Confirmation and event logging: When the smart contract successfully changes the registration list, it notifies the fog server by sending a confirmation response. The confirmation or event is recorded by the fog server.