Data transaction method and apparatus, electronic device, and storage medium
By establishing communication connections between sensors and designated containers and creating a trusted execution environment, the system addresses data privacy leaks and security threats during smart contract execution on the blockchain, enabling secure and efficient data transactions while ensuring data integrity and privacy.
Patent Information
- Application Number
- CN202110806075.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-16
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2041-07-16
AI Technical Summary
When executing smart contracts on the blockchain, there are issues of data privacy breaches and security threats, especially when nodes are attacked, data security is reduced.
The system acquires and verifies the status of data transactions through communication between sensors and designated containers. It uses hash values and random values to confirm data integrity, completes the transaction signing, and adds the data and transaction information to the blockchain. It uses a trusted execution environment such as Intel SGX's Enclave container for data storage, combines IPFS for long-term storage, and controls access permissions to ensure data security.
It enables data transactions in a trusted environment, avoids duplicate data transactions, improves the security and feasibility of data transactions, and ensures the integrity and privacy of data.
Smart Images

Figure CN115617766B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet of Things (IoT) technology, and in particular to a data transaction method, apparatus, electronic device, and storage medium. Background Technology
[0002] Among related technologies, executing smart contracts on the blockchain may lead to the leakage of data privacy, and during the execution of smart contracts, when the node responsible for processing data is attacked, there is a great threat to data security. Summary of the Invention
[0003] In view of this, embodiments of this application provide a data transaction method, apparatus, electronic device, and storage medium based on blockchain, so as to at least solve the problems of reduced data security and leakage of data privacy that have emerged in related technologies.
[0004] The technical solution of this application embodiment is implemented as follows:
[0005] This application provides a data transaction method, the method comprising:
[0006] Obtain a first request; the first request is used to request the implementation of a first transaction; the first transaction represents the transaction of first data collected by a first sensor;
[0007] Based on the first connection, the first data is acquired; the first connection represents the communication connection established between the container and the first sensor.
[0008] Within the defined container, the transaction status of the first data is determined;
[0009] If the transaction status of the first data is not traded, the signing of the first transaction is completed, and based on the first connection, the first data and the first transaction information are added to the blockchain.
[0010] In the above scheme, the method for obtaining the first request further includes:
[0011] Obtain device information from the first sensor;
[0012] Based on the device information of the first sensor, if the first sensor is a verified sensor, the first request is obtained.
[0013] In the above scheme, determining the transaction status of the first data includes:
[0014] Determine the first hash value of the first data;
[0015] If the first hash value of the first data exists in the set hash list, the transaction status of the first data is determined to be "transactional".
[0016] If the first hash value of the first data does not exist in the set hash list, the transaction status of the first data is determined to be untransactioned.
[0017] In the above scheme, completing the signing of the first transaction when the transaction status of the first data is untransactional includes:
[0018] Obtain a first verification package of the first data; the first verification package includes the data index of the first data, a second hash value, and a first random value; the second hash value is obtained by the buyer user in the first transaction based on the data index of the first data and the first random value;
[0019] The third hash value is determined based on the data index and the first random value of the first data in the first verification package;
[0020] If the second hash value is the same as the third hash value, the signing of the first transaction is completed.
[0021] In the above scheme, when the first hash value of the first data does not exist in the set hash list, the method further includes:
[0022] Add the first hash value of the first data to the set hash list.
[0023] In the above scheme, after adding the first data and the first transaction information to the blockchain, the method further includes:
[0024] Upload the first data to the designated file sharing system.
[0025] The method in the above scheme further includes:
[0026] Upon receiving a second request, access permissions are determined based on the first transaction information; the second request indicates that a second sensor or data agent node requests access to second data stored in the designated file-sharing system; the access permissions indicate the permission to access the second data.
[0027] If the access permission indicates that access to the second data is permitted, the second data stored in the set file-sharing system is returned based on the first hash value of the second data.
[0028] This application also provides a data transaction device, including:
[0029] The first acquisition unit is configured to acquire a first request; the first request is used to request the implementation of a first transaction; the first transaction represents the transaction of first data collected by a first sensor.
[0030] The second acquisition unit is used to acquire the first data; the first connection represents the communication connection established between the container and the first sensor.
[0031] The first determining unit is used to determine the transaction status of the first data in the set container;
[0032] The first transaction unit is used to complete the signing of the first transaction when the transaction status of the first data is not traded, and to add the first data and the first transaction information to the blockchain based on the first connection.
[0033] This application also provides an electronic device, a processor, and a memory for storing computer programs that can run on the processor.
[0034] When the processor runs the computer program, it executes the steps of any of the above methods.
[0035] This application also provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of any of the above methods.
[0036] In this embodiment of the invention, the data to be traded is transmitted to the designated container through a communication connection between the sensor and the designated container, and the data transaction is carried out within the designated container. This enables data transactions to be conducted in a trusted environment, ensuring data security. Furthermore, during the data transaction process, the data to be traded is further confirmed, thereby avoiding duplicate data transactions and improving the feasibility of data transactions. Attached Figure Description
[0037] Figure 1 A schematic diagram illustrating the implementation flow of a data transaction method provided in an embodiment of this application;
[0038] Figure 2 A schematic diagram illustrating the implementation flow of a data transaction method provided in yet another embodiment of this application;
[0039] Figure 3 A schematic diagram illustrating the implementation flow of a data transaction method provided in another embodiment of this application;
[0040] Figure 4 A schematic diagram illustrating the implementation flow of a data transaction method provided in yet another embodiment of this application;
[0041] Figure 5The process of generating a first verification package provided in an embodiment of this application;
[0042] Figure 6 A schematic diagram of a data transaction process provided in an embodiment of this application;
[0043] Figure 7 A schematic diagram illustrating the implementation flow of a data transaction method provided in an embodiment of this application;
[0044] Figure 8 This is a schematic diagram of a data transaction architecture provided in an application embodiment of this application;
[0045] Figure 9 This is a schematic diagram of the structure of a data transaction device provided in an embodiment of this application;
[0046] Figure 10 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0047] The present application will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0048] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0049] It should be noted that the technical solutions described in the embodiments of this application can be combined arbitrarily without conflict.
[0050] In addition, in the embodiments of this application, "first," "second," etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0051] Before providing a detailed description of the technical solutions in the embodiments of this application, a brief explanation of data transaction methods in related technologies will be given first.
[0052] In IoT data sharing systems, data messages signed by IoT sensors are packaged into data blocks and distributed to the blockchain network. The identity-based aggregated signature data block structure protects data reliability from malicious aggregation nodes and reduces the communication, storage, and computation costs of signing. However, the increasing traffic load and simultaneous data access by IoT nodes in these systems place a burden on centralized networks, posing serious challenges to traditional centralized management and storage networks. Even data storage in cloud environments faces security issues such as untrusted cloud providers or privacy breaches within server clusters. Furthermore, the public nature of smart contracts means that executing them on the blockchain carries the risk of data privacy leaks. Untrusted IoT aggregation nodes also pose a risk of cheating. Moreover, the original data packaging and signing process relies on trusted electronic certification (CA) services, which are not always entirely trustworthy. Additionally, the lack of proper oversight of the bureaus and nodes responsible for processing sensor-uploaded data makes them highly vulnerable to malicious nodes, posing a significant threat to data security.
[0053] Based on this, in this embodiment of the application, a trustworthy transaction environment is provided for data transactions, and access permissions to transaction data are controlled accordingly to ensure the security of data during the transaction process.
[0054] The present application will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0055] This application provides a data transaction method. Figure 1 This is a schematic flowchart of a data transaction method according to an embodiment of this application. Figure 1 As shown, the method includes:
[0056] S101: Obtain a first request; the first request is used to request the implementation of a first transaction; the first transaction represents the transaction of the first data collected by the first sensor.
[0057] Here, in the data trading environment, the data being traded is data collected by sensors. When a first sensor needs to trade its collected data, it contacts a nearby data broker node through a first request to conduct the transaction. The data broker node is responsible for handling data purchase and sales requests. The data broker node receives the first sensor's request and initiates the subsequent data trading process. In practical applications, all data broker nodes share the same distributed ledger, thus achieving transparency in data transactions.
[0058] In one embodiment, such as Figure 2As shown, the method for obtaining the first request further includes:
[0059] S201: Obtain device information of the first sensor.
[0060] Here, the device information of the first sensor is obtained. This device information may include different identity verifications such as the first sensor's device certificate. In practical applications, the configuration container can register different first sensors. After the configuration container is invoked and executed, the first sensor provides detailed device information to the configuration container. The configuration container packages and signs the device information provided by the first sensor and provides the first sensor with a digital certificate, a pseudo-ID, and a public-private key pair. The pseudo-ID enables anonymous communication for the first sensor, while the digital certificate is used for authentication. The public-private key pair can be generated using an elliptic curve digital signature algorithm. In practical applications, when the data proxy node receives the first request from the first sensor, it requests confirmation from the configuration container whether the first sensor is a verified sensor, thereby ensuring secure transactions between the data proxy node and the first sensor.
[0061] S202: Based on the device information of the first sensor, if the first sensor is a verified sensor, obtain the first request.
[0062] Here, the data proxy node can determine from the setting container whether the first sensor is a verified sensor based on the device information of the first sensor. If the first sensor is a verified sensor, it means that the first sensor has been registered in the setting container and is a trustworthy sensor. In other words, it will not pose a security threat to data transactions. Therefore, the first request can be obtained and subsequent transaction processes can be carried out with the first sensor.
[0063] S102: Based on the first connection, acquire the first data; the first connection represents the communication connection established between the setting container and the first sensor.
[0064] Here, the first sensor that issues the first request establishes a first connection with the configurable container. Data transmission between the first sensor and the configurable container is achieved through the first connection. The configurable container obtains the first data through the first connection and stores the first data in the configurable container. The configurable container can provide a reliable and secure environment for data transactions. In practical applications, the configurable container can be the Encalve container in the Trusted Execution Environment (TEX). Intel SGX is an instruction set extension based on the Intel architecture. It can provide a trusted execution environment in a secure state without relying on firmware and software, and run between different programs to ensure that the confidentiality and integrity of critical data are not compromised. Encalve is a protected content container used to store sensitive data. The trusted execution environment can ensure that the data in the Encalve container cannot be accessed by other nodes. Therefore, Encalve is responsible for processing data and executing contracts, thereby ensuring the security of data and transactions.
[0065] S103: In the set container, determine the transaction status of the first data.
[0066] Here, the first data to be traded is processed in the set container to determine the transaction status of the first data. The transaction status of the first data can reflect whether the first data has been traded, thereby avoiding the trading of duplicate data.
[0067] In one embodiment, such as Figure 3 As shown, determining the transaction status of the first data includes:
[0068] S301: Determine the first hash value of the first data.
[0069] Here, a hash value is a set of binary values obtained by encrypting data using a certain hash algorithm. For a set of data, the corresponding hash value is unique. Once the data changes, the corresponding hash value will also change. Therefore, hash values can be used for verification. In practical applications, hash values are often used to determine whether two pieces of data are the same. If the first piece of data has been traded, the data proxy node will have a corresponding record. Therefore, by determining the first hash value of the first piece of data and matching it with the data that has completed the transaction, the transaction data of the first piece of data can be determined. In practical applications, the first hash value of the first piece of data can be calculated using digital signature algorithms such as MD5 or SHA-1.
[0070] S302: If the first hash value of the first data exists in the set hash list, determine that the transaction status of the first data is "transaction completed".
[0071] Here, a hash list is set up to record the hash values corresponding to data that has been transacted. When the first hash value of the first piece of data exists in the hash list, it indicates that the first piece of data has been transacted, and the corresponding transaction status of the first piece of data is "transacted". In practical applications, when it is determined that the transaction status of the first piece of data is "transacted", the container can directly reject the first transaction, thereby avoiding duplicate transactions of data.
[0072] S303: If the first hash value of the first data does not exist in the set hash list, determine that the transaction status of the first data is not traded.
[0073] Here, if the first hash value of the first data does not exist in the set hash list, it means that the first hash value of the first data is different from the corresponding hash value of the data that has been traded. Therefore, it can be determined that the current first data is new data, has not been traded, and its transaction status is "untraded". In practical applications, when determining whether the first hash value of the first data exists in the set hash list, a Bloom filter can be used to filter the set hash list, thereby quickly determining whether the first hash value exists in the set hash list.
[0074] S104: If the transaction status of the first data is not traded, complete the signing of the first transaction and add the first data and the first transaction information to the blockchain based on the first connection.
[0075] Here, when the transaction status of the first data is "transacted," it means that the first data has already been traded by other IoT sensors. In other words, the first data has no potential or value for trading, therefore, no further trading is needed. When the transaction status of the first data is "not traded," it means that the first data is new data, possessing the potential and value for trading, and the signing of the first transaction is completed within the designated container. In practical applications, the trading of the first data is conducted through smart contracts. When a transaction is needed, a first transaction must be signed. In practice, after the first transaction is signed, payment can be made according to the content of the signed transaction. After the first transaction is signed, the first data is added to the blockchain for storage to indicate retrieval of the first data. In practical applications, the first transaction information can also be added to the blockchain, allowing the transaction status of the first data to be determined based on the first transaction information.
[0076] In one embodiment, when the first hash value of the first data does not exist in the defined hash list, the method further includes:
[0077] Add the first hash value of the first data to the set hash list.
[0078] Here, since the first hash value of the first data does not exist in the set hash list, after the first data is traded, the transaction status of the first data will change to "traded". Therefore, it is necessary to update the set hash list and add the first hash value of the first data to the set hash list, so as to maintain the accuracy of the set hash list and accurately identify the transaction status of the data to be traded.
[0079] In one embodiment, such as Figure 4 As shown, completing the signing of the first transaction when the transaction status of the first data is "untransactional" includes:
[0080] S401: Obtain the first verification package of the first data; the first verification package includes the data index of the first data, the second hash value, and the first random value; the second hash value is obtained by the buyer user in the first transaction based on the data index of the first data and the first random value.
[0081] Here, during the transaction of the first data, it is also necessary to prove the integrity and authenticity of the first data. The buyer in the first transaction first extracts a portion of the first data. The data index of the first data indicates the position of the selected portion within the first data. In practice, the data index can be represented by coordinates, indicating the start and end positions of the selected data. A first random value is used to perform a hash calculation on the selected portion of the first data to obtain a second hash value. The first random value is an arbitrary or non-repeating random value used only once. In practice, the calculation of the second hash value requires multiple calculations using different first random values until a hash value conforming to a specific pattern is obtained. The hash value conforming to the specific pattern is then output as the second hash value. The hash value of the specific pattern can be a hash value less than a set threshold. The buyer packages the first random value, the second hash value, and the data index of the first data to generate a first verification packet and sends it to a designated container. The designated container receives the first verification packet through a first connection. Figure 5 As shown, Figure 5 The process of generating the first verification package is shown.
[0082] S402: Determine the third hash value based on the data index of the first data in the first verification packet and the first random value.
[0083] Here, after receiving the first verification packet, the container extracts the data index of the first data in the first verification packet, finds the data corresponding to the data index of the first data in the first data, and performs a hash calculation on the data corresponding to the data index of the first data and the first random value to generate a third hash value.
[0084] S403: If the second hash value is the same as the third hash value, the signing of the first transaction is completed.
[0085] Here, since the second and third hash values are calculated based on the same data content and the same random value, they can be used to determine whether the first data is complete and authentic. When the second and third hash values are the same, it means the data obtained by the buyer is identical to the first data in the designated container, indicating that the first data is complete and authentic, and thus the transaction can proceed, completing the first transaction agreement. When the second and third hash values are different, it means the data obtained by the buyer is different from the first data in the designated container, meaning the first data may be fraudulent, and therefore the first transaction will not proceed. In practical applications, the buyer performs unilateral verification by comparing the second hash value with the first hash value to determine whether the first data is the data the buyer needs, ensuring fairness for both parties during the transaction of the first data.
[0086] In one embodiment, after adding the first data and the first transaction information to the blockchain, the method further includes:
[0087] Upload the first data to the designated file sharing system.
[0088] Here, after the initial data transaction is completed, the first transaction data is uploaded to a designated file-sharing system. This system can be the InterPlanetary File System (IPFS), a peer-to-peer, content-addressable distributed file storage system that solves the problem of large files not being able to be stored on a blockchain. It effectively stores and shares large files, and data stored in IPFS can be used by all nodes in the IPFS network. Storing the first data in IPFS ensures its long-term availability. In practical applications, the second data in the designated file-sharing system can be used by businesses interested in purchasing the data. For example... Figure 6 As shown, Figure 6The diagram illustrates the data transaction process. First, a first request is received from the first sensor, which then acquires the first data to be traded. It is determined whether the first sensor is verified. If the first sensor is unverified, the first request is rejected. If the first sensor is verified, it is further determined whether the first data is duplicated. If the first data is duplicated, the first request is rejected. If the first data is unique, the integrity of the first data is verified, a corresponding block is created for the first transaction, payment is made and delivered according to the first transaction contract, and the first data is stored in IPFS.
[0089] In one embodiment, such as Figure 7 As shown, the method further includes:
[0090] S701: Upon receiving a second request, determine access permissions based on the first transaction information; the second request represents a request from a second sensor or data agent node to access second data stored in the set file-sharing system; the access permissions represent the permission to access the second data.
[0091] Here, since the established file-sharing system allows all nodes in the network to access the data stored within it, to further ensure the security of the second data stored in the system, it is necessary to restrict the access permissions of the second sensor or data proxy node that initiates the access request. Access permissions can be determined through the first transaction information. In practical applications, the first sensor establishes a first connection with the designated container via wired or wireless means, and sends the encrypted first data to the data proxy node. The data proxy node, connected to the established file-sharing system, stores all the first data information in the blockchain, including the signature and the hash value of the first data. After the data proxy node enters into a transaction contract with the first sensor regarding the first data, it gains access to read the first data. Since the corresponding access permissions are reflected through the first transaction information, uploading, downloading, or transferring files in the established file-sharing system requires interaction with the corresponding first transaction information. For example, when uploading files in a designated file-sharing system, the sensor first registers with the designated container as a provider of file blocks. The designated hash list contains information about how to connect to the sensor using specific identifiers, such as by providing an IP address. Therefore, the designated file-sharing system can request the sensor by setting the hash list and then connect to the sensor to retrieve the file. Because the designated file-sharing system uses content identifiers to identify, verify, and transmit blocks and files, it is particularly suitable for use in blockchains. In fact, a single transaction can send the root hash value of the file's Merkle tree to a blockchain block. However, to more easily distinguish between the designated file-sharing system and a blockchain block, no information other than the hash value is needed when retrieving a file from the designated file-sharing system. In practical applications, the definition of a smart contract for implementing access control is as follows:
[0092] The FileData structure defined in the smart contract contains an address type variable named owner, a mapping named access, and a dynamic array of address type variables named allowedaddress. The contract contains a mapping from 32-byte type variables to instances of the FileData structure, called a memory mapping. Many functions have a corresponding version, appended with "Multiple" to the function name. The "Multiple" functions use an array and call the corresponding single version multiple times. All functions can be called externally by the data broker node. Each function can pass input data as an argument from the user. It is validated by the function using an if statement. If the check condition resolves to false, the revert function is called. Revert rolls the smart contract back to its previously held state. Functions that do not change the state of the public blockchain platform can be declared as constants. Constant functions do not require paid transactions to execute because they are similar to simply reading data and do not modify the smart contract storage. Such functions reduce the workload required by nodes because they can be called locally instead of broadcasting transactions to be included in a block. grantAccess: Accepts an address and a 32-byte variable representing the block hash as arguments. Returns if the address is empty (value 0x0) or the hash is empty. Otherwise, it uses the hash value parameter as the key to retrieve the relevant data from storage by accessing the memory map. The sender matches the owner recorded in the FileData instance accessed through the file map. If there is no match, the revert function is called. If there is a match, the access map will add the address parameter as the key and set the corresponding boolean value to true. Finally, the address parameter is added to the allowedaddress array and stored in the smart contract's storage. removeAccess: This function operates in the same way as the grantAccess function, the only difference being that it sets the boolean value in the memory map to false. checkAccess: Accepts an address and a 32-byte value representing the block hash as parameters. Returns false if either of these values is empty. Returns true if the address parameter matches the owner. Returns true if the address has previously been granted access. Returns false if the address is not allowed access. deleteBlock: Accepts a 32-byte value as a parameter. Returns if the hash value is empty or msg. The sender is not the owner of the block identified by the hash value. If the check passes, it will iterate through the allowedaddress array and set all boolean values to false. In the second step, it allocates a new empty Filedata instance for the data in the memory map of the given hash value. In effect, all access permissions and ownership are removed.This file can no longer be requested by any user. As per IPFS requirements, the actual deletion of data is left to the individual nodes.
[0093] S702: If the access permission characterization allows access to the second data, return the second data stored in the set file sharing system according to the first hash value of the second data.
[0094] Here, when the access permission characterization allows access to the second data, it means that the sensor or data agent node that initiated the data access request has the permission to access the second data. By using the first hash value of the accessed second data, the corresponding second data is found in the set file-sharing system, and the second data is returned to the sensor or data agent node that initiated the data access request. In this way, by restricting data access permissions, the security of the data in the set file-sharing system can be further ensured, and data leakage can be avoided.
[0095] In the above embodiments, during the data transaction process, data transmission is achieved through a secure connection between the sensor and the container. The container can encrypt the data during transmission, thereby ensuring data security. In addition, the status of the data to be traded can be verified to avoid duplicate transactions, thus enabling effective and secure data transactions.
[0096] In one application embodiment of this application, such as Figure 8 As shown, Figure 8 A schematic diagram of the data transaction architecture is shown. Figure 8 The system comprises IoT sensors, enclave processing modules, data proxy nodes, and servers. These components can act as participants in the data production process. For example, in a product information sharing system, the product factory managing the IoT sensors is the data producer. Due to limited network conditions, IoT sensors can only connect to a single data generator. The blockchain network consists of servers that are each system participant and act as blockchain nodes. Considering the instability of the network environment between servers, the network communication between these blockchain nodes is peer-to-peer, employing a partially synchronized model. Figure 8 The architecture shown employs a bilinear mapping scheme, where bilinear pairing can be used to construct the system within an elliptic curve system, and the system is initialized using an elliptic curve data signature algorithm. In practical applications, such as... Figure 8The architecture shown comprises four entities: Enclave, data broker nodes, blockchain, and IPFS. Enclave handles the registration of IoT sensors. When a new IoT sensor joins the network, Enclave registers it and provides a digital certificate. The registration contracts for IoT sensors are executed within Enclave. Furthermore, to prevent the addition of malicious IoT sensors to the network, Enclave is responsible for generating public-private key pairs for key exchange. These keys are generated using an elliptic curve digital signature algorithm, and the key exchange process is entirely conducted within Enclave. Data broker nodes handle data purchase and sales requests. All data broker nodes share the same distributed ledger, and information about data transactions is stored on the blockchain for transparency. The data received by data broker nodes is encrypted by Enclave, ensuring the authenticity of the data broker nodes. The blockchain can provide transparency and security for data transactions within the data broker nodes on the Fabric consortium blockchain. IPFS resides in the storage layer and is used to store transaction data to ensure long-term data availability.
[0097] To implement the data transaction method of this application embodiment, this application embodiment also provides a data transaction apparatus. For example... Figure 9 As shown, the device includes:
[0098] The first acquisition unit 901 is used to acquire a first request; the first request is used to request the implementation of a first transaction; the first transaction represents the transaction of first data collected by the first sensor.
[0099] The second acquisition unit 902 is used to acquire the first data; the first connection represents the communication connection established between the setting container and the first sensor;
[0100] The first determining unit 903 is used to determine the transaction status of the first data in the set container;
[0101] The first transaction unit 904 is used to complete the signing of the first transaction when the transaction status of the first data is not traded, and to add the first data and the first transaction information to the blockchain based on the first connection.
[0102] In one embodiment, when the first acquisition unit 901 acquires the first request, it is further configured to:
[0103] Obtain device information from the first sensor;
[0104] Based on the device information of the first sensor, if the first sensor is a verified sensor, the first request is obtained.
[0105] In one embodiment, when determining the transaction status of the first data, the first determining unit 903 is further configured to:
[0106] Determine the first hash value of the first data;
[0107] If the first hash value of the first data exists in the set hash list, the transaction status of the first data is determined to be "transactional".
[0108] If the first hash value of the first data does not exist in the set hash list, the transaction status of the first data is determined to be untransactioned.
[0109] In one embodiment, when the first transaction unit 904 completes the signing of the first transaction while the transaction status of the first data is untransactional, it is further configured to:
[0110] Obtain a first verification package of the first data; the first verification package includes the data index of the first data, a second hash value, and a first random value; the second hash value is obtained by the buyer user in the first transaction based on the data index of the first data and the first random value;
[0111] The third hash value is determined based on the data index and the first random value of the first data in the first verification package;
[0112] If the second hash value is the same as the third hash value, the signing of the first transaction is completed.
[0113] In one embodiment, when the first hash value of the first data does not exist in the set hash list, the device is further configured to:
[0114] Add the first hash value of the first data to the set hash list.
[0115] In one embodiment, after adding the first data and the first transaction information to the blockchain, the device is further configured to:
[0116] Upload the first data to the designated file sharing system.
[0117] In one embodiment, the device is further configured to:
[0118] Upon receiving a second request, access permissions are determined based on the first transaction information; the second request indicates that a second sensor or data agent node requests access to second data stored in the designated file-sharing system; the access permissions indicate the permission to access the second data.
[0119] If the access permission indicates that access to the second data is permitted, the second data stored in the set file-sharing system is returned based on the first hash value of the second data.
[0120] In practical applications, the first acquisition unit 901, the second acquisition unit 902, the first determination unit 903, and the first transaction unit 904 can be implemented by the processor in the data transaction device. Of course, the processor needs to run the program stored in the memory to implement the functions of the above program modules.
[0121] It should be noted that the above Figure 9 The data trading device provided in this embodiment is illustrated using the above-described division of program modules as an example. In practical applications, the above processing can be distributed among different program modules as needed, that is, the internal structure of the device can be divided into different program modules to complete all or part of the processing described above. Furthermore, the data trading device and data trading method embodiments provided in the above embodiments belong to the same concept, and their specific implementation processes are detailed in the method embodiments, and will not be repeated here.
[0122] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiments of this application, the embodiments of this application also provide an electronic device. Figure 10 This is a schematic diagram of the hardware structure of the electronic device according to an embodiment of this application, as shown below. Figure 10 As shown, the electronic device includes:
[0123] Communication interface 1 enables information exchange with other devices, such as network devices;
[0124] Processor 2 is connected to communication interface 1 to enable information interaction with other devices and to execute the data transaction methods provided by one or more of the above-mentioned technical solutions when running computer programs. The computer program is stored in memory 3.
[0125] Of course, in practical applications, the various components in an electronic device are coupled together through bus system 4. It can be understood that bus system 4 is used to achieve communication and connection between these components. In addition to the data bus, bus system 4 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 10 The general will label all buses as Bus System 4.
[0126] The memory 3 in this embodiment is used to store various types of data to support the operation of the electronic device. Examples of such data include any computer program used to operate on the electronic device.
[0127] It is understood that memory 3 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memory 3 described in the embodiments of this application is intended to include, but is not limited to, these and any other suitable types of memory.
[0128] The methods disclosed in the embodiments of this application can be applied to processor 2, or implemented by processor 2. Processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 2 or by instructions in the form of software. The processor 2 may be a general-purpose processor, DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in memory 3. Processor 2 reads the program in memory 3 and completes the steps of the aforementioned method in combination with its hardware.
[0129] When processor 2 executes the program, it implements the corresponding processes in the various methods of the embodiments of this application. For the sake of brevity, these will not be described in detail here.
[0130] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a memory 3 that stores a computer program, which can be executed by a processor 2 to complete the steps described in the aforementioned method. The computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM.
[0131] In the several embodiments provided in this application, it should be understood that the disclosed apparatus, terminal, and method can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0132] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0133] In addition, each functional unit in the various embodiments of this application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0134] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0135] Alternatively, if the integrated units described above are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0136] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method of data transaction, characterized by, The method comprises: obtaining a first request; the first request is used to request to implement a first transaction; the first transaction represents a transaction of first data collected by a first sensor; obtaining the first data based on a first connection; the first connection represents a communication connection established between a set container and the first sensor; determining a transaction state of the first data in the set container; in the case that the transaction state of the first data is untransacted, completing the signing of the first transaction; wherein, in the case that the transaction state of the first data is untransacted, completing the signing of the first transaction comprises: obtaining a first verification package of the first data; the first verification package comprises a data index of the first data, a second hash value and a first random value; the second hash value is calculated based on part of the data selected from the first data and the first random value by a buyer user in the first transaction; the data index of the first data is used to indicate the position of the part of data selected by the buyer user in the first data; according to the data index of the first data in the first verification package, the corresponding data in the first data corresponding to the data index is found, and a third hash value is determined according to the corresponding data and the first random value; in the case that the second hash value and the third hash value are the same, the signing of the first transaction is completed; based on the first connection, adding the first data and first transaction information of the first transaction to a block chain.
2. The method of claim 1, wherein, The method further comprises: obtaining device information of the first sensor; in the case that the first sensor is a verified sensor according to the device information of the first sensor, obtaining the first request.
3. The method of claim 1, wherein, The method further comprises: determining a first hash value of the first data; in the case that the first hash value of the first data exists in a set hash list, determining that the transaction state of the first data is transacted; in the case that the first hash value of the first data does not exist in the set hash list, determining that the transaction state of the first data is untransacted.
4. The method of claim 3, wherein, The method further comprises: adding the first hash value of the first data to the set hash list.
5. The method of claim 1, wherein, After adding the first data and the first transaction information of the first transaction to the block chain, the method further comprises: uploading the first data to a set file sharing system.
6. The method of claim 5, wherein, The method further comprises: in the case that a second request is received, determining an access right according to the first transaction information; the second request represents a request of a second sensor or a data agent node to access second data stored in the set file sharing system; the access right represents an access right to the second data; in the case that the access right represents that the second data is allowed to be accessed, returning the second data stored in the set file sharing system according to a first hash value of the second data.
7. A data transaction apparatus, characterized by comprising: The method comprises: a first obtaining unit, configured to obtain a first request; The first request is used to request to implement a first transaction; the first transaction represents a transaction of first data collected by a first sensor; A second acquisition unit is configured to acquire the first data based on a first connection; The first connection represents a communication connection established between a set container and the first sensor; A first determination unit is configured to determine a transaction state of the first data in the set container; A first transaction unit is configured to complete signing of the first transaction in a case that the transaction state of the first data is untransaction; wherein the signing of the first transaction in the case that the transaction state of the first data is untransaction includes: acquiring a first verification package of the first data; the first verification package includes a data index, a second hash value and a first random value of the first data; the second hash value is calculated based on part of data selected from the first data and the first random value by a buyer user in the first transaction; the data index of the first data is used to indicate a position of the part of data selected by the buyer user in the first data; corresponding data corresponding to the data index in the first data is found according to the data index of the first data in the first verification package, and a third hash value is determined according to the corresponding data and the first random value; the signing of the first transaction is completed in a case that the second hash value is same as the third hash value; and the first transaction unit is further configured to add the first data and first transaction information of the first transaction into a block chain based on the first connection.
8. An electronic device, comprising: Comprise: a processor and a memory for storing a computer program capable of running on the processor, wherein the processor is used to run the computer program, and execute the steps of the method in any one of claims 1 to 6.
9. A storage medium having stored thereon a computer program, characterized in that The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.
Citation Information
Patent Citations
Transaction processing method and device based on block chain and electronic equipment
CN111461883A
Data processing method, device and equipment based on block chain and readable storage medium
CN111600720A