Blockchain-based traceability data processing method, device, electronic device and medium
By encapsulating the scattered data of the data provider in NFT form and using blockchain for evidence storage, the problem of insufficient location efficiency and accuracy of traceability data in the existing traceability model is solved, and efficient and reliable evidence storage of traceability data is achieved.
Patent Information
- Application Number
- CN202210427026.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-21
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2042-04-21
AI Technical Summary
The existing traceability model has insufficient efficiency and accuracy in traceability data location, and the relationship between the data and the data provider cannot be trusted and proof-keeping, resulting in low accuracy of traceability data.
The traceability data processing method based on blockchain is adopted to encapsulate the scattered data of the data provider into an inseparable whole in the form of NFT, and the traceability data and data providers are trustworthy and proof-keeping through smart contracts.
It improves the location efficiency and accuracy of the traceability source of traceability data, and ensures the security and immutability of traceability data.
Smart Images

Figure CN114741738B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a blockchain-based traceability data processing method, device, electronic device and medium. Background Art
[0002] For the commodity industry, the supply chain is relatively isolated, and each node in an industrial chain is an information island. The degree of informatization of the entire process is low, and transaction data tracing is extremely difficult. The existing traceability model is to mark a traceable object at the source of the traceability object, and each data provider involved in the transmission link of the traceability object provides the link data to the traceability system.
[0003] However, after each data provider uploads the data to the traceability system, it needs to go through complex processes such as traceability model, data analysis, and multi-party verification to locate the data source, resulting in low efficiency in locating traceability data. At the same time, since the relationship between the data and the data provider is not credibly documented, the data provider may deny the facts and tamper with the data, resulting in low accuracy of traceability data. Summary of the invention
[0004] In view of the above, it is necessary to propose a blockchain-based traceability data processing method, device, electronic device and medium, which encapsulates the scattered data of the data provider in the form of NFT as an indivisible whole, and provides credible evidence for the traceability data and the data provider, thereby improving the efficiency and accuracy of locating the traceability source of the traceability data.
[0005] A first aspect of the present invention provides a blockchain-based traceability data processing method, the method comprising:
[0006] Receive the original traceability data of the target object, create a traceability link of the target object based on the original traceability data, and deploy the traceability link to the blockchain through a smart contract, wherein the traceability link contains a traceability code;
[0007] In response to a received traceability data evidence storage request from a data provider of the target object, parsing the traceability data evidence storage request to obtain a parsing result;
[0008] Send the parsing result to the NFT generation model of the smart contract to generate the target NFT data of the data provider and store it;
[0009] When a request for downloading the traceability data of the target object sent by the data query party is detected, determining whether the data query party has the authority to download the traceability data;
[0010] When the data query party has the authority to download the traceability data, an authorization message is generated through the smart contract, and the traceability data is downloaded based on the authorization message.
[0011] Optionally, sending the parsing result to the NFT generation model of the smart contract, generating the target NFT data of the data provider and storing it includes:
[0012] Identify the data type of each data field information in the parsing result;
[0013] When it is identified that the data type of each data field information in the parsing result is text data, each data field information is sent to the NFT generation model of the smart contract; when it is identified that the data type of each data field information in the parsing result is not text data, a hash value of each data field information is calculated, and the hash value is sent to the NFT generation model of the smart contract;
[0014] The NFT generation model of the smart contract generates the NFT identification code of the data provider, and fills each received data field information or hash value into the corresponding position of the data provider's traceability node according to the node name and data field information of the data provider's traceability node corresponding to the target traceability link, as well as the data format of each data field information, to obtain the first NFT data;
[0015] Fill in the information of the data provider in the field corresponding to the data provider to obtain the second NFT data;
[0016] The NFT generation model of the smart contract encapsulates the NFT identification code, the first NFT data, and the second NFT data to generate the target NFT data of the data provider;
[0017] The target NFT data of the data provider is sent to the data storage model of the smart contract, and the target NFT data of the data provider is written into the blockchain for storage in the data storage model.
[0018] Optionally, the creating a traceability link of the target object based on the original traceability data includes:
[0019] Identify the original traceability data, obtain the node name and data field information of each traceability node of the target object, and the data format of each data field information;
[0020] Convert each traceability node of the target object into a traceability node of a corresponding traceability link, wherein the traceability node of the traceability link contains the node name and data field information of the traceability node, as well as the data format of each data field information;
[0021] Convert the reference relationship between each traceability node into an edge between nodes in the corresponding traceability link, wherein the edge between the traceability nodes in the traceability link serves as the reference relationship between the traceability nodes in the traceability link;
[0022] A traceability link for the target object is created according to the reference relationship between the traceability node of the traceability link and the traceability node in the traceability link.
[0023] Optionally, parsing the traceability data evidence storage request to obtain a parsing result includes:
[0024] Parse the traceability data evidence storage request to obtain the target traceability code and evidence data;
[0025] Matching the target traceability link corresponding to the target traceability code from a preset database;
[0026] The stored evidence data is sent to the smart contract, and the data storage model of the smart contract parses the stored evidence data according to the preset parsing specification to obtain the parsing result.
[0027] Optionally, the determining whether the data querying party has the authority to download the traceability data includes:
[0028] Parse the request to download the traceability data of the target object and obtain the NFT identification code of the traceability data;
[0029] Send the NFT identification code to the NFT application model of the smart contract, generate an application for the use of the NFT data, and write the application for the use of the NFT data into the blockchain;
[0030] Determine whether the application for use of the NFT data is authorized;
[0031] When the application for use of the NFT data is authorized, it is determined that the data querying party has the authority to download the traceability data;
[0032] When the application for use of the NFT data is not authorized, it is determined that the data querying party does not have the authority to download the traceability data.
[0033] Optionally, generating an authorization message through the smart contract, and downloading the traceability data based on the authorization message includes:
[0034] The NFT authorization model of the smart contract receives the authorization message sent by the data provider and writes the authorization message into the blockchain;
[0035] Verifying the signature of the data querying party based on the authorization message;
[0036] When the signature verification is passed, the data querying party downloads the traceability data from the data storage server based on the authorization message.
[0037] Optionally, the method further comprises:
[0038] When a request for querying the traceability data sent by the data query party is detected, the traceability code of the target object is obtained;
[0039] Query the corresponding traceability link according to the traceability code, and match the evidence information of all traceability nodes on the traceability link;
[0040] The evidence information of all traceability nodes is sorted according to a preset sorting method, and the sorting result is returned to the data query party.
[0041] A second aspect of the present invention provides a traceability data processing device based on blockchain, the device comprising:
[0042] A receiving and creating module, which is used to receive the original traceability data of the target object, create a traceability link of the target object based on the original traceability data, and deploy the traceability link to the blockchain through a smart contract, wherein the traceability link contains a traceability code;
[0043] A parsing module, configured to respond to a received traceability data evidence storage request from a data provider of the target object, parse the traceability data evidence storage request, and obtain a parsing result;
[0044] A generation module, used to send the parsing result to the NFT generation model of the smart contract, generate the target NFT data of the data provider and store it;
[0045] A judgment module, for judging whether the data querying party has the authority to download the traceability data when a request for downloading the traceability data of the target object sent by the data querying party is detected;
[0046] The download module is used to generate an authorization message through the smart contract when the data query party has the authority to download the traceability data, and download the traceability data based on the authorization message.
[0047] A third aspect of the present invention provides an electronic device, comprising a processor and a memory, wherein the processor is used to implement the blockchain-based traceability data processing method when executing a computer program stored in the memory.
[0048] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the blockchain-based traceability data processing method is implemented.
[0049] In summary, the blockchain-based traceability data processing method, device, electronic device and medium described in the present invention create a traceability link of the target object based on the original traceability data, and deploy the traceability link to the blockchain through a smart contract, establish a storage relationship between the traceability data and the provider of the traceability data, and use the blockchain to store the traceability data, so that the traceability data cannot be tampered with once it is on the chain, thereby improving the security of the traceability data stored in the traceability link. The traceability data storage request of the data provider is parsed to obtain the parsing result, and the parsing result is sent to the NFT generation model of the smart contract, the target NFT data of the data provider is generated and stored, the scattered data of the data provider is encapsulated as an inseparable whole in the form of NFT, and the traceability data and the data provider are credibly stored, thereby improving the positioning efficiency and accuracy of the traceability source of the traceability data. When the data query party has the right to download the traceability data, an authorization message is generated through the smart contract, and under the authorization condition, the traceability data is downloaded based on the authorization message, thereby improving the security of the traceability data. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 This is a flowchart of a blockchain-based traceability data processing method provided in Example 1 of the present invention.
[0051] Figure 2 This is a structural diagram of a blockchain-based traceability data processing device provided in Example 2 of the present invention.
[0052] Figure 3 It is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0053] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.
[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0055] Embodiment 1
[0056] Figure 1 This is a flowchart of a blockchain-based traceability data processing method provided in Example 1 of the present invention.
[0057] In this embodiment, the blockchain-based traceability data processing method can be applied to electronic devices. For electronic devices that need to perform blockchain-based traceability data processing, the blockchain-based traceability data processing function provided by the method of the present invention can be directly integrated into the electronic device, or run in the electronic device in the form of a software development kit (Software Development Kit, SDK).
[0058] like Figure 1 As shown, the blockchain-based traceability data processing method specifically includes the following steps. According to different requirements, the order of the steps in the flowchart can be changed, and some can be omitted.
[0059] S11, receiving original traceability data of the target object, creating a traceability link of the target object based on the original traceability data, and deploying the traceability link to the blockchain through a smart contract, wherein the traceability link contains a traceability code.
[0060] In this embodiment, during the traceability data processing of the target object, a traceability link can be created for the target object to realize the storage of the traceability data of the target object, and the traceability data can be deployed to the blockchain through a smart contract.
[0061] In this embodiment, the target object may be a certain product, for example, vaccine A, and a traceability link is created for vaccine A. The traceability link corresponds to a unique traceability code, and the traceability code is used to uniquely identify the target object.
[0062] In this embodiment, the smart contract provides functions such as link storage of traceability data, data storage, NFT data generation, NFT application, NFT authorization, and data traceability query. The smart contract includes an NFT generation model, a data storage model, an NFT application model, a data storage model, and an NFT authorization model.
[0063] In an optional embodiment, the creating the traceability link of the target object based on the original traceability data includes:
[0064] Identify the original traceability data, obtain the node name and data field information of each traceability node of the target object, and the data format of each data field information;
[0065] Convert each traceability node of the target object into a traceability node of a corresponding traceability link, wherein the traceability node of the traceability link contains the node name and data field information of the traceability node, as well as the data format of each data field information;
[0066] Convert the reference relationship between each traceability node into an edge between nodes in the corresponding traceability link, wherein the edge between the traceability nodes in the traceability link serves as the reference relationship between the traceability nodes in the traceability link;
[0067] A traceability link for the target object is created according to the reference relationship between the traceability node of the traceability link and the traceability node in the traceability link.
[0068] In this embodiment, the original traceability data includes the node name and data field information of each traceability node of the target object, as well as the data format of each data field information. The original source data also includes the traceability data provider information of each traceability node, the original data characteristics and other attribute information of the traceability data.
[0069] In this embodiment, a traceability link of the target object is created based on the original traceability data, and the traceability link is deployed to the blockchain through a smart contract. A storage relationship is established between the traceability data and the provider of the traceability data, and the blockchain is used to store the traceability data. Once the traceability data is uploaded to the chain, it cannot be tampered with, thereby improving the security of the traceability data subsequently stored on the traceability link.
[0070] S12, in response to the received traceability data evidence request from the data provider of the target object, parsing the traceability data evidence request to obtain a parsing result.
[0071] In this embodiment, when the data provider needs to store the traceability data of the target object, the client of the data provider sends a traceability data storage request to the server, and the server parses the traceability data storage request to obtain a parsing result.
[0072] In an optional embodiment, parsing the traceability data evidence storage request to obtain a parsing result includes:
[0073] Parse the traceability data evidence storage request to obtain the target traceability code and evidence data;
[0074] Matching the target traceability link corresponding to the target traceability code from a preset database;
[0075] The stored evidence data is sent to the smart contract, and the data storage model of the smart contract parses the stored evidence data according to the preset parsing specification to obtain the parsing result.
[0076] In this embodiment, a database can be established in advance, in which traceability codes of traceability links of all target objects are stored. When a data provider sends a traceability data evidence request, the traceability data evidence request includes a target traceability code and evidence data. The target traceability link can be quickly determined through the target traceability code. The target traceability link corresponds to a preset parsing specification. The evidence data is parsed according to the preset parsing specification, which facilitates the subsequent management of the evidence data and improves the management efficiency of the evidence data.
[0077] S13, sending the parsing result to the NFT generation model of the smart contract, generating the target NFT data of the data provider and storing it.
[0078] In this embodiment, when the analysis results are stored, the analysis results are sent to the NFT generation model of the smart contract, and the NFT package is performed on the analysis results to obtain the NFT data of the data provider.
[0079] In an optional embodiment, sending the parsing result to the NFT generation model of the smart contract, generating the target NFT data of the data provider and storing it includes:
[0080] Identify the data type of each data field information in the parsing result;
[0081] When it is identified that the data type of each data field information in the parsing result is text data, each data field information is sent to the NFT generation model of the smart contract; when it is identified that the data type of each data field information in the parsing result is not text data, a hash value of each data field information is calculated, and the hash value is sent to the NFT generation model of the smart contract;
[0082] The NFT generation model of the smart contract generates the NFT identification code of the data provider, and fills each received data field information or hash value into the corresponding position of the data provider's traceability node according to the node name and data field information of the data provider's traceability node corresponding to the target traceability link, as well as the data format of each data field information, to obtain the first NFT data;
[0083] Fill in the information of the data provider in the field corresponding to the data provider to obtain the second NFT data;
[0084] The NFT generation model of the smart contract encapsulates the NFT identification code, the first NFT data, and the second NFT data to generate the target NFT data of the data provider;
[0085] The target NFT data of the data provider is sent to the data storage model of the smart contract, and the target NFT data of the data provider is written into the blockchain for storage in the data storage model.
[0086] In this embodiment, when encapsulating the target NFT data of the data provider, the information of the data provider is bound, so that the target NFT data is more complete and the management efficiency of the NFT data is improved.
[0087] In this embodiment, the NFT generation model in the smart contract receives each data field information, hash value, data provider information and NFT identification code, and encapsulates these scattered data in the form of NFT as an indivisible whole. When an abnormality occurs in the traceability data, the NFT identification code of the abnormal traceability data is obtained, and the data source of the abnormal traceability data is determined to be the data provider corresponding to the NFT identification code. For example, in the vaccine logistics transportation link, operator A provides the quantity data of goods shipped out of the warehouse, operator B provides the transportation environment data such as temperature and humidity during the transportation process, and operator C provides the transportation vehicle and driver information. Finally, if the number of vaccines is abnormal, operator A can be quickly located, thereby improving the positioning efficiency and accuracy of the traceability source of the traceability data. In addition, since the target NFT data of each data provider is taken as a whole, the traceability data and the data provider are reliably stored, which avoids the problem of unreliable traceability data caused by the data provider tampering with the traceability data, thereby improving the security of the traceability data.
[0088] S14, when a request for downloading the traceability data of the target object sent by the data query party is detected, it is determined whether the data query party has the authority to download the traceability data.
[0089] In this embodiment, the request to download the traceability data of the target object refers to the data query party's request to read the encapsulated NFT data. In order to ensure the security of the NFT data, it is necessary to determine whether the data query party has the authority to download the traceability data of the target object.
[0090] In an optional embodiment, the determining whether the data querying party has the authority to download the traceability data includes:
[0091] Parse the request to download the traceability data of the target object and obtain the NFT identification code of the traceability data;
[0092] Send the NFT identification code to the NFT application model of the smart contract, generate an application for the use of the NFT data, and write the application for the use of the NFT data into the blockchain;
[0093] Determine whether the application for use of the NFT data is authorized;
[0094] When the application for use of the NFT data is authorized, it is determined that the data querying party has the authority to download the traceability data;
[0095] When the application for use of the NFT data is not authorized, it is determined that the data querying party does not have the authority to download the traceability data.
[0096] In this embodiment, the NFT application model of the smart contract can record the use application of the NFT data based on the data query party's request to download the traceability data of the target object and the NFT identification code of the traceability data, and write the use application of the NFT data into the blockchain. The owner of the NFT data determines whether the use application of the NFT data is authorized, and determines whether the data query party has the authority to download the traceability data based on the judgment result. When the data query party has the authority to download the traceability data, the data query party is authorized to download the traceability data.
[0097] Furthermore, the method further comprises:
[0098] When a request for querying the traceability data sent by the data query party is detected, the traceability code of the target object is obtained;
[0099] Query the corresponding traceability link according to the traceability code, and match the evidence information of all traceability nodes on the traceability link;
[0100] The evidence information of all traceability nodes is sorted according to a preset sorting method, and the sorting result is returned to the data query party.
[0101] In this embodiment, the evidence information includes the traceability code of the traceability link, the NFT identification code of each traceability node, the application for use of NFT data and other evidence records.
[0102] In this embodiment, when the data query party queries the link evidence information of the traceability data, it does not need to obtain authorization from the owner. All the evidence information of the target object can be quickly queried through the traceability code of the traceability link of the traceability data, thereby improving the tracing efficiency of the traceability data.
[0103] S15, when the data query party has the authority to download the traceability data, an authorization message is generated through the smart contract, and the traceability data is downloaded based on the authorization message.
[0104] In this embodiment, when the data query party has the authority to download the traceability data, it is necessary to verify the signature of the data query party to further ensure the security of the traceability data.
[0105] In an optional embodiment, generating an authorization message through the smart contract and downloading the traceability data based on the authorization message includes:
[0106] The NFT authorization model of the smart contract receives the authorization message sent by the data provider and writes the authorization message into the blockchain;
[0107] Verifying the signature of the data querying party based on the authorization message;
[0108] When the signature verification is passed, the data querying party downloads the traceability data from the data storage server based on the authorization message.
[0109] Furthermore, the method further comprises:
[0110] When the signature verification fails, the NFT authorization model will write an authorization rejection message into the blockchain.
[0111] S16: When the data querying party does not have the authority to download the traceability data, an authorization rejection message is generated through the smart contract.
[0112] In other optional embodiments, the method further includes:
[0113] When the data querying party has the authority to download the traceability data, the owner of the traceability data sends the traceability data to the data querying party.
[0114] Further, after downloading the traceability data based on the authorization message, the method further includes:
[0115] Compare the hash value in the downloaded traceability data with the hash value of the evidence stored on the corresponding traceability link;
[0116] When the hash value in the downloaded traceability data is completely consistent with the hash value of the evidence stored on the corresponding traceability link, it is determined that the downloaded traceability data is correct;
[0117] When the hash value in the downloaded traceability data is not completely consistent with the hash value of the evidence stored on the corresponding traceability link, it is determined that the downloaded traceability data is abnormal.
[0118] In this embodiment, the data query party can obtain the traceability data in two ways. The first way is that when there is a confidentiality requirement for the traceability data, the owner of the traceability data directly sends the traceability data to the data owner when it is determined that the data query party has the authority to download the traceability data. The second way is that when there is no confidentiality requirement for the traceability data, the owner of the traceability data authorizes the data query party to download the traceability data from the data storage server, which further improves the security of the traceability data.
[0119] In summary, the traceability data processing method based on blockchain described in this embodiment creates a traceability link of the target object based on the original traceability data, and deploys the traceability link to the blockchain through a smart contract, establishes a storage relationship between the traceability data and the provider of the traceability data, and uses the blockchain to store the traceability data, so that the traceability data cannot be tampered with once it is on the chain, thereby improving the security of the traceability data stored in the traceability link. The traceability data storage request of the data provider is parsed to obtain the parsing result, and the parsing result is sent to the NFT generation model of the smart contract, the target NFT data of the data provider is generated and stored, the scattered data of the data provider is encapsulated in the form of NFT as an inseparable whole, and the traceability data and the data provider are stored reliably, which improves the positioning efficiency and accuracy of the traceability source of the traceability data. When the data query party has the right to download the traceability data, an authorization message is generated through the smart contract. Under the authorization condition, the traceability data is downloaded based on the authorization message, thereby improving the security of the traceability data.
[0120] Embodiment 2
[0121] Figure 2 This is a structural diagram of a blockchain-based traceability data processing device provided in Example 2 of the present invention.
[0122] In some embodiments, the blockchain-based traceability data processing device 20 may include multiple functional modules composed of program code segments. The program code of each program segment in the blockchain-based traceability data processing device 20 may be stored in the memory of the electronic device and executed by the at least one processor to execute (see Figure 1 Description) The function of blockchain-based traceability data processing.
[0123] In this embodiment, the blockchain-based traceability data processing device 20 can be divided into multiple functional modules according to the functions it performs. The functional modules may include: a receiving and creating module 201, a parsing module 202, a generating module 203, a judging module 204, a downloading module 205, a writing module 206 and a comparing module 207. The module referred to in the present invention refers to a series of computer-readable instruction segments that can be executed by at least one processor and can perform fixed functions, which are stored in a memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.
[0124] The receiving and creating module 201 is used to receive the original traceability data of the target object, create a traceability link of the target object based on the original traceability data, and deploy the traceability link to the blockchain through a smart contract, wherein the traceability link contains a traceability code.
[0125] In this embodiment, during the traceability data processing of the target object, a traceability link can be created for the target object to realize the storage of the traceability data of the target object, and the traceability data can be deployed to the blockchain through a smart contract.
[0126] In this embodiment, the target object may be a certain product, for example, vaccine A, and a traceability link is created for vaccine A. The traceability link corresponds to a unique traceability code, and the traceability code is used to uniquely identify the target object.
[0127] In this embodiment, the smart contract provides functions such as link storage of traceability data, data storage, NFT data generation, NFT application, NFT authorization, and data traceability query. The smart contract includes an NFT generation model, a data storage model, an NFT application model, a data storage model, and an NFT authorization model.
[0128] In an optional embodiment, the receiving and creating module 201 creates the traceability link of the target object based on the original traceability data, including:
[0129] Identify the original traceability data, obtain the node name and data field information of each traceability node of the target object, and the data format of each data field information;
[0130] Convert each traceability node of the target object into a traceability node of a corresponding traceability link, wherein the traceability node of the traceability link contains the node name and data field information of the traceability node, as well as the data format of each data field information;
[0131] Convert the reference relationship between each traceability node into an edge between nodes in the corresponding traceability link, wherein the edge between the traceability nodes in the traceability link serves as the reference relationship between the traceability nodes in the traceability link;
[0132] A traceability link for the target object is created according to the reference relationship between the traceability node of the traceability link and the traceability node in the traceability link.
[0133] In this embodiment, the original traceability data includes the node name and data field information of each traceability node of the target object, as well as the data format of each data field information. The original source data also includes the traceability data provider information of each traceability node, the original data characteristics and other attribute information of the traceability data.
[0134] In this embodiment, a traceability link of the target object is created based on the original traceability data, and the traceability link is deployed to the blockchain through a smart contract. A storage relationship is established between the traceability data and the provider of the traceability data, and the blockchain is used to store the traceability data. Once the traceability data is uploaded to the chain, it cannot be tampered with, thereby improving the security of the traceability data subsequently stored on the traceability link.
[0135] The parsing module 202 is used to respond to the received traceability data evidence request from the data provider of the target object, parse the traceability data evidence request, and obtain a parsing result.
[0136] In this embodiment, when the data provider needs to store the traceability data of the target object, the client of the data provider sends a traceability data storage request to the server, and the server parses the traceability data storage request to obtain a parsing result.
[0137] In an optional embodiment, the parsing module 202 parses the traceability data evidence storage request, and the parsing result obtained includes:
[0138] Parse the traceability data evidence storage request to obtain the target traceability code and evidence data;
[0139] Matching the target traceability link corresponding to the target traceability code from a preset database;
[0140] The stored evidence data is sent to the smart contract, and the data storage model of the smart contract parses the stored evidence data according to the preset parsing specification to obtain the parsing result.
[0141] In this embodiment, a database can be established in advance, in which traceability codes of traceability links of all target objects are stored. When a data provider sends a traceability data evidence request, the traceability data evidence request includes a target traceability code and evidence data. The target traceability link can be quickly determined through the target traceability code. The target traceability link corresponds to a preset parsing specification. The evidence data is parsed according to the preset parsing specification, which facilitates the subsequent management of the evidence data and improves the management efficiency of the evidence data.
[0142] The generation module 203 is used to send the analysis result to the NFT generation model of the smart contract, generate the target NFT data of the data provider and store it.
[0143] In this embodiment, when the analysis results are stored, the analysis results are sent to the NFT generation model of the smart contract, and the NFT package is performed on the analysis results to obtain the NFT data of the data provider.
[0144] In an optional embodiment, the generation module 203 sends the parsing result to the NFT generation model of the smart contract, generates the target NFT data of the data provider and stores it, including:
[0145] Identify the data type of each data field information in the parsing result;
[0146] When it is identified that the data type of each data field information in the parsing result is text data, each data field information is sent to the NFT generation model of the smart contract; when it is identified that the data type of each data field information in the parsing result is not text data, a hash value of each data field information is calculated, and the hash value is sent to the NFT generation model of the smart contract;
[0147] The NFT generation model of the smart contract generates the NFT identification code of the data provider, and fills each received data field information or hash value into the corresponding position of the data provider's traceability node according to the node name and data field information of the data provider's traceability node corresponding to the target traceability link, as well as the data format of each data field information, to obtain the first NFT data;
[0148] Fill in the information of the data provider in the field corresponding to the data provider to obtain the second NFT data;
[0149] The NFT generation model of the smart contract encapsulates the NFT identification code, the first NFT data, and the second NFT data to generate the target NFT data of the data provider;
[0150] The target NFT data of the data provider is sent to the data storage model of the smart contract, and the target NFT data of the data provider is written into the blockchain for storage in the data storage model.
[0151] In this embodiment, when encapsulating the target NFT data of the data provider, the information of the data provider is bound, so that the target NFT data is more complete and the management efficiency of the NFT data is improved.
[0152] In this embodiment, the NFT generation model in the smart contract receives each data field information, hash value, data provider information and NFT identification code, and encapsulates these scattered data in the form of NFT as an indivisible whole. When an abnormality occurs in the traceability data, the NFT identification code of the abnormal traceability data is obtained, and the data source of the abnormal traceability data is determined to be the data provider corresponding to the NFT identification code. For example, in the vaccine logistics transportation link, operator A provides the quantity data of goods shipped out of the warehouse, operator B provides the transportation environment data such as temperature and humidity during the transportation process, and operator C provides the transportation vehicle and driver information. Finally, if the number of vaccines is abnormal, operator A can be quickly located, thereby improving the positioning efficiency and accuracy of the traceability source of the traceability data. In addition, since the target NFT data of each data provider is taken as a whole, the traceability data and the data provider are reliably stored, which avoids the problem of unreliable traceability data caused by the data provider tampering with the traceability data, thereby improving the security of the traceability data.
[0153] The judgment module 204 is used to judge whether the data query party has the authority to download the traceability data when a request for downloading the traceability data of the target object sent by the data query party is detected.
[0154] In this embodiment, the request to download the traceability data of the target object refers to the data query party's request to read the encapsulated NFT data. In order to ensure the security of the NFT data, it is necessary to determine whether the data query party has the authority to download the traceability data of the target object.
[0155] In an optional embodiment, the judging module 204 judges whether the data querying party has the authority to download the traceability data, including:
[0156] Parse the request to download the traceability data of the target object and obtain the NFT identification code of the traceability data;
[0157] Send the NFT identification code to the NFT application model of the smart contract, generate an application for the use of the NFT data, and write the application for the use of the NFT data into the blockchain;
[0158] Determine whether the application for use of the NFT data is authorized;
[0159] When the application for use of the NFT data is authorized, it is determined that the data querying party has the authority to download the traceability data;
[0160] When the application for use of the NFT data is not authorized, it is determined that the data querying party does not have the authority to download the traceability data.
[0161] In this embodiment, the NFT application model of the smart contract can record the use application of the NFT data based on the data query party's request to download the traceability data of the target object and the NFT identification code of the traceability data, and write the use application of the NFT data into the blockchain. The owner of the NFT data determines whether the use application of the NFT data is authorized, and determines whether the data query party has the authority to download the traceability data based on the judgment result. When the data query party has the authority to download the traceability data, the data query party is authorized to download the traceability data.
[0162] Furthermore, when a request for querying the traceability data sent by the data query party is detected, the traceability code of the target object is obtained; the corresponding traceability link is queried according to the traceability code, and the evidence information of all traceability nodes on the traceability link is matched; the evidence information of all traceability nodes is sorted according to a preset sorting method, and the sorting result is returned to the data query party.
[0163] In this embodiment, the evidence information includes the traceability code of the traceability link, the NFT identification code of each traceability node, the application for use of NFT data and other evidence records.
[0164] In this embodiment, when the data query party queries the link evidence information of the traceability data, it does not need to obtain authorization from the owner. All the evidence information of the target object can be quickly queried through the traceability code of the traceability link of the traceability data, thereby improving the tracing efficiency of the traceability data.
[0165] The download module 205 is used to generate an authorization message through the smart contract when the data query party has the authority to download the traceability data, and download the traceability data based on the authorization message.
[0166] In this embodiment, when the data query party has the authority to download the traceability data, it is necessary to verify the signature of the data query party to further ensure the security of the traceability data.
[0167] In an optional embodiment, the download module 205 generates an authorization message through the smart contract, and downloads the traceability data based on the authorization message, including:
[0168] The NFT authorization model of the smart contract receives the authorization message sent by the data provider and writes the authorization message into the blockchain;
[0169] Verifying the signature of the data querying party based on the authorization message;
[0170] When the signature verification is passed, the data querying party downloads the traceability data from the data storage server based on the authorization message.
[0171] The writing module 206 is used for the NFT authorization model to write a rejection authorization message into the blockchain when the signature verification fails.
[0172] Furthermore, the generating module 203 is also used to generate an authorization rejection message through the smart contract when the data querying party does not have the authority to download the traceability data.
[0173] In other optional embodiments, when the data querying party has the authority to download the traceability data, the owner of the traceability data sends the traceability data to the data querying party.
[0174] Furthermore, after the traceability data is downloaded based on the authorization message, the comparison module 207 is used to compare the hash value in the downloaded traceability data with the hash value stored on the corresponding traceability link; when the hash value in the downloaded traceability data is completely consistent with the hash value stored on the corresponding traceability link, it is determined that the downloaded traceability data is correct; when the hash value in the downloaded traceability data is not completely consistent with the hash value stored on the corresponding traceability link, it is determined that the downloaded traceability data is abnormal.
[0175] In this embodiment, the data query party can obtain the traceability data in two ways. The first way is that when there is a confidentiality requirement for the traceability data, the owner of the traceability data directly sends the traceability data to the data owner when it is determined that the data query party has the authority to download the traceability data. The second way is that when there is no confidentiality requirement for the traceability data, the owner of the traceability data authorizes the data query party to download the traceability data from the data storage server, which further improves the security of the traceability data.
[0176] In summary, the traceability data processing device based on blockchain described in this embodiment creates a traceability link of the target object based on the original traceability data, and deploys the traceability link to the blockchain through a smart contract, establishes a storage relationship between the traceability data and the provider of the traceability data, and uses the blockchain to store the traceability data, so that the traceability data cannot be tampered with once it is on the chain, thereby improving the security of the traceability data stored in the traceability link. The traceability data storage request of the data provider is parsed to obtain the parsing result, and the parsing result is sent to the NFT generation model of the smart contract, the target NFT data of the data provider is generated and stored, the scattered data of the data provider is encapsulated in the form of NFT as an inseparable whole, and the traceability data and the data provider are credibly stored, thereby improving the positioning efficiency and accuracy of the traceability source of the traceability data. When the data query party has the right to download the traceability data, an authorization message is generated through the smart contract, and under the authorization condition, the traceability data is downloaded based on the authorization message, thereby improving the security of the traceability data.
[0177] Embodiment 3
[0178] See also Figure 3 FIG. 2 is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. In a preferred embodiment of the present invention, the electronic device 3 includes a memory 31 , at least one processor 32 , at least one communication bus 33 and a transceiver 34 .
[0179] Those skilled in the art should understand that Figure 3 The structure of the electronic device shown does not constitute a limitation of the embodiments of the present invention, and may be a bus structure or a star structure. The electronic device 3 may also include more or less other hardware or software than shown in the figure, or a different component arrangement.
[0180] In some embodiments, the electronic device 3 is an electronic device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application-specific integrated circuits, programmable gate arrays, digital processors, and embedded devices. The electronic device 3 may also include client devices, which include but are not limited to any electronic product that can interact with a client through a keyboard, mouse, remote control, touchpad, or voice-controlled device, such as a personal computer, tablet computer, smart phone, digital camera, etc.
[0181] It should be noted that the electronic device 3 is only an example, and other existing or future electronic products that are suitable for the present invention should also be included in the protection scope of the present invention and included here by reference.
[0182] In some embodiments, the memory 31 is used to store program codes and various data, such as the blockchain-based traceability data processing device 20 installed in the electronic device 3, and realize high-speed and automatic access to programs or data during the operation of the electronic device 3. The memory 31 includes a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0183] In some embodiments, the at least one processor 32 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips, etc. The at least one processor 32 is the control core (Control Unit) of the electronic device 3, and uses various interfaces and lines to connect various components of the entire electronic device 3, and executes various functions and processes data of the electronic device 3 by running or executing programs or modules stored in the memory 31, and calling data stored in the memory 31.
[0184] In some embodiments, the at least one communication bus 33 is configured to implement connection and communication between the memory 31 and the at least one processor 32, etc.
[0185] Although not shown, the electronic device 3 may also include a power source (such as a battery) for supplying power to each component. Optionally, the power source may be logically connected to the at least one processor 32 through a power management device, so that the power management device can manage charging, discharging, and power consumption management. The power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device 3 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0186] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0187] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium and includes a number of instructions for enabling a computer device (which can be a personal computer, electronic device, or network device, etc.) or a processor to execute a part of the method described in each embodiment of the present invention.
[0188] In a further embodiment, in combination Figure 2 The at least one processor 32 can execute the operating device of the electronic device 3 and various installed applications (such as the blockchain-based traceability data processing device 20), program codes, etc., for example, the above-mentioned modules.
[0189] The memory 31 stores program codes, and the at least one processor 32 can call the program codes stored in the memory 31 to execute related functions. For example, Figure 2 The various modules described are program codes stored in the memory 31 and executed by the at least one processor 32, so as to realize the functions of the various modules to achieve the purpose of traceability data processing based on blockchain.
[0190] Exemplarily, the program code may be divided into one or more modules / units, which are stored in the memory 31 and executed by the processor 32 to complete the present application. The one or more modules / units may be a series of computer-readable instruction segments capable of completing specific functions, which are used to describe the execution process of the program code in the electronic device 3. For example, the program code may be divided into a receiving and creating module 201, a parsing module 202, a generating module 203, a judging module 204, a downloading module 205, a writing module 206, and a comparing module 207.
[0191] In one embodiment of the present invention, the memory 31 stores a plurality of computer-readable instructions, and the plurality of computer-readable instructions are executed by the at least one processor 32 to implement the function of blockchain-based traceability data processing.
[0192] Specifically, the specific implementation method of the at least one processor 32 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0193] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0194] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, and may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0195] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0196] It is obvious to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential features of the present invention. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present invention is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "including" does not exclude other units or, and the singular does not exclude the plural. The multiple units or devices stated in the present invention can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
[0197] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A blockchain-based traceability data processing method, characterized in that: The method comprises: Receive the original traceability data of the target object, create a traceability link of the target object based on the original traceability data, and deploy the traceability link to the blockchain through a smart contract, wherein the traceability link contains a traceability code; In response to a received traceability data evidence storage request from a data provider of the target object, parsing the traceability data evidence storage request to obtain a parsing result; The parsing result is sent to the NFT generation model of the smart contract to generate the target NFT data of the data provider and store it, including: identifying the data type of each data field information in the parsing result; when the data type of each data field information in the parsing result is identified as text data, each data field information is sent to the NFT generation model of the smart contract; when the data type of each data field information in the parsing result is identified as not text data, the hash value of each data field information is calculated and the hash value is sent to the NFT generation model of the smart contract; the NFT generation model of the smart contract generates the NFT identification code of the data provider, and provides the data provider according to the target traceability link. The node name and data field information of the traceability node of the data provider, as well as the data format of each data field information, fill each received data field information or hash value into the corresponding position of the traceability node of the data provider to obtain the first NFT data; fill in the information of the data provider in the corresponding field of the data provider to obtain the second NFT data; the NFT generation model of the smart contract encapsulates the NFT identification code, the first NFT data and the second NFT data to generate the target NFT data of the data provider; sends the target NFT data of the data provider to the data storage model of the smart contract, and writes the target NFT data of the data provider into the blockchain for storage in the data storage model; When a request for downloading the traceability data of the target object sent by the data query party is detected, determining whether the data query party has the authority to download the traceability data; When the data query party has the authority to download the traceability data, an authorization message is generated through the smart contract, and the traceability data is downloaded based on the authorization message.
2. The blockchain-based traceability data processing method according to claim 1, characterized in that: The creating of the traceability link of the target object based on the original traceability data includes: Identify the original traceability data, obtain the node name and data field information of each traceability node of the target object, and the data format of each data field information; Convert each traceability node of the target object into a traceability node of a corresponding traceability link, wherein the traceability node of the traceability link contains the node name and data field information of the traceability node, as well as the data format of each data field information; Convert the reference relationship between each traceability node into an edge between nodes in the corresponding traceability link, wherein the edge between the traceability nodes in the traceability link serves as the reference relationship between the traceability nodes in the traceability link; A traceability link for the target object is created according to the reference relationship between the traceability node of the traceability link and the traceability node in the traceability link.
3. The blockchain-based traceability data processing method according to claim 1, characterized in that: The parsing of the traceability data evidence storage request to obtain the parsing result includes: Parse the traceability data evidence storage request to obtain the target traceability code and evidence data; Matching the target traceability link corresponding to the target traceability code from a preset database; The stored evidence data is sent to the smart contract, and the data storage model of the smart contract parses the stored evidence data according to the preset parsing specification to obtain the parsing result.
4. The blockchain-based traceability data processing method according to claim 1, characterized in that: The determining whether the data querying party has the authority to download the traceability data includes: Parse the request to download the traceability data of the target object and obtain the NFT identification code of the traceability data; Send the NFT identification code to the NFT application model of the smart contract, generate an application for the use of the NFT data, and write the application for the use of the NFT data into the blockchain; Determine whether the application for use of the NFT data is authorized; When the application for use of the NFT data is authorized, it is determined that the data querying party has the authority to download the traceability data; When the application for use of the NFT data is not authorized, it is determined that the data querying party does not have the authority to download the traceability data.
5. The blockchain-based traceability data processing method according to claim 1, characterized in that: The step of generating an authorization message through the smart contract and downloading the traceability data based on the authorization message includes: The NFT authorization model of the smart contract receives the authorization message sent by the data provider and writes the authorization message into the blockchain; Verifying the signature of the data querying party based on the authorization message; When the signature verification is passed, the data querying party downloads the traceability data from the data storage server based on the authorization message.
6. The blockchain-based traceability data processing method according to any one of claims 1 to 5, characterized in that: The method further comprises: When a request for querying the traceability data sent by the data query party is detected, the traceability code of the target object is obtained; Query the corresponding traceability link according to the traceability code, and match the evidence information of all traceability nodes on the traceability link; The evidence information of all traceability nodes is sorted according to a preset sorting method, and the sorting result is returned to the data query party.
7. A blockchain-based traceability data processing device, characterized in that: The device comprises: A receiving and creating module, which is used to receive the original traceability data of the target object, create a traceability link of the target object based on the original traceability data, and deploy the traceability link to the blockchain through a smart contract, wherein the traceability link contains a traceability code; A parsing module, configured to respond to a received traceability data evidence storage request from a data provider of the target object, parse the traceability data evidence storage request, and obtain a parsing result; A generation module is used to send the parsing result to the NFT generation model of the smart contract, generate the target NFT data of the data provider and store it, including: identifying the data type of each data field information in the parsing result; when the data type of each data field information in the parsing result is identified as text data, each data field information is sent to the NFT generation model of the smart contract; when the data type of each data field information in the parsing result is identified as not text data, the hash value of each data field information is calculated, and the hash value is sent to the NFT generation model of the smart contract; the NFT generation model of the smart contract generates the NFT identification code of the data provider, and stores it according to the target traceability link corresponding to the target traceability link. The node name and data field information of the data provider's traceability node, as well as the data format of each data field information, fill each received data field information or hash value into the corresponding position of the data provider's traceability node to obtain the first NFT data; fill in the data provider's information in the corresponding field of the data provider to obtain the second NFT data; the NFT generation model of the smart contract encapsulates the NFT identification code, the first NFT data and the second NFT data to generate the target NFT data of the data provider; sends the target NFT data of the data provider to the data storage model of the smart contract, and writes the target NFT data of the data provider into the blockchain for storage in the data storage model; A judgment module, for judging whether the data querying party has the authority to download the traceability data when a request for downloading the traceability data of the target object sent by the data querying party is detected; The download module is used to generate an authorization message through the smart contract when the data query party has the authority to download the traceability data, and download the traceability data based on the authorization message.
8. An electronic device, characterized in that: The electronic device includes a processor and a memory, and the processor is used to implement the blockchain-based traceability data processing method as described in any one of claims 1 to 6 when executing the computer program stored in the memory.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the blockchain-based traceability data processing method as described in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Virtual asset disposal method for non-homogenized token based on block chain
CN113362073A
Commodity traceability anti-counterfeiting method based on block chain and related equipment
CN113706175A