# Big Data Sharing Model and Key Mechanism of International Trade Based on Blockchain

Authors: Guohua Lian
Journal: International Transactions on Electrical Energy Systems
 (2022)

---

## Abstract

COVID-19 has made the world realize that the world is a whole, and international trade is the main way to connect countries. With the increase of international trade, the trade data has also become gradually huge. However, the current international trade data is still transmitted using the traditional Internet, which not only is inefficient, but also has poor security. Therefore, this paper aimed to use blockchain technology to explore the big data sharing model and key mechanism of international trade. This paper mainly introduced the design and implementation of a blockchain-based IoT data security sharing system. Firstly, the functional architecture of the prototype system was comprehensively introduced. According to the division of different functional modules, the data interaction design of different modules and the design of related smart contracts were expounded. According to the characteristics of international trade big data, the encryption and decryption algorithms are designed for the transmission of international trade big data. Finally, the prototype system was introduced from data acquisition, experimental environment deployment, system-related functional verification, and performance testing. The experimental test results showed that the encryption and decryption of transaction data by the data security sharing prototype system were more than 2 times faster than those of the traditional algorithm, and the transmission efficiency of the system at different nodes fluctuated within 10%, which showed that the system could perform security interactive sharing of data.


---

## Body

## 1. Introduction

The development of e-commerce in China relies on the construction of strong infrastructure such as information and communication and the rapid popularization of the Internet. With the increase in the amount of international trade, the current data analysis model is no longer suitable for such a huge amount of international trade data. Due to some of its own characteristics, such as the high connectivity of each node and the immutability of data, blockchain provides new solutions for distributed related fields. Therefore, it is necessary to study the big data sharing model and key mechanism of international trade based on blockchain.The data sharing model is an important part of realizing modernization. Many scholars have conducted research on the data sharing model. Shafagh et al. conducted research on the virtual currency problem in network trade, and they proposed a new access method for the data security problem in Bitcoin transmission [1]. Xia et al. proposed a blockchain-based data sharing framework that fully addressed the access control challenges associated with sensitive data stored in the cloud using the immutability and built-in autonomy properties of blockchains [2]. Xue et al. proposed a blockchain-based medical data sharing model, which had the advantages of decentralization, high security, collective maintenance, and tamper resistance [3]. Zhang and Lin proposed a blockchain-based secure and privacy-preserving PHI sharing (BSPP) scheme for diagnostic improvement in e-health systems [4]. Ma et al. studied a new multikeyword searchable encryption technology, which could improve the accuracy of retrieval results and propose a secure and trusted data sharing framework based on attribute encryption (ABE), searchable encryption, and blockchain [5]. However, their research on data sharing models only focused on the improvement of efficiency and did not consider the security of transmission.International trade services are an important component of global economic development, and many scholars have conducted research on international trade data. Yang et al. aimed to study international trade barriers and countermeasures of Chinese medicinal materials based on big data [6]. Li and Lv proposed a research on the development strategy of international trade in services (IST) based on BD [7]. Atyeh et al. proposed an Intuitive Fuzzy Goal Programming (IF_GP) algorithm based on goal programming and intuitionistic fuzzy numbers to promote consensus among decision makers, eliminate uncertainty, and better express the planner’s opinion [8]. Ruelle conducted research on container data in international trade. They collected the time of departure and return of containers and used container big data to analyze and predict the trade volume of international trade [9]. However, their study did not analyze trade data as a significant resource.In this paper, a blockchain encryption algorithm was proposed for international trade data. The blockchain technology was combined with the data sharing of the Internet of Things, and then the architecture layered design and smart contract architecture of the system were abstracted based on the actual scenarios and the above models. According to some characteristics of the blockchain, the data in this prototype system can be trusted, safe, open, transparent, and traceable, which will lay a solid foundation for the subsequent research on data security protection.


## 2. Blockchain Technology and International Trade

### 2.1. International Trade Big Data

The WTO has an important influence on the form and environment of international trade. Since China joined the WTO, the scale of China’s international trade has been greatly improved. Due to the lack of consensus among WTO members, most of the items on the WTO agenda have been abandoned, leaving only a small part. Among them, the hottest issue is digital trade. Therefore, in today’s international trade, the most important thing was international trade big data [10]. As shown in Figure 1, international trade big data includes logistics data, transaction information data, operational data, and financial data.Figure 1
International trade big data.


### 2.2. Blockchain Structure

A blockchain consists of different blocks. The blockchain can be viewed as a public ledger where all submitted transactions are stored in different blocks. This chain grows as new blocks are continually appended to it. The security of the data in the block was ensured through the elliptic encryption algorithm in asymmetric encryption, and the distributed consensus algorithm was used to synchronize the data of each “bookkeeper” in the ledger to ensure that the data of each “bookkeeper” was consistent [11], as shown in Figure 2.Figure 2
Main applications of blockchain in finance.To analyze the blockchain from the data structure, first of all, the block is one of the important elements of the blockchain. From the computer’s point of view, blocks are files. These files are composed of file names and file contents. Corresponding to the blocks, they are the block header and the block body, respectively. The information in the block header is used to identify different blocks. The block header includes the current blockchain version number, random number, and the root of the Merkle tree [12]. The block body stores the transaction information packaged by the block at that time and is stored in the block body in the time series of time stamps. The hash value of the previous block is stored in each block and then connected according to the time sequence of the generation of each block to form a blockchain. Each transaction in the block body is signed by the public and private keys of both parties. For accounts on the blockchain, they can query the information in any block.From the analysis of the technical composition of the blockchain, the blockchain is not generated by a new technology, but a new application composed of technologies that have existed before. These technologies include distributed p2p node communication technology, modern cryptography technology, distributed consensus algorithm, and smart contract technology that supports user-defined programming [13]. Under the constant collision of these different technologies, blockchain technology has emerged. And with the continuous research on the blockchain in the academic world, it has been trying to apply it to other fields according to its characteristics and has produced considerable repercussions, for example, in various financial services such as digital assets, remittances, and online payments [14]. Furthermore, it can be applied in other fields including smart contracts, public services, reputation systems, and security services [15].


