## 4 Implementation and Evaluation
### Evaluation
#### 4.2.2 DID Generation and Verification Time Analysis  
Figure 9 shows the time taken to generate and validate a Verifiable Credential (VC) for different scenarios. It can be seen that, in our scheme, the time to generate a VC and the time to verify a VC are lower than those of BSN and BaiDu. The VC needs to be signed by the owner of the DID. Different VCs needs different information to be verified. When there is more information to be verified, the overall generation and verification process will take more time. In our scenario, the contents of the VC encompass the message, its corresponding message digest, a signature confirming the endorsement by the controller, details of the VC issuer, and the verification URL designated by the issuer specifically for this VC. At the same time, BIDU-DID and BSN-DID are relatively static, which means that whenever the data content or information needs to be changed a new DID needs to be applied for. However, the content of DID in our scheme is modifiable, which means that a single generation is reused many times, and this mechanism helps to improve the performance of DIDs. In our solution, both the generation of DIDs and the verification of a VC fall within an acceptable time-frame. At the same time, in different scenarios the generation of a DID will vary from the information contained in the verification. In some single-purpose verification scenarios, the overall time consumption can be further reduced.  
Every transaction within our blockchain is recorded, while the transmission of IoT data takes place through alternative channels. Through the blockchain, users possess the capability to inquire about the data holdings of others and initiate transactions with the respective data owners. Following the successful mining of transaction information onto the blockchain, data owners have the flexibility to choose an optimal method for data delivery.  
This entire transaction process, as delineated above, can be seamlessly executed by deploying smart contracts on the blockchain infrastructure. Algorithm 1 encapsulates part of the logic of a smart contract designed for transaction execution. Leveraging smart contracts significantly enhances the efficiency of transactions. In addition, automatic verification of  
Figure 9: Comparison of the VC generation and verification times of the BDIDA-IoT solution with the Baidu [27; 28] and BSN [29; 30] DID solutions. The abscissa represents the number of VCs and the ordinate represents the total time (ms) taken to complete generation or verification. (**a**) VC Generation Time shows the experimental results of VC generation time. (**b**) VC Verification Time shows the experimental results of VC verification time.  
data integrity injects a layer of trust and automation throughout the transaction process, which can simplify the process of trading.  
```
1:INPUT: VC (Verifiable Credential)
2:RESULT: Balance (Sender and Receiver)
3:Sender_balance \(\leftarrow\)Sender_balance \(-\)count
4:Receiver_balance \(\leftarrow\)Receiver_balance \(+\)count
5:ifVC.Signature.Verify\(()=\) true then
6:\(count\)\(\leftarrow\)VC.count
7:\(VC.State\)\(\leftarrow\) done
8: AddBalance()
9:else
10:return error.False(\"no permission\")
11:endif
```  
**Algorithm 1** Part of the logic of smart contracts