A method and system for setting up a smart contract

By partitioning, storing and processing the sub-contracts of smart contracts by event category in the local device of the blockchain node, it ensures that high-privacy level data is processed in high-security level areas and solves the problem of leakage of private data when it is processed on low-security devices. issues, improving the security of data processing.

CN111859457BActive Publication Date: 2024-10-18LENOVO (BEIJING) LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010758938.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-31
Publication Date
2024-10-18
Estimated Expiration
2040-07-31

AI Technical Summary

Technical Problem

When the local device of the blockchain node processes blockchain data, the private data is easily read by non-blockchain nodes due to the low device privacy level, resulting in data leakage.

Method used

Using the smart contract setting method, sub-contracts that handle different types of events are loaded into storage areas with different security levels to ensure that high-privacy level data is processed in high-security level storage areas, and the result data is processed through encryption to avoid data leakage. Illegally obtained in a low-security area.

Benefits of technology

It improves the security of blockchain data processing, prevents privacy data leakage, ensures that high-privacy level data is processed in a safe environment, and enhances the privacy data protection capabilities of local devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111859457B_ABST
    Figure CN111859457B_ABST
Patent Text Reader

Abstract

The present application discloses a method and system for setting up a smart contract, which is applied to a first electronic device. In this solution, a first sub-contract and a second sub-contract with an associated relationship are respectively stored in storage areas with different security levels, and are used to process events with different privacy levels, thereby ensuring that data with a higher privacy level can be processed in a storage area with a higher security level, thereby improving the security of private data, avoiding the situation in which a local device processes data obtained from a blockchain due to a lower privacy level, resulting in the data being obtained by a node not on the blockchain, thereby improving the security of the local device in processing data on the blockchain.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of smart contracts, and in particular to a method and system for setting up a smart contract. Background Art

[0002] Blockchain has the characteristics of decentralization, openness, transparency and information immutability. Due to the openness and transparency of blockchain, data stored on the blockchain can be read by each node on the blockchain, but it cannot be read by nodes outside the blockchain.

[0003] If the data stored in the blockchain is private data, when the local node processes the private data, it is necessary to obtain the private data stored on the blockchain and then perform local processing. However, during the data processing process, the private data is usually read by nodes not on the blockchain due to the low privacy level of the local device. Summary of the invention

[0004] In view of this, the present application provides a method and system for setting up a smart contract, and its specific scheme is as follows:

[0005] A method for setting a smart contract, applied to a first electronic device, the first electronic device corresponding to a first node of a blockchain, comprising:

[0006] Loading a first subcontract into a first storage area, wherein the first subcontract is used to process a first category of events;

[0007] Loading a second subcontract into a second storage area, wherein the second subcontract is used to process a second category of events; wherein the first subcontract and the second subcontract are associated with each other;

[0008] The security level of the second storage area is higher than that of the first storage area, and the privacy level of the second category of events is higher than that of the first category of events.

[0009] Furthermore, loading the second sub-contract into the second storage area includes:

[0010] The second sub-contract is loaded into the second storage area through the first sub-contract.

[0011] Furthermore, it also includes:

[0012] In response to the event processing instruction, the event meets the second category of events;

[0013] Obtain the data to be processed through the second sub-contract;

[0014] Processing the data to be processed in the second storage area to obtain result data;

[0015] Encrypting the result data to obtain ciphertext data;

[0016] The encrypted data is stored in a read-write set through the second subcontract, wherein the read-write set is located in the first storage area.

[0017] Furthermore, obtaining the data to be processed through the second sub-contract includes:

[0018] Acquire basic data through the first subcontract, and send the basic data to the second storage area;

[0019] The second sub-contract obtains the data to be processed based on the basic data, wherein the data to be processed is encrypted data and the basic data is unencrypted data.

[0020] Furthermore, the second sub-contract obtains the data to be processed according to the basic data, including:

[0021] The second sub-contract obtains the data to be processed that matches the basic data from the blockchain.

[0022] Furthermore, it also includes:

[0023] Read the ciphertext data from the read-write set through the first subcontract;

[0024] The encrypted data is stored in the blockchain through the first sub-contract.

[0025] Furthermore, it also includes:

[0026] Obtaining a credible attestation report for proving the integrity of the second sub-contract;

[0027] The trusted proof report is stored in the blockchain.

[0028] Furthermore, obtaining a credible proof report for proving the integrity of the second sub-contract includes:

[0029] Generate verification information for verifying the second sub-contract through the first sub-contract;

[0030] The verification information is verified to obtain the credible certification report.

[0031] Further, the verifying the verification information to obtain the credible certification report includes:

[0032] Sending the verification information to a second electronic device, wherein the trust level of the second electronic device is greater than a preset level;

[0033] Receive the trustworthy certification report for the verification information sent by the second electronic device; wherein the trustworthy certification report is generated after the second electronic device verifies the legitimacy of the verification information.

[0034] A smart contract setting system is applied to a first electronic device, wherein the first electronic device corresponds to a first node of a blockchain, and includes:

[0035] A first loading unit, used to load a first subcontract into a first storage area, wherein the first subcontract is used to process a first category of events;

[0036] A second loading unit is used to load a second sub-contract into a second storage area, wherein the second sub-contract is used to process a second category of events, wherein the first sub-contract and the second sub-contract are associated with each other, the security level of the second storage area is higher than the security level of the first storage area, and the privacy level of the second category of events is higher than the privacy level of the first category of events.