### 2.3. Blockchain Data Encryption Algorithm

This article aims to optimize the data encryption algorithm based on blockchain technology in view of the insufficient security of traditional data transmission. Before performing the encryption operation, according to the characteristics of international trade big data,HKGCi to which DO belongs runs this initialization algorithm. In trade, it is important that some data cannot be published, so enter the security parameter k. For files or data that need to be encrypted, first use hash function H:0,1⟶GT to map string attributes to random elements of GT [16, 17]. Then, HKGCi randomly selects the parameters α1,β1,α2,β2∈Zp to generate the master private key of the corresponding encrypted file:(1)MK1=β1,gα1.Master public key:(2)PK1=G,g,h1=gβ1,eg,gα1.Secondary private key:(3)MK2=β2,gα2.Secondary public key:(4)PK2=G,g,h2=gβ2,eg,gα2.The text is added as follows: executed by the data owner DO, DO first encrypts the filef to be encrypted by AES and then encrypts its corresponding key m twice by Encrypt. The algorithm is divided into two parts:Computes1 nodes:(5)si1≤si≤p−1.Set the last child node value to(6)st=s1−∑i=1t−1simodp.Each leaf node ofTA is(7)aj,i∈TA.Calculate(8)cj,i=gtjsi.s2 for each leaf node(9)b∈j,iTID.Calculate(10)kj,i=gtn+jsi.i is the sequence number of the attribute in the tree.Generate ciphertext:Calculate separately(11)c1=gs1,c2=gs2,c˜=Meg,gα1s1eg,gα2s2.The final output ciphertext:(12)ct=T,c˜,c1,c2,∀αj,i∈TA:cj,i,∀tj,i∈TID:kj,i.The decryption algorithm is run locally by the data user DU. The algorithm firstly judges whether user attribute setAi and user identity bi satisfy TD, TID, respectively [18]. It will return if not satisfied; otherwise, select the minimum attribute subset Ai′ that satisfies TA to calculate(13)cΔ=c˜ec1,d1⋅∏αj∈U′ecj,i,dj,cΔ=Meg,gα2,s2.The plaintext is(14)M=cΔekj,i,dk=cΔegs2,gα2.


### 2.4. Algorithm Effect

In order to test the performance of the algorithm in this paper, the algorithm in this paper is compared with the traditional blockchain algorithm, that is, the algorithm before improvement, and the control scheme performance, encryption performance, and decryption performance of the algorithm are analyzed.In view of the performance of the control scheme of the algorithm, the algorithm in this paper is compared with the access control scheme of Ethereum and the access control scheme of Fabric, and the average time of processing 8000 transactions on the Internet of Things is tested, as shown in Table1. The algorithm in this paper takes an average of 250 ms, which is much lower than the Ethereum access and Fabric access. Because the algorithm in this paper has a DAG structure, the increase in the number of transactions will not slow down the computing efficiency, but with the increase of transaction users, the transmission efficiency will be faster. The algorithm in this paper removes the packaging link, and the algorithm time-consuming is further reduced.Table 1
Average processing time per transaction.
Number of transactions processedAverage time (ms)Algorithm in this paper8000250Ethereum access8000950Fabric access8000590In view of the efficiency of encryption and decryption when the algorithm processes files, the processing efficiency under different file sizes and the processing efficiency under different number of files are, respectively, carried out in this paper. As shown in Figure3(a), the algorithm in this paper has high efficiency when processing files of different sizes, and the time consumption is always about 1000 ms, while the traditional algorithm takes more time as the file becomes larger, and the processing file size is 4G, and the time-consuming of the algorithm in this paper is 4% of that of the traditional algorithm. As shown in Figure 3(b), the comparison of the decryption efficiency of the algorithm in this paper is similar to that of the encryption, which also shows that the algorithm in this paper has high operational efficiency when dealing with files of different sizes.Figure 3
Comparison of the efficiency of algorithms processing different numbers of files. (a) Comparison of time-consuming algorithm encryption for processing different numbers of files. (b) Time-consuming comparison of algorithm decryption for processing different numbers of files.
(a)(b)As shown in Figure4, this paper tests the computational efficiency of the two algorithms when processing 50, 100, …, 300 1G files, respectively. When encrypting and decrypting the algorithm in this paper and the traditional algorithm, the processing time increases with the increase of the number of files. However, the slope of the algorithm in this paper is obviously lower than that of the traditional algorithm. This shows that the algorithm in this paper has high computational efficiency when dealing with different numbers of files.Figure 4
Performance comparison of algorithms for processing different numbers of files. (a) Time consuming to process different number of files to encrypt. (b) Decryption consumes time to process different number of files.
(a)(b)Finally, this paper compares the overall functions of the two algorithms, as shown in Table2. It can be seen that the scheme in this paper adds a revocation mechanism for big data application scenarios, and this shows that the algorithm designed in this paper allows interception and revocation in data transmission, which greatly protects the security of data, which is more practical.Table 2
Algorithm practical comparison.
Algorithm in this paperTraditional algorithmRevocation mechanism10Secure channel11Apply blockcha11Centralized00


## 2.1. International Trade Big Data

The WTO has an important influence on the form and environment of international trade. Since China joined the WTO, the scale of China’s international trade has been greatly improved. Due to the lack of consensus among WTO members, most of the items on the WTO agenda have been abandoned, leaving only a small part. Among them, the hottest issue is digital trade. Therefore, in today’s international trade, the most important thing was international trade big data [10]. As shown in Figure 1, international trade big data includes logistics data, transaction information data, operational data, and financial data.Figure 1
International trade big data.


## 2.2. Blockchain Structure

A blockchain consists of different blocks. The blockchain can be viewed as a public ledger where all submitted transactions are stored in different blocks. This chain grows as new blocks are continually appended to it. The security of the data in the block was ensured through the elliptic encryption algorithm in asymmetric encryption, and the distributed consensus algorithm was used to synchronize the data of each “bookkeeper” in the ledger to ensure that the data of each “bookkeeper” was consistent [11], as shown in Figure 2.Figure 2
Main applications of blockchain in finance.To analyze the blockchain from the data structure, first of all, the block is one of the important elements of the blockchain. From the computer’s point of view, blocks are files. These files are composed of file names and file contents. Corresponding to the blocks, they are the block header and the block body, respectively. The information in the block header is used to identify different blocks. The block header includes the current blockchain version number, random number, and the root of the Merkle tree [12]. The block body stores the transaction information packaged by the block at that time and is stored in the block body in the time series of time stamps. The hash value of the previous block is stored in each block and then connected according to the time sequence of the generation of each block to form a blockchain. Each transaction in the block body is signed by the public and private keys of both parties. For accounts on the blockchain, they can query the information in any block.From the analysis of the technical composition of the blockchain, the blockchain is not generated by a new technology, but a new application composed of technologies that have existed before. These technologies include distributed p2p node communication technology, modern cryptography technology, distributed consensus algorithm, and smart contract technology that supports user-defined programming [13]. Under the constant collision of these different technologies, blockchain technology has emerged. And with the continuous research on the blockchain in the academic world, it has been trying to apply it to other fields according to its characteristics and has produced considerable repercussions, for example, in various financial services such as digital assets, remittances, and online payments [14]. Furthermore, it can be applied in other fields including smart contracts, public services, reputation systems, and security services [15].


## 2.3. Blockchain Data Encryption Algorithm

This article aims to optimize the data encryption algorithm based on blockchain technology in view of the insufficient security of traditional data transmission. Before performing the encryption operation, according to the characteristics of international trade big data,HKGCi to which DO belongs runs this initialization algorithm. In trade, it is important that some data cannot be published, so enter the security parameter k. For files or data that need to be encrypted, first use hash function H:0,1⟶GT to map string attributes to random elements of GT [16, 17]. Then, HKGCi randomly selects the parameters α1,β1,α2,β2∈Zp to generate the master private key of the corresponding encrypted file:(1)MK1=β1,gα1.Master public key:(2)PK1=G,g,h1=gβ1,eg,gα1.Secondary private key:(3)MK2=β2,gα2.Secondary public key:(4)PK2=G,g,h2=gβ2,eg,gα2.The text is added as follows: executed by the data owner DO, DO first encrypts the filef to be encrypted by AES and then encrypts its corresponding key m twice by Encrypt. The algorithm is divided into two parts:Computes1 nodes:(5)si1≤si≤p−1.Set the last child node value to(6)st=s1−∑i=1t−1simodp.Each leaf node ofTA is(7)aj,i∈TA.Calculate(8)cj,i=gtjsi.s2 for each leaf node(9)b∈j,iTID.Calculate(10)kj,i=gtn+jsi.i is the sequence number of the attribute in the tree.Generate ciphertext:Calculate separately(11)c1=gs1,c2=gs2,c˜=Meg,gα1s1eg,gα2s2.The final output ciphertext:(12)ct=T,c˜,c1,c2,∀αj,i∈TA:cj,i,∀tj,i∈TID:kj,i.The decryption algorithm is run locally by the data user DU. The algorithm firstly judges whether user attribute setAi and user identity bi satisfy TD, TID, respectively [18]. It will return if not satisfied; otherwise, select the minimum attribute subset Ai′ that satisfies TA to calculate(13)cΔ=c˜ec1,d1⋅∏αj∈U′ecj,i,dj,cΔ=Meg,gα2,s2.The plaintext is(14)M=cΔekj,i,dk=cΔegs2,gα2.


## 2.4. Algorithm Effect