[0037] It can be seen from the above technical scheme that the setting method and system of the smart contract disclosed in the present application are applied to the first electronic device, the first electronic device corresponds to the first node of the blockchain, the first subcontract is loaded into the first storage area, the first subcontract is used to process the first category event, the second subcontract is loaded into the second storage area, the second subcontract is used to process the second category event, wherein the first subcontract and the second subcontract have an associated relationship, the security level of the second storage area is higher than the security level of the first storage area, and the privacy level of the second category event is higher than the privacy level of the first category event. In this scheme, the first subcontract and the second subcontract with an associated relationship are stored in storage areas with different security levels respectively, and are used to process events with different privacy levels, ensuring that data with a higher privacy level can be processed in a storage area with a higher security level, improving the security of private data, avoiding the situation where the local device, when processing the data obtained from the blockchain, may have a lower privacy level and cause the data to be obtained by nodes not on the blockchain, and improving the security of the local device processing data on the blockchain. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0039] Figure 1 A flowchart of a method for setting a smart contract disclosed in an embodiment of the present application;

[0040] Figure 2 A flowchart of a method for setting a smart contract disclosed in an embodiment of the present application;

[0041] Figure 3 A flowchart of a method for setting a smart contract disclosed in an embodiment of the present application;

[0042] Figure 4 A flowchart of a method for setting a smart contract disclosed in an embodiment of the present application;

[0043] Figure 5 A schematic diagram of the structure of a smart contract setting system disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0044] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0045] The present application discloses a method for setting a smart contract, which is applied to a first electronic device, where the first electronic device corresponds to a first node of a blockchain. The flowchart of the method for setting a smart contract disclosed in this embodiment is as follows: Figure 1 As shown, including:

[0046] Step S11, loading a first sub-contract into a first storage area, where the first sub-contract is used to process a first category of events;

[0047] Step S12: load the second sub-contract into the second storage area, where the second sub-contract is used to process second category events, wherein the first sub-contract and the second sub-contract are associated with each other, the security level of the second storage area is higher than the security level of the first storage area, and the privacy level of the second category events is higher than the privacy level of the first category events.

[0048] Blockchain is used to store different data based on different nodes. For each node on the blockchain, the data on other nodes is visible. If the data stored on a node includes private data, it is also visible to other nodes, but invisible to nodes not on the blockchain.

[0049] If a local device that is a node on the blockchain wants to process the data stored on the blockchain, it must first obtain the data from the blockchain, then process the data and store it on the blockchain. However, in the process of the local device obtaining and processing the data on the blockchain, if the privacy level of the local device is low, a node not on the blockchain may obtain the data from the local device, resulting in data leakage.

[0050] In order to avoid the situation where local data is visible to nodes outside the blockchain during the process of data processing by the local device, this solution divides the smart contract on the local device that can process data stored in the blockchain into a first sub-contract and a second sub-contract. The first sub-contract and the second sub-contract constitute a complete smart contract.

[0051] The contracts for handling different categories of events in the smart contract are stored separately, the first subcontract is used to handle the first category of events, and the second subcontract is used to handle the second category of events, wherein the privacy level of the second category of events is higher than the privacy level of the first category of events.

[0052] That is, a privacy level is set for each event in advance, and different privacy levels corresponding to the event make the event correspond to the first category event or the second category event. For example, an event with a privacy level higher than the second level belongs to the second category event, and an event with a privacy level not higher than the second level belongs to the first category event.

[0053] The subcontract used to process the first category of events belongs to the first subcontract, and the subcontract used to process the second category of events belongs to the second subcontract. All subcontracts in the smart contract are classified according to the event categories they process, thereby obtaining the classified first subcontract and second subcontract.

[0054] The storage area of ​​the smart contract is divided into two parts, namely, a first storage area and a second storage area. The first storage area and the second storage area correspond to different security levels respectively. The security level of the second storage area is higher than the security level of the first storage area. That is, the second storage area is a trusted execution environment relative to the first storage area, and the first storage area is a non-trusted execution environment relative to the second storage area. Specifically, the first storage area can be a common memory storage area.

[0055] Since privacy data has a certain degree of privacy, it is necessary to ensure the security and reliability of the processing process when processing privacy data. Therefore, the second storage area with a high security level is loaded with a second sub-contract for processing events with a high privacy level, that is, the privacy data is processed in a trusted execution environment; the first storage area with a low security level is loaded with a first sub-contract for processing events with a low privacy level, that is, non-privacy data is processed in ordinary memory, which ensures that privacy data can be processed in the second storage area with a high security level, and non-privacy data does not need to be processed in the second storage area with a high security level, and it can be processed in the storage area with an ordinary security level.

[0056] Of course, non-privacy data can also be processed in the second storage area with a high security level. Non-privacy data is a first-category event, which requires first ensuring that the sub-contract for processing non-privacy data is loaded in the second storage area, so that non-privacy data can be processed in the second storage area with a high security level.

[0057] The setting method of the smart contract disclosed in this embodiment is applied to a first electronic device, the first electronic device corresponds to the first node of the blockchain, the first subcontract is loaded into the first storage area, the first subcontract is used to process the first category event, the second subcontract is loaded into the second storage area, the second subcontract is used to process the second category event, wherein the first subcontract and the second subcontract have an associated relationship, the security level of the second storage area is higher than the security level of the first storage area, and the privacy level of the second category event is higher than the privacy level of the first category event. In this scheme, the first subcontract and the second subcontract with an associated relationship are stored in storage areas with different security levels respectively, and are used to process events with different privacy levels, ensuring that data with a higher privacy level can be processed in a storage area with a higher security level, improving the security of private data, avoiding the situation where the local device, when processing data obtained from the blockchain, may have a lower privacy level and cause the data to be obtained by nodes not on the blockchain, and improving the security of the local device processing data on the blockchain.

[0058] This embodiment discloses a method for setting a smart contract, which is applied to a first electronic device, where the first electronic device corresponds to a first node of a blockchain. The flowchart of the method for setting a smart contract disclosed in this embodiment is as follows: Figure 2 As shown, including:

[0059] Step S21, loading a first sub-contract into a first storage area, where the first sub-contract is used to process a first category of events;

[0060] Step S22: load the second subcontract into the second storage area through the first subcontract; the second subcontract is used to process second category events; the first subcontract and the second subcontract are associated with each other; the security level of the second storage area is higher than the security level of the first storage area; and the privacy level of the second category events is higher than the privacy level of the first category events.

[0061] After the smart contract is divided into a first sub-contract and a second sub-contract, when the first sub-contract and the second sub-contract are loaded into a storage area, the first sub-contract can be directly loaded into the first storage area from the system of the first electronic device storing the smart contract, and then the second sub-contract can be loaded from the system into the second storage area through the first sub-contract, that is, the second sub-contract is loaded by the first sub-contract.

[0062] The process of loading the first sub-contract into the first storage area can be implemented by the first electronic device, and then the first sub-contract in the first storage area is initialized, and the second sub-contract is loaded during the process of initializing the first sub-contract.

[0063] At this time, it can be that: in the process of loading the first sub-contract into the first storage area through the first electronic device, the first program for loading the second sub-contract is also loaded into the first storage area at the same time. After the first sub-contract is loaded into the first storage area, the first sub-contract is initialized, and after the initialization is completed, the first sub-contract loads the second sub-contract from the system into the second storage area. When the first sub-contract is loaded into the first storage area through the first electronic device, the first program for loading the second sub-contract is loaded into the first storage area, and then the second sub-contract is directly loaded through the first sub-contract, which ensures that all information related to the smart contract in the first electronic device is loaded into the first storage area, avoiding the situation where part of the sub-contracts in the first sub-contract or the second sub-contract are lost during the loading process.

[0064] In addition, you can also:

[0065] The first sub-contract is loaded into the first storage area through the first electronic device, and the second sub-contract is loaded into the second storage area through the first electronic device.

[0066] The process of loading the first sub-contract and the process of loading the second sub-contract by the first electronic device may be performed simultaneously to ensure the efficiency of loading the sub-contracts; or, it may also be: the first electronic device first loads the first sub-contract to the first storage area, and then initializes the first sub-contract. During the initialization of the first sub-contract, the first electronic device loads the second sub-contract to the second storage area to ensure the speed of loading the sub-contract by the first electronic device, and avoid the speed occupation caused by loading two sub-contracts at the same time, resulting in reduced efficiency.

[0067] The setting method of the smart contract disclosed in this embodiment is applied to a first electronic device, the first electronic device corresponds to the first node of the blockchain, the first subcontract is loaded into the first storage area, the first subcontract is used to process the first category event, the second subcontract is loaded into the second storage area, the second subcontract is used to process the second category event, wherein the first subcontract and the second subcontract have an associated relationship, the security level of the second storage area is higher than the security level of the first storage area, and the privacy level of the second category event is higher than the privacy level of the first category event. In this scheme, the first subcontract and the second subcontract with an associated relationship are stored in storage areas with different security levels respectively, and are used to process events with different privacy levels, ensuring that data with a higher privacy level can be processed in a storage area with a higher security level, improving the security of private data, avoiding the situation where the local device, when processing data obtained from the blockchain, may have a lower privacy level and cause the data to be obtained by nodes not on the blockchain, and improving the security of the local device processing data on the blockchain.

[0068] This embodiment discloses a method for setting a smart contract, which is applied to a first electronic device, where the first electronic device corresponds to a first node of a blockchain. The flowchart of the method for setting a smart contract disclosed in this embodiment is as follows: Figure 3 As shown, including:

[0069] Step S31, loading a first sub-contract into a first storage area, where the first sub-contract is used to process a first category of events;

[0070] Step S32: Load the second subcontract into the second storage area. The second subcontract is used to process the second category of events. The first subcontract and the second subcontract are associated. The security level of the second storage area is higher than the security level of the first storage area. The privacy level of the second category of events is higher than the privacy level of the first category of events.

[0071] Step S33, in response to the event processing instruction, the event meets the second category event;

[0072] Step S34: Obtain the data to be processed through the second sub-contract;

[0073] Step S35, processing the data to be processed in the second storage area to obtain result data;

[0074] Step S36, encrypting the result data to obtain ciphertext data;

[0075] Step S37: Store the encrypted data in the read-write set through the second sub-contract, where the read-write set is located in the first storage area.

[0076] After the first sub-contract of the smart contract is loaded into the first storage area and the second sub-contract of the smart contract is loaded into the second storage area, the smart contract can respond to event processing instructions, wherein the event processing instructions are used to process the data to be processed.

[0077] If the event in the event processing instruction is a second category event, the data to be processed is obtained through the second sub-contract, and the second sub-contract processes the obtained data to be processed, wherein the second sub-contract processes the data to be processed in the second storage area to obtain the result data. Afterwards, the second sub-contract encrypts the result data in the second storage area to obtain the ciphertext data.

[0078] Since the privacy level of the second category events processed in the second storage area is higher than the privacy level of the first category events processed in the first storage area, the process of processing the data to be processed by the second subcontract in the second storage area is carried out in the storage area with a higher security level, and the processing of the data to be processed has a certain degree of privacy;

[0079] After the data to be processed is processed in the storage area with a higher security level, the result data is obtained. In order to ensure the privacy of the result data, the first electronic device will encrypt the result data through the second sub-contract to obtain ciphertext data, so that the data processed by the second sub-contract in the second storage area is ciphertext data. When it is stored, the actual result data will not be directly obtained by other nodes not on the blockchain. Even if other nodes not on the blockchain can obtain the data on the first electronic device, what they obtain is the encrypted ciphertext data, which ensures the privacy of the data to be processed after being processed by the second sub-contract in the second storage area.

[0080] In addition, after obtaining the ciphertext data, the ciphertext data is stored in the read-write set through the second subcontract, and the read-write set is located in the first storage area.