In order to test the performance of the algorithm in this paper, the algorithm in this paper is compared with the traditional blockchain algorithm, that is, the algorithm before improvement, and the control scheme performance, encryption performance, and decryption performance of the algorithm are analyzed.In view of the performance of the control scheme of the algorithm, the algorithm in this paper is compared with the access control scheme of Ethereum and the access control scheme of Fabric, and the average time of processing 8000 transactions on the Internet of Things is tested, as shown in Table1. The algorithm in this paper takes an average of 250 ms, which is much lower than the Ethereum access and Fabric access. Because the algorithm in this paper has a DAG structure, the increase in the number of transactions will not slow down the computing efficiency, but with the increase of transaction users, the transmission efficiency will be faster. The algorithm in this paper removes the packaging link, and the algorithm time-consuming is further reduced.Table 1
Average processing time per transaction.
Number of transactions processedAverage time (ms)Algorithm in this paper8000250Ethereum access8000950Fabric access8000590In view of the efficiency of encryption and decryption when the algorithm processes files, the processing efficiency under different file sizes and the processing efficiency under different number of files are, respectively, carried out in this paper. As shown in Figure3(a), the algorithm in this paper has high efficiency when processing files of different sizes, and the time consumption is always about 1000 ms, while the traditional algorithm takes more time as the file becomes larger, and the processing file size is 4G, and the time-consuming of the algorithm in this paper is 4% of that of the traditional algorithm. As shown in Figure 3(b), the comparison of the decryption efficiency of the algorithm in this paper is similar to that of the encryption, which also shows that the algorithm in this paper has high operational efficiency when dealing with files of different sizes.Figure 3
Comparison of the efficiency of algorithms processing different numbers of files. (a) Comparison of time-consuming algorithm encryption for processing different numbers of files. (b) Time-consuming comparison of algorithm decryption for processing different numbers of files.
(a)(b)As shown in Figure4, this paper tests the computational efficiency of the two algorithms when processing 50, 100, …, 300 1G files, respectively. When encrypting and decrypting the algorithm in this paper and the traditional algorithm, the processing time increases with the increase of the number of files. However, the slope of the algorithm in this paper is obviously lower than that of the traditional algorithm. This shows that the algorithm in this paper has high computational efficiency when dealing with different numbers of files.Figure 4
Performance comparison of algorithms for processing different numbers of files. (a) Time consuming to process different number of files to encrypt. (b) Decryption consumes time to process different number of files.
(a)(b)Finally, this paper compares the overall functions of the two algorithms, as shown in Table2. It can be seen that the scheme in this paper adds a revocation mechanism for big data application scenarios, and this shows that the algorithm designed in this paper allows interception and revocation in data transmission, which greatly protects the security of data, which is more practical.Table 2
Algorithm practical comparison.
Algorithm in this paperTraditional algorithmRevocation mechanism10Secure channel11Apply blockcha11Centralized00


## 3. Big Data Sharing Model and Key Mechanisms

### 3.1. Data Security Issues in IoT Data Sharing

In the process of IoT data sharing, IoT data is threatened by different aspects at various stages of the data sharing process. At present, many kinds of IoT data are generated by users’ own daily activities, so these data inevitably contain some private information of users. If some data security threats are encountered in the process of data sharing, it is likely to crack down on users’ data sharing. The positivity of IoT reduces the flow of IoT data [19, 20]. These data security issues include the following: data is obtained by malicious hackers during the interaction process, resulting in data leakage, the authorization process between users is opaque, the user’s control over data is not high granularity, and scalability is not strong. During the sharing process, it may be tampered with, so the integrity of the data cannot be protected, and after the data transaction, the ownership of the data is not recognized and protected, resulting in disputes over the ownership of the data. As shown in Figure 5, in the eyes of data publishers or data requesters, the traditional IoT data sharing platform is a system similar to a “black box,” so users can only see the input and output of the current data sharing system, but the operation inside the platform is unclear. The shared data set may be sold privately by the service provider or tampered by the service provider. By handing over the data to a third-party service provider, users no longer have any control over the data and can only passively trust the service provider. Therefore, the centralized model has more data security problems.Figure 5
IoT data sharing model.Therefore, in view of some problems in the traditional data sharing model in Figure5, this paper proposed the following three methods to ensure data security in data sharing. (1) Before data sharing, it is necessary to ensure that the data cannot be stolen and deciphered by others, so a data encryption technology needs to be used to ensure the confidentiality of the data. (2) In the process of data sharing, according to the characteristics of IoT data, it is necessary to ensure that users have fine-grained and scalable data management and control, and the data authorization process is transparent and open, thus ensuring the credibility of data authorization, which also makes the data only accessible to authorized users. (3) After data sharing, it is necessary to provide a credible and nontamperable technology to verify the data integrity of IoT data during the sharing process.


### 3.2. Design of IoT Data Security Sharing Model Based on Blockchain

In the process of IoT data sharing, the main information flow is basically from data release to data encryption and decryption and access control to the final data reception. In traditional data sharing platforms, there are hidden dangers in the openness and security of these data. Therefore, in order to share various types of IoT data, it is necessary to build a credible, secure, transparent, and decentralized IoT data security sharing model to promote the flow of data, so as to achieve efficient integration of data resources and provide more security, a more trusted data sharing service [21].The model proposed in this paper is composed of data provider, data demander, web-based client, Ethereum-based data security sharing server, and IPFS data storage network. The data provider is responsible for abstracting the metadata from the owned dataset and publishing it to the blockchain network. The data demander has a demand for some data and looks for it in the blockchain network. The web-based client is a visual web client implemented by front-end technology. The data security sharing server based on Ethereum is a decentralized system with data sharing function developed by smart contracts. The IPFS data storage network is used to store encrypted data published to the shared system. Due to the storage limitations of the blockchain itself, this model uses IPFS with the blockchain to provide data storage services, as shown in Figure6.Figure 6
Blockchain-based IoT data security sharing model.In this model, the realization of IoT data sharing is divided into the following stages: (1) data release stage: the data set owned by the data owner can upload the data set through the data publishing function of the prototype system. The data set is divided into two parts, which are stored on-chain and off-chain, respectively. The metadata information of the dataset is stored on the chain, and the encrypted data of the dataset is stored off-chain by IPFS. (2) Data request stage: the data requester finds the required data in the system and initiates a data request to the data publisher. (3) Data sharing stage: after receiving the data request, if the data publisher agrees to data sharing, the data set will be shared through access control. (4) Data requester verification stage: after the data requester obtains the required data set, it can verify whether the data set has been tampered with through the data integrity verification service of the system.


### 3.3. Key Mechanism of Data Security Sharing Protection Based on Blockchain

#### 3.3.1. Data Confidentiality Protection Mechanism Based on Proxy Reencryption Technology