[0081] Among them, the read-write set is a read-write record, which is used to record which subcontract in which storage area has read or written what data at what time, and the read-write set is stored to record the read-write information. Since the read-write set only includes read-write records, and what is stored in the read-write set is the ciphertext data encrypted by the second subcontract, it does not include any specific information of private data. Therefore, there is no need to store the read-write set in the second storage area, and it can be directly stored in the first storage area, so that the read-write set can be directly stored in the blockchain by the first subcontract, and can be obtained by all nodes of the blockchain.

[0082] Further, if an event processing instruction is responded to, the event in the event processing instruction is a first category event.

[0083] The first sub-contract obtains the data to be processed of the event, processes the data to be processed in the first storage area to obtain result data, and stores the result data in the read-write set through the first sub-contract, so that when the read-write set is stored in the blockchain, it can be obtained by all nodes of the blockchain.

[0084] Among them, if the event in the event processing instruction is a first category event, the data to be processed for the first category event is processed in the first storage area through the first subcontract, and the result data obtained can be directly written into the read-write set without encryption. Since the privacy level of the first category event is lower than the privacy level of the second category event, and the security level of the first storage area is lower than the security level of the second storage area, only data that does not require privacy will be processed in the first storage area through the first subcontract. In the process of processing through the first subcontract, due to the low security level of the first storage area, unsafe factors may occur in the processing process, such as being obtained by other nodes not on the blockchain. Therefore, after the result data is processed by the first subcontract, it does not need to be encrypted. It is not private data, and the result data can be intuitively displayed in the blockchain.

[0085] Furthermore, after storing the read-write set in the first storage area, the first electronic device can read the ciphertext data from the read-write set through the first sub-contract and store the ciphertext data in the blockchain through the first sub-contract.

[0086] The ciphertext data obtained after being processed by the second sub-contract in the second storage area needs to pass through the first storage area before being stored in the blockchain. In addition, the second sub-contract in the second storage area obtains the ciphertext data after processing the data to be processed, and stores the ciphertext data in the read-write set located in the first storage area. That is, the ciphertext data is stored in the read-write set by the second sub-contract and then read and stored in the blockchain by the first sub-contract.

[0087] In addition, the second sub-contract in the second storage area needs to pass through the first storage area to read or write data. That is, when the second sub-contract in the second storage area reads data from the blockchain, the data needs to be stored in the first storage area, and then the second sub-contract in the second storage area needs to obtain it from the first storage area before it can process it in the second storage area; similarly, after the second sub-contract in the second storage area processes the data, if it wants to write the data into the blockchain, it needs to first store the data in the first storage area, and then store it from the first storage area to the blockchain.

[0088] Specifically, the second storage area can read and write data from the blockchain through the read-write set stored in the first storage area. Because the second storage area encrypts the data before storing it in the read-write set, the data read and written by the second storage area obtained by the first storage area or the blockchain are not the original data, but encrypted data.

[0089] Furthermore, the data to be processed is obtained through the second sub-contract, including:

[0090] The basic data is obtained through the first sub-contract and sent to the second storage area; the second sub-contract obtains the data to be processed based on the basic data, wherein the data to be processed is encrypted data and the basic data is unencrypted data.

[0091] Obtaining basic data through the first subcontract can be: directly obtaining basic data from the blockchain through the first subcontract, the basic data is plain text data, that is, the event corresponding to the basic data is a first category event, such as: the basic data can be: public data such as device number. The basic data is sent to the second storage area, and the second subcontract in the second storage area obtains the data to be processed based on the basic data.

[0092] Among them, the basic data is unencrypted data, and the data to be processed is encrypted data, that is, first obtain the unencrypted public data from the blockchain, and after the first sub-contract obtains the unencrypted public data, it sends it to the second storage area, and the second sub-contract in the second storage area obtains the data to be processed based on the unencrypted basic data. Specifically: the second sub-contract obtains the encrypted data to be processed that matches the basic data based on the unencrypted basic data. For example: if the basic data is the device number, the data to be processed is: the operation data of the device specified by the device number, etc.

[0093] Among them, the second sub-contract obtains the encrypted data to be processed that matches the basic data based on the basis. It can be: the second sub-contract obtains the encrypted data to be processed that matches the basic data from the blockchain based on the basic data, and the event corresponding to the data to be processed is a second category event; it can also be: the second sub-contract obtains the encrypted data to be processed that matches the basic data from the first electronic device locally based on the basic data.

[0094] The second sub-contract can perform a series of processing on the encrypted data to be processed only after obtaining the encrypted data to be processed, that is, the second sub-contract first decrypts the encrypted data to be processed, performs corresponding processing on it after decryption, and then encrypts the processed data after processing so that it can be encrypted and stored in the first electronic device or blockchain, thereby ensuring that the data stored in the first storage area and the blockchain are encrypted data. At the same time, encryption and decryption of data and data storage in the second storage area also ensure the privacy and security of a series of data processing processes in the second storage area.

[0095] The setting method of the smart contract disclosed in this embodiment is applied to a first electronic device, the first electronic device corresponds to the first node of the blockchain, the first subcontract is loaded into the first storage area, the first subcontract is used to process the first category event, the second subcontract is loaded into the second storage area, the second subcontract is used to process the second category event, wherein the first subcontract and the second subcontract have an associated relationship, the security level of the second storage area is higher than the security level of the first storage area, and the privacy level of the second category event is higher than the privacy level of the first category event. In this scheme, the first subcontract and the second subcontract with an associated relationship are stored in storage areas with different security levels respectively, and are used to process events with different privacy levels, ensuring that data with a higher privacy level can be processed in a storage area with a higher security level, improving the security of private data, avoiding the situation where the local device, when processing data obtained from the blockchain, may have a lower privacy level and cause the data to be obtained by nodes not on the blockchain, and improving the security of the local device processing data on the blockchain.

[0096] This embodiment discloses a method for setting a smart contract, which is applied to a first electronic device, where the first electronic device corresponds to a first node of a blockchain. The flowchart of the method for setting a smart contract disclosed in this embodiment is as follows: Figure 4 As shown, including:

[0097] Step S41, loading a first sub-contract into a first storage area, the first sub-contract being used to process a first category of events;

[0098] Step S42: Load the second subcontract into the second storage area, the second subcontract is used to process the second category of events, wherein the first subcontract and the second subcontract are associated, the security level of the second storage area is higher than the security level of the first storage area, and the privacy level of the second category of events is higher than the privacy level of the first category of events;

[0099] Step S43: Obtain a credible certification report for proving the integrity of the second sub-contract;

[0100] Step S44: Store the trusted proof report in the blockchain.

[0101] The trusted proof report is used to prove the integrity of the second sub-contract, that is, to prove that the second sub-contract is completely loaded into the second storage area, and that it can process the second category of events normally and safely, thereby ensuring the data protection of the second sub-contract in the second storage area for the second category of event processing process and results.

[0102] The trusted proof report is stored in the blockchain so that each node can clearly understand that the data processed by the second sub-contract in the second storage area is privacy-protected data, not real data.

[0103] Furthermore, obtaining a credible proof report for proving the integrity of the second sub-contract includes: generating verification information for verifying the second sub-contract through the first sub-contract, verifying the verification information, and obtaining a credible proof report.

[0104] That is, the verification information of the second sub-contract is first generated through the first sub-contract, and the node verifies the verification information to generate a credible proof report. Specifically, the node can be the first node, that is, the first node verifies the verification information locally;

[0105] It can also be external verification, that is, the first node sends the verification information generated by the first sub-contract to an external service, and the external service remotely verifies the verification information. Specifically, the first node sends the verification information to an external service provider, which is verified through the IAS service. After verification, a trusted proof report is generated and the trusted proof report is transmitted back to the first node.

[0106] That is: sending verification information to a second electronic device, wherein the trust level of the second electronic device is greater than a preset level; receiving a trustworthy certification report for the verification information sent by the second electronic device, wherein the trustworthy certification report is generated after the second electronic device verifies the legitimacy of the verification information.

[0107] The verification information generated by the first sub-contract may be: the code of the second sub-contract, or: the data originally stored in the second storage area.

[0108] Since the first sub-contract and the second sub-contract constitute a complete smart contract, when the first sub-contract has been loaded into the first storage area, the first sub-contract can clarify the second sub-contract based on the smart contract stored in the first electronic device, that is, it can determine what the code of the second sub-contract is. Therefore, the first sub-contract can generate verification information of the second sub-contract, that is, the code of the second sub-contract, and the first electronic device can determine whether the second sub-contract is complete based on the code of the second sub-contract.

[0109] In addition to the second sub-contract, the data stored in the second storage area also includes data obtained through the processing of the second sub-contract. The data obtained through the processing of the second sub-contract is used as verification information to determine whether the data processing process of the second sub-contract is complete, thereby determining whether the second sub-contract is complete and reliable.

[0110] Furthermore, the generation of a trusted proof report may be as follows: after the second sub-contract of the second storage area is initialized, a trusted proof report is generated to ensure the reliability of the trusted proof report.

[0111] The setting method of the smart contract disclosed in this embodiment is applied to a first electronic device, the first electronic device corresponds to the first node of the blockchain, the first subcontract is loaded into the first storage area, the first subcontract is used to process the first category event, the second subcontract is loaded into the second storage area, the second subcontract is used to process the second category event, wherein the first subcontract and the second subcontract have an associated relationship, the security level of the second storage area is higher than the security level of the first storage area, and the privacy level of the second category event is higher than the privacy level of the first category event. In this scheme, the first subcontract and the second subcontract with an associated relationship are stored in storage areas with different security levels respectively, and are used to process events with different privacy levels, ensuring that data with a higher privacy level can be processed in a storage area with a higher security level, improving the security of private data, avoiding the situation where the local device, when processing data obtained from the blockchain, may have a lower privacy level and cause the data to be obtained by nodes not on the blockchain, and improving the security of the local device processing data on the blockchain.

[0112] This embodiment discloses a smart contract setting system, which is applied to a first electronic device, and the first electronic device corresponds to a first node of a blockchain, wherein a structural diagram of the smart contract setting system is as follows: Figure 5 As shown, including:

[0113] The first loading unit 51 and the second loading unit 52 .

[0114] The first loading unit 51 is used to load the first sub-contract into the first storage area, and the first sub-contract is used to process the first category event;

[0115] The second loading unit 52 is used to load the second sub-contract into the second storage area, and the second sub-contract is used to process second category events, wherein the first sub-contract and the second sub-contract are associated with each other, the security level of the second storage area is higher than the security level of the first storage area, and the privacy level of the second category events is higher than the privacy level of the first category events.

[0116] Blockchain is used to store different data based on different nodes. For each node on the blockchain, the data on other nodes is visible. If the data stored on a node includes private data, it is also visible to other nodes, but invisible to nodes not on the blockchain.

[0117] If a local device that is a node on the blockchain wants to process the data stored on the blockchain, it must first obtain the data from the blockchain, then process the data and store it on the blockchain. However, in the process of the local device obtaining and processing the data on the blockchain, if the privacy level of the local device is low, a node not on the blockchain may obtain the data from the local device, resulting in data leakage.

[0118] In order to avoid the situation where local data is visible to nodes outside the blockchain during the process of data processing by the local device, this solution divides the smart contract on the local device that can process data stored in the blockchain into a first sub-contract and a second sub-contract. The first sub-contract and the second sub-contract constitute a complete smart contract.

[0119] The contracts for handling different categories of events in the smart contract are stored separately, the first subcontract is used to handle the first category of events, and the second subcontract is used to handle the second category of events, wherein the privacy level of the second category of events is higher than the privacy level of the first category of events.

[0120] That is, a privacy level is set for each event in advance, and different privacy levels corresponding to the event make the event correspond to the first category event or the second category event. For example, an event with a privacy level higher than the second level belongs to the second category event, and an event with a privacy level not higher than the second level belongs to the first category event.