In the hierarchical design of the architecture in this paper, since the IoT data set occupies a large space, the data layer is divided into on-chain and off-chain storage when designing data storage. This storage method brings a problem. That is, the data may be stolen by some hackers with ulterior motives, so a data encryption method is needed for the data stored off-chain to encrypt the data, prevent data leakage, and avoid related economic problems for data sharing loss. Although data encryption can be achieved using symmetric encryption algorithms, in traditional data sharing scenarios, the data publisher needs to encrypt the data in each transaction when sharing. The data sharer uses a different key in each data sharing, so the data publisher needs to save a pair of corresponding keys according to each transaction. This situation is a burden on the data publisher and can lead to confusion in data key management in the long run. Therefore, this paper uses the key conversion mechanism of proxy reencryption to avoid generating a new key for each data sharing.In the system design of this paper, the proxy reencryption technology is mainly reflected in the two processes of data encryption and decryption in the entire IoT data sharing process. In the encryption phase of IoT data, the agent reencryption performs two encryptions. The first is for the data owner to encrypt, and the second is for the agent to reencrypt to convert the ciphertext. In the data decryption stage, the data requester only needs his own private key to complete the data decryption. This paper divides the role of proxy reencryption technology in the data sharing process. We mainly divide it into three roles. Among them, the proxy role is mainly to transform the ciphertext in each data sharing, so that the data requester does not need to know the data. The publisher’s private key can decrypt the data ciphertext.


#### 3.3.2. Blockchain-Based Capability Access Control Mechanism

When choosing an access control scheme, this paper chooses a capability-based access control method. The capability-based access control method is accomplished through a capability Token in the authorization process of both users. Users can customize the information in the capability, so as to achieve the dynamic and extensibility of rights management, and also between users. The authority can be delegated and revoked through the delegation mechanism to achieve free control of authority. Due to the high efficiency, scalability, and manageability of Token, it is often used in distributed resource rights management on the Internet of Things environment. The specific access control method is shown in Figure7.Figure 7
The overall flow chart of the capabilities of the blockchain.


## 3.1. Data Security Issues in IoT Data Sharing

In the process of IoT data sharing, IoT data is threatened by different aspects at various stages of the data sharing process. At present, many kinds of IoT data are generated by users’ own daily activities, so these data inevitably contain some private information of users. If some data security threats are encountered in the process of data sharing, it is likely to crack down on users’ data sharing. The positivity of IoT reduces the flow of IoT data [19, 20]. These data security issues include the following: data is obtained by malicious hackers during the interaction process, resulting in data leakage, the authorization process between users is opaque, the user’s control over data is not high granularity, and scalability is not strong. During the sharing process, it may be tampered with, so the integrity of the data cannot be protected, and after the data transaction, the ownership of the data is not recognized and protected, resulting in disputes over the ownership of the data. As shown in Figure 5, in the eyes of data publishers or data requesters, the traditional IoT data sharing platform is a system similar to a “black box,” so users can only see the input and output of the current data sharing system, but the operation inside the platform is unclear. The shared data set may be sold privately by the service provider or tampered by the service provider. By handing over the data to a third-party service provider, users no longer have any control over the data and can only passively trust the service provider. Therefore, the centralized model has more data security problems.Figure 5
IoT data sharing model.Therefore, in view of some problems in the traditional data sharing model in Figure5, this paper proposed the following three methods to ensure data security in data sharing. (1) Before data sharing, it is necessary to ensure that the data cannot be stolen and deciphered by others, so a data encryption technology needs to be used to ensure the confidentiality of the data. (2) In the process of data sharing, according to the characteristics of IoT data, it is necessary to ensure that users have fine-grained and scalable data management and control, and the data authorization process is transparent and open, thus ensuring the credibility of data authorization, which also makes the data only accessible to authorized users. (3) After data sharing, it is necessary to provide a credible and nontamperable technology to verify the data integrity of IoT data during the sharing process.


## 3.2. Design of IoT Data Security Sharing Model Based on Blockchain

In the process of IoT data sharing, the main information flow is basically from data release to data encryption and decryption and access control to the final data reception. In traditional data sharing platforms, there are hidden dangers in the openness and security of these data. Therefore, in order to share various types of IoT data, it is necessary to build a credible, secure, transparent, and decentralized IoT data security sharing model to promote the flow of data, so as to achieve efficient integration of data resources and provide more security, a more trusted data sharing service [21].The model proposed in this paper is composed of data provider, data demander, web-based client, Ethereum-based data security sharing server, and IPFS data storage network. The data provider is responsible for abstracting the metadata from the owned dataset and publishing it to the blockchain network. The data demander has a demand for some data and looks for it in the blockchain network. The web-based client is a visual web client implemented by front-end technology. The data security sharing server based on Ethereum is a decentralized system with data sharing function developed by smart contracts. The IPFS data storage network is used to store encrypted data published to the shared system. Due to the storage limitations of the blockchain itself, this model uses IPFS with the blockchain to provide data storage services, as shown in Figure6.Figure 6
Blockchain-based IoT data security sharing model.In this model, the realization of IoT data sharing is divided into the following stages: (1) data release stage: the data set owned by the data owner can upload the data set through the data publishing function of the prototype system. The data set is divided into two parts, which are stored on-chain and off-chain, respectively. The metadata information of the dataset is stored on the chain, and the encrypted data of the dataset is stored off-chain by IPFS. (2) Data request stage: the data requester finds the required data in the system and initiates a data request to the data publisher. (3) Data sharing stage: after receiving the data request, if the data publisher agrees to data sharing, the data set will be shared through access control. (4) Data requester verification stage: after the data requester obtains the required data set, it can verify whether the data set has been tampered with through the data integrity verification service of the system.