[0121] The subcontract used to process the first category of events belongs to the first subcontract, and the subcontract used to process the second category of events belongs to the second subcontract. All subcontracts in the smart contract are classified according to the event categories they process, thereby obtaining the classified first subcontract and second subcontract.

[0122] The storage area of ​​the smart contract is divided into two parts, namely, a first storage area and a second storage area. The first storage area and the second storage area correspond to different security levels respectively. The security level of the second storage area is higher than the security level of the first storage area. That is, the second storage area is a trusted execution environment relative to the first storage area, and the first storage area is a non-trusted execution environment relative to the second storage area. Specifically, the first storage area can be a common memory storage area.

[0123] Since privacy data has a certain degree of privacy, it is necessary to ensure the security and reliability of the processing process when processing privacy data. Therefore, the second storage area with a high security level is loaded with a second sub-contract for processing events with a high privacy level, that is, the privacy data is processed in a trusted execution environment; the first storage area with a low security level is loaded with a first sub-contract for processing events with a low privacy level, that is, non-privacy data is processed in ordinary memory, which ensures that privacy data can be processed in the second storage area with a high security level, and non-privacy data does not need to be processed in the second storage area with a high security level, and it can be processed in the storage area with an ordinary security level.

[0124] Of course, non-privacy data can also be processed in the second storage area with a high security level. Non-privacy data is a first-category event, which requires first ensuring that the sub-contract for processing non-privacy data is loaded in the second storage area, so that non-privacy data can be processed in the second storage area with a high security level.

[0125] Furthermore, the second loading unit 52 loads the second sub-contract into the second storage area, including:

[0126] The second loading unit loads the second sub-contract into the second storage area through the first sub-contract.

[0127] After the smart contract is divided into a first sub-contract and a second sub-contract, when the first sub-contract and the second sub-contract are loaded into a storage area, the first sub-contract can be directly loaded into the first storage area from the system of the first electronic device storing the smart contract, and then the second sub-contract can be loaded from the system into the second storage area through the first sub-contract, that is, the second sub-contract is loaded by the first sub-contract.

[0128] The process of loading the first sub-contract into the first storage area can be implemented by the first electronic device, and then the first sub-contract in the first storage area is initialized, and the second sub-contract is loaded during the process of initializing the first sub-contract.

[0129] At this time, it can be that: in the process of loading the first sub-contract into the first storage area through the first electronic device, the first program for loading the second sub-contract is also loaded into the first storage area at the same time. After the first sub-contract is loaded into the first storage area, the first sub-contract is initialized, and after the initialization is completed, the first sub-contract loads the second sub-contract from the system into the second storage area. When the first sub-contract is loaded into the first storage area through the first electronic device, the first program for loading the second sub-contract is loaded into the first storage area, and then the second sub-contract is directly loaded through the first sub-contract, which ensures that all information related to the smart contract in the first electronic device is loaded into the first storage area, avoiding the situation where part of the sub-contracts in the first sub-contract or the second sub-contract are lost during the loading process.

[0130] In addition, you can also:

[0131] The first sub-contract is loaded into the first storage area through the first electronic device, and the second sub-contract is loaded into the second storage area through the first electronic device.

[0132] The process of loading the first sub-contract and the process of loading the second sub-contract by the first electronic device may be performed simultaneously to ensure the efficiency of loading the sub-contracts; or, it may also be: the first electronic device first loads the first sub-contract to the first storage area, and then initializes the first sub-contract. During the initialization of the first sub-contract, the first electronic device loads the second sub-contract to the second storage area to ensure the speed of loading the sub-contract by the first electronic device, and avoid the speed occupation caused by loading two sub-contracts at the same time, resulting in reduced efficiency.

[0133] Furthermore, the smart contract setting system may further include: a response unit, wherein:

[0134] The response unit is used to respond to an event processing instruction. The event meets the second category of events. The data to be processed is obtained through the second sub-contract, and the data to be processed is processed in the second storage area to obtain result data; the result data is encrypted to obtain ciphertext data, and the ciphertext data is stored in the read-write set through the second sub-contract, wherein the read-write set is located in the first storage area.

[0135] After the first sub-contract of the smart contract is loaded into the first storage area and the second sub-contract of the smart contract is loaded into the second storage area, the smart contract can respond to event processing instructions, wherein the event processing instructions are used to process the data to be processed.

[0136] If the event in the event processing instruction is a second category event, the data to be processed is obtained through the second sub-contract, and the second sub-contract processes the obtained data to be processed, wherein the second sub-contract processes the data to be processed in the second storage area to obtain the result data. Afterwards, the second sub-contract encrypts the result data in the second storage area to obtain the ciphertext data.

[0137] Since the privacy level of the second category events processed in the second storage area is higher than the privacy level of the first category events processed in the first storage area, the process of processing the data to be processed by the second subcontract in the second storage area is carried out in the storage area with a higher security level, and the processing of the data to be processed has a certain degree of privacy;

[0138] After the data to be processed is processed in the storage area with a higher security level, the result data is obtained. In order to ensure the privacy of the result data, the first electronic device will encrypt the result data through the second sub-contract to obtain ciphertext data, so that the data processed by the second sub-contract in the second storage area is ciphertext data. When it is stored, the actual result data will not be directly obtained by other nodes not on the blockchain. Even if other nodes not on the blockchain can obtain the data on the first electronic device, what they obtain is the encrypted ciphertext data, which ensures the privacy of the data to be processed after being processed by the second sub-contract in the second storage area.

[0139] In addition, after obtaining the ciphertext data, the ciphertext data is stored in the read-write set through the second subcontract, and the read-write set is located in the first storage area.

[0140] Among them, the read-write set is a read-write record, which is used to record which subcontract in which storage area has read or written what data at what time, and the read-write set is stored to record the read-write information. Since the read-write set only includes read-write records, and what is stored in the read-write set is the ciphertext data encrypted by the second subcontract, it does not include any specific information of private data. Therefore, there is no need to store the read-write set in the second storage area, and it can be directly stored in the first storage area, so that the read-write set can be directly stored in the blockchain by the first subcontract, and can be obtained by all nodes of the blockchain.

[0141] Further, if an event processing instruction is responded to, the event in the event processing instruction is a first category event.

[0142] The first sub-contract obtains the data to be processed of the event, processes the data to be processed in the first storage area to obtain result data, and stores the result data in the read-write set through the first sub-contract, so that when the read-write set is stored in the blockchain, it can be obtained by all nodes of the blockchain.

[0143] Among them, if the event in the event processing instruction is a first category event, the data to be processed for the first category event is processed in the first storage area through the first subcontract, and the result data obtained can be directly written into the read-write set without encryption. Since the privacy level of the first category event is lower than the privacy level of the second category event, and the security level of the first storage area is lower than the security level of the second storage area, only data that does not require privacy will be processed in the first storage area through the first subcontract. In the process of processing through the first subcontract, due to the low security level of the first storage area, unsafe factors may occur in the processing process, such as being obtained by other nodes not on the blockchain. Therefore, after the result data is processed by the first subcontract, it does not need to be encrypted. It is not private data, and the result data can be intuitively displayed in the blockchain.

[0144] Furthermore, after storing the read-write set in the first storage area, the first electronic device can read the ciphertext data from the read-write set through the first sub-contract and store the ciphertext data in the blockchain through the first sub-contract.

[0145] The ciphertext data obtained after being processed by the second sub-contract in the second storage area needs to pass through the first storage area before being stored in the blockchain. In addition, the second sub-contract in the second storage area obtains the ciphertext data after processing the data to be processed, and stores the ciphertext data in the read-write set located in the first storage area. That is, the ciphertext data is stored in the read-write set by the second sub-contract and then read and stored in the blockchain by the first sub-contract.

[0146] In addition, the second sub-contract in the second storage area needs to pass through the first storage area to read or write data. That is, when the second sub-contract in the second storage area reads data from the blockchain, the data needs to be stored in the first storage area, and then the second sub-contract in the second storage area needs to obtain it from the first storage area before it can process it in the second storage area; similarly, after the second sub-contract in the second storage area processes the data, if it wants to write the data into the blockchain, it needs to first store the data in the first storage area, and then store it from the first storage area to the blockchain.

[0147] Specifically, the second storage area can read and write data from the blockchain through the read-write set stored in the first storage area. Because the second storage area encrypts the data before storing it in the read-write set, the data read and written by the second storage area obtained by the first storage area or the blockchain are not the original data, but encrypted data.

[0148] Furthermore, the data to be processed is obtained through the second sub-contract, including:

[0149] The basic data is obtained through the first sub-contract and sent to the second storage area; the second sub-contract obtains the data to be processed based on the basic data, wherein the data to be processed is encrypted data and the basic data is unencrypted data.

[0150] Obtaining basic data through the first subcontract can be: directly obtaining basic data from the blockchain through the first subcontract, the basic data is plain text data, that is, the event corresponding to the basic data is a first category event, such as: the basic data can be: public data such as device number. The basic data is sent to the second storage area, and the second subcontract in the second storage area obtains the data to be processed based on the basic data.

[0151] Among them, the basic data is unencrypted data, and the data to be processed is encrypted data, that is, first obtain the unencrypted public data from the blockchain, and after the first sub-contract obtains the unencrypted public data, it sends it to the second storage area, and the second sub-contract in the second storage area obtains the data to be processed based on the unencrypted basic data. Specifically: the second sub-contract obtains the encrypted data to be processed that matches the basic data based on the unencrypted basic data. For example: if the basic data is the device number, the data to be processed is: the operation data of the device specified by the device number, etc.

[0152] Among them, the second sub-contract obtains the encrypted data to be processed that matches the basic data based on the basis. It can be: the second sub-contract obtains the encrypted data to be processed that matches the basic data from the blockchain based on the basic data, and the event corresponding to the data to be processed is a second category event; it can also be: the second sub-contract obtains the encrypted data to be processed that matches the basic data from the first electronic device locally based on the basic data.

[0153] The second sub-contract can perform a series of processing on the encrypted data to be processed only after obtaining the encrypted data to be processed, that is, the second sub-contract first decrypts the encrypted data to be processed, performs corresponding processing on it after decryption, and then encrypts the processed data after processing so that it can be encrypted and stored in the first electronic device or blockchain, thereby ensuring that the data stored in the first storage area and the blockchain are encrypted data. At the same time, encryption and decryption of data and data storage in the second storage area also ensure the privacy and security of a series of data processing processes in the second storage area.

[0154] Furthermore, the smart contract setting system disclosed in this embodiment may also include: an acquisition unit, wherein:

[0155] The acquisition unit is used to obtain a trusted proof report for proving the integrity of the second sub-contract; and store the trusted proof report in the blockchain.

[0156] The trusted proof report is used to prove the integrity of the second sub-contract, that is, to prove that the second sub-contract is completely loaded into the second storage area, and that it can process the second category of events normally and safely, thereby ensuring the data protection of the second sub-contract in the second storage area for the second category of event processing process and results.

[0157] The trusted proof report is stored in the blockchain so that each node can clearly understand that the data processed by the second sub-contract in the second storage area is privacy-protected data, not real data.

[0158] Furthermore, obtaining a credible proof report for proving the integrity of the second sub-contract includes: generating verification information for verifying the second sub-contract through the first sub-contract, verifying the verification information, and obtaining a credible proof report.

[0159] That is, the verification information of the second sub-contract is first generated through the first sub-contract, and the node verifies the verification information to generate a credible proof report. Specifically, the node can be the first node, that is, the first node verifies the verification information locally;