## 3.3. Key Mechanism of Data Security Sharing Protection Based on Blockchain

### 3.3.1. Data Confidentiality Protection Mechanism Based on Proxy Reencryption Technology

In the hierarchical design of the architecture in this paper, since the IoT data set occupies a large space, the data layer is divided into on-chain and off-chain storage when designing data storage. This storage method brings a problem. That is, the data may be stolen by some hackers with ulterior motives, so a data encryption method is needed for the data stored off-chain to encrypt the data, prevent data leakage, and avoid related economic problems for data sharing loss. Although data encryption can be achieved using symmetric encryption algorithms, in traditional data sharing scenarios, the data publisher needs to encrypt the data in each transaction when sharing. The data sharer uses a different key in each data sharing, so the data publisher needs to save a pair of corresponding keys according to each transaction. This situation is a burden on the data publisher and can lead to confusion in data key management in the long run. Therefore, this paper uses the key conversion mechanism of proxy reencryption to avoid generating a new key for each data sharing.In the system design of this paper, the proxy reencryption technology is mainly reflected in the two processes of data encryption and decryption in the entire IoT data sharing process. In the encryption phase of IoT data, the agent reencryption performs two encryptions. The first is for the data owner to encrypt, and the second is for the agent to reencrypt to convert the ciphertext. In the data decryption stage, the data requester only needs his own private key to complete the data decryption. This paper divides the role of proxy reencryption technology in the data sharing process. We mainly divide it into three roles. Among them, the proxy role is mainly to transform the ciphertext in each data sharing, so that the data requester does not need to know the data. The publisher’s private key can decrypt the data ciphertext.


### 3.3.2. Blockchain-Based Capability Access Control Mechanism

When choosing an access control scheme, this paper chooses a capability-based access control method. The capability-based access control method is accomplished through a capability Token in the authorization process of both users. Users can customize the information in the capability, so as to achieve the dynamic and extensibility of rights management, and also between users. The authority can be delegated and revoked through the delegation mechanism to achieve free control of authority. Due to the high efficiency, scalability, and manageability of Token, it is often used in distributed resource rights management on the Internet of Things environment. The specific access control method is shown in Figure7.Figure 7
The overall flow chart of the capabilities of the blockchain.


## 3.3.1. Data Confidentiality Protection Mechanism Based on Proxy Reencryption Technology

In the hierarchical design of the architecture in this paper, since the IoT data set occupies a large space, the data layer is divided into on-chain and off-chain storage when designing data storage. This storage method brings a problem. That is, the data may be stolen by some hackers with ulterior motives, so a data encryption method is needed for the data stored off-chain to encrypt the data, prevent data leakage, and avoid related economic problems for data sharing loss. Although data encryption can be achieved using symmetric encryption algorithms, in traditional data sharing scenarios, the data publisher needs to encrypt the data in each transaction when sharing. The data sharer uses a different key in each data sharing, so the data publisher needs to save a pair of corresponding keys according to each transaction. This situation is a burden on the data publisher and can lead to confusion in data key management in the long run. Therefore, this paper uses the key conversion mechanism of proxy reencryption to avoid generating a new key for each data sharing.In the system design of this paper, the proxy reencryption technology is mainly reflected in the two processes of data encryption and decryption in the entire IoT data sharing process. In the encryption phase of IoT data, the agent reencryption performs two encryptions. The first is for the data owner to encrypt, and the second is for the agent to reencrypt to convert the ciphertext. In the data decryption stage, the data requester only needs his own private key to complete the data decryption. This paper divides the role of proxy reencryption technology in the data sharing process. We mainly divide it into three roles. Among them, the proxy role is mainly to transform the ciphertext in each data sharing, so that the data requester does not need to know the data. The publisher’s private key can decrypt the data ciphertext.


## 3.3.2. Blockchain-Based Capability Access Control Mechanism

When choosing an access control scheme, this paper chooses a capability-based access control method. The capability-based access control method is accomplished through a capability Token in the authorization process of both users. Users can customize the information in the capability, so as to achieve the dynamic and extensibility of rights management, and also between users. The authority can be delegated and revoked through the delegation mechanism to achieve free control of authority. Due to the high efficiency, scalability, and manageability of Token, it is often used in distributed resource rights management on the Internet of Things environment. The specific access control method is shown in Figure7.Figure 7
The overall flow chart of the capabilities of the blockchain.


## 4. Design and Implementation of a Prototype System for Secure Sharing of International Trade Data Based on Blockchain

### 4.1. System Design

This paper will build a distributed trusted and secure data sharing prototype system based on the Ethereum blockchain prototype system combined with the data sharing process. The system can provide data sharing users with safe and credible sharing services and a complete audit system.The account management module is mainly responsible for providing users of this system with services such as user registration, information update, and query. The data sharing management module is mainly responsible for a series of management services for the shared data in this system, such as data release, request, encryption, and data integrity verification services. Rights management includes the control of data by users in this prototype system, especially the control of power transaction, power delegation, and revocation. Audit management mainly includes on-chain trusted storage of users, shared data, and authorization information and provides query functions for these information.In the user-side interface color matching and page control selection, the system uses Bootstrap and Html5 to select appropriate controls, so that users can interact with blockchain services in an easier way. The logic development behind the web page uses web3.js to interact with the Ethereum client and uses a high-performance web framework to provide elegant http services for front-end pages. In the blockchain, we choose the Ethereum platform with a relatively high maturity, and the smart contract language chooses the popular Solidity language for logic writing. In the data storage service, we use blockchain, interplanetary file system, and some common databases to store different data. The datasets in this prototype system are derived from various sensor data collected by SD-WSN.


### 4.2. System Module Design

The data sharing management module mainly includes a series of operations performed by users in the process of data sharing. For example, the sharing process is continuously refined into different subfunctions that cannot be further divided. The module is divided into roles, which are divided into data providers and data requesters. Data publishers publish their own information and metadata information to the blockchain through the data publishing method of data sharing management. Data requesters initiate data requests for published data on the shared system. According to the storage method of data, the source data is stored in the IPFS file system off-chain, while only basic user information and metadata are stored on the chain.(1)
Publish data function. In this function, what users need before publishing is to encrypt the data to be shared to prevent the plaintext of the data from being directly stolen.(2)
Request data function. This function is that when some users have a demand for data on the chain, they can call the data request method in the data sharing management contract. The premise of using this function is that the data required by the current user just appears in the data list on the chain. The requester can describe to the publisher its demand for the data or propose appropriate compensation to achieve the purpose of data interaction.(3)
Data transaction function. This function is completed by the mutual cooperation between the supply and demand sides of the user. Data transactions are interacted through a capability-based access control mechanism. After the data publisher agrees to the requester, it grants the capability token to it and then requests to obtain the source data through the access token.(4)
Proxy reencryption function. The proxy reencryption function is mainly reflected in data sharing. It is mainly responsible for providing data protection functions for IoT data in data sharing, which is divided into two stages: encryption and decryption.(5)
Data integrity verification function. This function is to verify the integrity of the data after the data requester completes the data sharing to check whether the shared data has been tampered with.


### 4.3. Smart Contract Design and Implementation of Core Modules

Figure8 is the operation flow chart of the system smart contract. From the perspective of the user interface to the bottom layer of the system, it is the front-end interface interaction, the Ethereum web3.js contract calling interface, the abi interface of the smart contract, the deployment of the smart contract, the compilation of the smart contract, and so on.Figure 8
Flow chart of smart contract operation.(1) According to the specific process design of each module in the prototype system, this paper uses the smart contract language to complete the logic writing. (2) The compiled smart contract cannot be directly understood by the computer, and a compiler needs to be used to compile it into binary bytecode. This system completes the compilation of the smart contract through the EthereumWallet Ethereum wallet. (3) The written smart contract is parsed into bytecode by the Ethereum virtual machine EVM. (4) After the smart contract is deployed, it will return a contract account address. In the front-end code, by configuring the contract address, this article generates the ABI of the contract through the web version of Remix. ABI is the binary interface expression of the smart contract. The Ethereum front-end script listens to the Ethereum client port through the binary interface of the smart contract to realize the interaction between the client and the blockchain.


### 4.4. Deployment and Testing of the Prototype System

This prototype system conducts IoT data security sharing experiments on five computers, including four 64-bit Windows 10 computers and one 64-bit Ubuntu cloud server in the laboratory. The data collection part uses 10 Crossbow wireless sensor nodes for field data collection. The specific computer configuration information is shown in Table3.Table 3
System environment configuration.
System typeWindows 10Ubuntu 6Memory16G2GGo-ethereum versionGeth/v 1.8Geth/v 1.8IPFS versionIPFS/0.9.8IPFS/0.9.8The experimental environment deployment of this prototype system is mainly composed of three parts: data acquisition environment, server component assembly, and Web-based client construction, as shown in Figure9.Figure 9
The actual deployment diagram of the prototype system.The function verification of the prototype system is to verify the security sharing function of the IoT data of the prototype system. In this experiment, different nodes play different roles to complete. For example, one of the experimental nodes simulates the data owner and simulates data release, and the other experimental node simulates the data requester to complete the data request simulation. Through the data interaction between the two nodes in the blockchain system, the security sharing function verification of the entire prototype system is completed.This paper mainly conducted experiments on the mining speed of the blockchain nodes in this prototype system and the number of transactions per unit time between different nodes. In order to test whether the change in the number of nodes in the private blockchain cluster will affect the transaction packaging speed in the system, this test uses a virtual machine environment and builds 20 blockchain nodes for implementation. 5, 10, 15, and 20 nodes are controlled, respectively, to network for 60 minutes to conduct experimental simulations. Every 10 minutes, the number of transactions is counted. The comparison experiment results are shown in Figure10.Figure 10
Number of transactions per unit time of different nodes.As shown in Figure10, at the same time, the speed of mining new blocks by different numbers of nodes is basically the same, and the number of transactions is not affected by the change in the number of nodes in the blockchain network. Therefore, the experimental data showed that the increase in the number of blockchain nodes has little effect on the transaction packaging speed in this prototype system.


## 4.1. System Design

This paper will build a distributed trusted and secure data sharing prototype system based on the Ethereum blockchain prototype system combined with the data sharing process. The system can provide data sharing users with safe and credible sharing services and a complete audit system.The account management module is mainly responsible for providing users of this system with services such as user registration, information update, and query. The data sharing management module is mainly responsible for a series of management services for the shared data in this system, such as data release, request, encryption, and data integrity verification services. Rights management includes the control of data by users in this prototype system, especially the control of power transaction, power delegation, and revocation. Audit management mainly includes on-chain trusted storage of users, shared data, and authorization information and provides query functions for these information.In the user-side interface color matching and page control selection, the system uses Bootstrap and Html5 to select appropriate controls, so that users can interact with blockchain services in an easier way. The logic development behind the web page uses web3.js to interact with the Ethereum client and uses a high-performance web framework to provide elegant http services for front-end pages. In the blockchain, we choose the Ethereum platform with a relatively high maturity, and the smart contract language chooses the popular Solidity language for logic writing. In the data storage service, we use blockchain, interplanetary file system, and some common databases to store different data. The datasets in this prototype system are derived from various sensor data collected by SD-WSN.