[0160] It can also be external verification, that is, the first node sends the verification information generated by the first sub-contract to an external service, and the external service remotely verifies the verification information. Specifically, the first node sends the verification information to an external service provider, which is verified through the IAS service. After verification, a trusted proof report is generated and the trusted proof report is transmitted back to the first node.

[0161] That is: sending verification information to a second electronic device, wherein the trust level of the second electronic device is greater than a preset level; receiving a trustworthy certification report for the verification information sent by the second electronic device, wherein the trustworthy certification report is generated after the second electronic device verifies the legitimacy of the verification information.

[0162] The verification information generated by the first sub-contract may be: the code of the second sub-contract, or: the data originally stored in the second storage area.

[0163] Since the first sub-contract and the second sub-contract constitute a complete smart contract, when the first sub-contract has been loaded into the first storage area, the first sub-contract can clarify the second sub-contract based on the smart contract stored in the first electronic device, that is, it can determine what the code of the second sub-contract is. Therefore, the first sub-contract can generate verification information of the second sub-contract, that is, the code of the second sub-contract, and the first electronic device can determine whether the second sub-contract is complete based on the code of the second sub-contract.

[0164] In addition to the second sub-contract, the data stored in the second storage area also includes data obtained through the processing of the second sub-contract. The data obtained through the processing of the second sub-contract is used as verification information to determine whether the data processing process of the second sub-contract is complete, thereby determining whether the second sub-contract is complete and reliable.

[0165] Furthermore, the generation of a trusted proof report may be as follows: after the second sub-contract of the second storage area is initialized, a trusted proof report is generated to ensure the reliability of the trusted proof report.

[0166] The first electronic device disclosed in this embodiment corresponds to the first node of the blockchain, and the first subcontract is loaded into the first storage area, and the first subcontract is used to process the first category of events, and the second subcontract is loaded into the second storage area, and the second subcontract is used to process the second category of events, wherein the first subcontract and the second subcontract have an associated relationship, the security level of the second storage area is higher than the security level of the first storage area, and the privacy level of the second category of events is higher than the privacy level of the first category of events. In this solution, the first subcontract and the second subcontract with an associated relationship are stored in storage areas with different security levels, respectively, and are used to process events with different privacy levels, ensuring that data with a higher privacy level can be processed in a storage area with a higher security level, improving the security of private data, avoiding the situation in which the local device, when processing data obtained from the blockchain, may have a lower privacy level and cause the data to be obtained by nodes not on the blockchain, and improving the security of the local device in processing data on the blockchain.

[0167] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0168] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0169] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0170] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for setting a smart contract, applied to a first electronic device, the first electronic device corresponding to a first node of a blockchain, comprising: Loading a first subcontract into a first storage area, wherein the first subcontract is used to process a first category of events; Loading a second subcontract into a second storage area, wherein the second subcontract is used to process a second category of events; wherein the first subcontract and the second subcontract are associated with each other; and the first subcontract and the second subcontract constitute a complete smart contract; Wherein, the security level of the second storage area is higher than the security level of the first storage area, and the privacy level of the second category of events is higher than the privacy level of the first category of events; In response to the event processing instruction, the event meets the second category event; Obtain the data to be processed through the second sub-contract; The data to be processed is processed in the second storage area to obtain result data.

2. The method according to claim 1, wherein: The step of loading the second sub-contract into the second storage area includes: The second sub-contract is loaded into the second storage area through the first sub-contract.

3. The method according to claim 1, wherein: Also includes: Encrypting the result data to obtain ciphertext data; The encrypted data is stored in a read-write set through the second subcontract, wherein the read-write set is located in the first storage area.

4. The method according to claim 3, wherein: The obtaining the data to be processed through the second sub-contract includes: Acquire basic data through the first subcontract, and send the basic data to the second storage area; The second sub-contract obtains the data to be processed based on the basic data, wherein the data to be processed is encrypted data and the basic data is unencrypted data.

5. The method according to claim 4, wherein: The second sub-contract obtains the data to be processed according to the basic data, including: The second sub-contract obtains the data to be processed that matches the basic data from the blockchain.

6. The method according to claim 3, wherein: Also includes: Read the ciphertext data from the read-write set through the first subcontract; The encrypted data is stored in the blockchain through the first sub-contract.

7. The method according to claim 1, wherein: Also includes: Obtaining a credible attestation report for proving the integrity of the second sub-contract; The trusted proof report is stored in the blockchain.

8. The method according to claim 7, wherein: The obtaining of a credible proof report for proving the integrity of the second sub-contract includes: Generate verification information for verifying the second sub-contract through the first sub-contract; The verification information is verified to obtain the credible certification report.

9. The method according to claim 8, wherein: The verifying the verification information to obtain the credible certification report includes: Sending the verification information to a second electronic device, wherein the trust level of the second electronic device is greater than a preset level; Receive the trustworthy certification report for the verification information sent by the second electronic device; wherein the trustworthy certification report is generated after the second electronic device verifies the legitimacy of the verification information.

10. A smart contract setting system, applied to a first electronic device, the first electronic device corresponding to a first node of a blockchain, comprising: A first loading unit, used to load a first subcontract into a first storage area, wherein the first subcontract is used to process a first category of events; A second loading unit is used to load a second subcontract into a second storage area, wherein the second subcontract is used to process a second category of events, wherein the first subcontract and the second subcontract are associated with each other, and the first subcontract and the second subcontract constitute a complete smart contract; the security level of the second storage area is higher than the security level of the first storage area, and the privacy level of the second category of events is higher than the privacy level of the first category of events; In response to the event processing instruction, the event meets the second category event; Obtain the data to be processed through the second sub-contract; The data to be processed is processed in the second storage area to obtain result data.

Citation Information

Patent Citations

  • Method for realizing privacy protection in block chain, node and storage medium

    CN110008737A