## 4.2. System Module Design

The data sharing management module mainly includes a series of operations performed by users in the process of data sharing. For example, the sharing process is continuously refined into different subfunctions that cannot be further divided. The module is divided into roles, which are divided into data providers and data requesters. Data publishers publish their own information and metadata information to the blockchain through the data publishing method of data sharing management. Data requesters initiate data requests for published data on the shared system. According to the storage method of data, the source data is stored in the IPFS file system off-chain, while only basic user information and metadata are stored on the chain.(1)
Publish data function. In this function, what users need before publishing is to encrypt the data to be shared to prevent the plaintext of the data from being directly stolen.(2)
Request data function. This function is that when some users have a demand for data on the chain, they can call the data request method in the data sharing management contract. The premise of using this function is that the data required by the current user just appears in the data list on the chain. The requester can describe to the publisher its demand for the data or propose appropriate compensation to achieve the purpose of data interaction.(3)
Data transaction function. This function is completed by the mutual cooperation between the supply and demand sides of the user. Data transactions are interacted through a capability-based access control mechanism. After the data publisher agrees to the requester, it grants the capability token to it and then requests to obtain the source data through the access token.(4)
Proxy reencryption function. The proxy reencryption function is mainly reflected in data sharing. It is mainly responsible for providing data protection functions for IoT data in data sharing, which is divided into two stages: encryption and decryption.(5)
Data integrity verification function. This function is to verify the integrity of the data after the data requester completes the data sharing to check whether the shared data has been tampered with.


## 4.3. Smart Contract Design and Implementation of Core Modules

Figure8 is the operation flow chart of the system smart contract. From the perspective of the user interface to the bottom layer of the system, it is the front-end interface interaction, the Ethereum web3.js contract calling interface, the abi interface of the smart contract, the deployment of the smart contract, the compilation of the smart contract, and so on.Figure 8
Flow chart of smart contract operation.(1) According to the specific process design of each module in the prototype system, this paper uses the smart contract language to complete the logic writing. (2) The compiled smart contract cannot be directly understood by the computer, and a compiler needs to be used to compile it into binary bytecode. This system completes the compilation of the smart contract through the EthereumWallet Ethereum wallet. (3) The written smart contract is parsed into bytecode by the Ethereum virtual machine EVM. (4) After the smart contract is deployed, it will return a contract account address. In the front-end code, by configuring the contract address, this article generates the ABI of the contract through the web version of Remix. ABI is the binary interface expression of the smart contract. The Ethereum front-end script listens to the Ethereum client port through the binary interface of the smart contract to realize the interaction between the client and the blockchain.


## 4.4. Deployment and Testing of the Prototype System

This prototype system conducts IoT data security sharing experiments on five computers, including four 64-bit Windows 10 computers and one 64-bit Ubuntu cloud server in the laboratory. The data collection part uses 10 Crossbow wireless sensor nodes for field data collection. The specific computer configuration information is shown in Table3.Table 3
System environment configuration.
System typeWindows 10Ubuntu 6Memory16G2GGo-ethereum versionGeth/v 1.8Geth/v 1.8IPFS versionIPFS/0.9.8IPFS/0.9.8The experimental environment deployment of this prototype system is mainly composed of three parts: data acquisition environment, server component assembly, and Web-based client construction, as shown in Figure9.Figure 9
The actual deployment diagram of the prototype system.The function verification of the prototype system is to verify the security sharing function of the IoT data of the prototype system. In this experiment, different nodes play different roles to complete. For example, one of the experimental nodes simulates the data owner and simulates data release, and the other experimental node simulates the data requester to complete the data request simulation. Through the data interaction between the two nodes in the blockchain system, the security sharing function verification of the entire prototype system is completed.This paper mainly conducted experiments on the mining speed of the blockchain nodes in this prototype system and the number of transactions per unit time between different nodes. In order to test whether the change in the number of nodes in the private blockchain cluster will affect the transaction packaging speed in the system, this test uses a virtual machine environment and builds 20 blockchain nodes for implementation. 5, 10, 15, and 20 nodes are controlled, respectively, to network for 60 minutes to conduct experimental simulations. Every 10 minutes, the number of transactions is counted. The comparison experiment results are shown in Figure10.Figure 10
Number of transactions per unit time of different nodes.As shown in Figure10, at the same time, the speed of mining new blocks by different numbers of nodes is basically the same, and the number of transactions is not affected by the change in the number of nodes in the blockchain network. Therefore, the experimental data showed that the increase in the number of blockchain nodes has little effect on the transaction packaging speed in this prototype system.


## 5. Conclusions

This paper conducted in-depth research and analysis on the data security problems existing in the process of IoT data sharing. Aiming at the centralized architecture of traditional IoT data sharing, a blockchain-based IoT data security sharing model was proposed. The model conducted a research on the architecture layering and proposed a distributed data storage model. Then, in view of the weak data security protection capability in traditional IoT data sharing, a key mechanism related to the security sharing and protection of IoT data based on blockchain was proposed. Finally, according to the above theory, a prototype system of IoT data security sharing based on blockchain was built, and relevant functional verification was completed. Based on the blockchain, this paper studied the security sharing of IoT data. Although some achievements have been achieved, there are still some problems that need further research, mainly including the following: (1) in terms of data protection, higher security of off-chain data storage can be improved by combining proxy reencryption technology with other encryption algorithms. (2) At the level of the blockchain itself, a consensus mechanism that is more in line with secure sharing can be studied to strengthen the security of data in this prototype system.



---

*Source: 9621750-2022-09-08.xml*