Uplink transaction data state query method, related device and medium
By using a trusted execution environment to replace the bypass node verification of the Merkle tree in blockchain transaction processing, the problems of large storage space usage and low verification efficiency are solved, and efficient data verification and security assurance are achieved.
Patent Information
- Application Number
- CN202310361840.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-30
- Publication Date
- 2024-10-01
AI Technical Summary
In existing blockchain transaction processing, the object terminal needs to save a large number of bypass nodes on the Merkel tree for verification, which results in large storage space usage and a large amount of calculations in the verification process, resulting in low efficiency.
The trusted execution environment is used to replace the bypass node verification method of the Merkel tree. The transaction data status is written into the state storage space, and when necessary, it is obtained and signed from the storage space through the trusted execution environment and sent to the object terminal for verification. Signing avoids the process of saving bypass nodes and layer-by-layer verification.
It reduces the storage space occupied, improves the verification efficiency of query status reliability, and ensures the authenticity and security of the data.
Smart Images

Figure CN118733640A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of blockchain, and in particular to a method for querying the status of transaction data on a blockchain, a related device, and a medium. Background Art
[0002] In the current blockchain transaction processing, when the object terminal generates a transaction that needs to be on-chain, the transaction is entrusted to the blockchain node to generate a block based on the transaction so as to record it on the blockchain. After the transaction is on-chain, the transaction data status changes. For example, after the transaction of employee A reimbursing an electronic invoice at enterprise B is on-chain, the number of resources of enterprise B will change. In the prior art, the blockchain node maintains a Merkle tree for various transaction data states. The summary of various transaction data states is used as the bottom node of the Merkle tree. Every two adjacent lower nodes of the Merkle tree perform summary operations to generate an upper node until the Merkle tree root is generated. Afterwards, when the object needs to query the relevant data status, the blockchain node returns the queried data status to the object. The blockchain node also returns the summary value of the data status to all bypass nodes required to generate the Merkle tree root upward in the Merkle tree, so that the object terminal can use these bypass nodes to verify the reliability of the returned data status.
[0003] In the above technology, the object terminal needs to save all bypass nodes used for verification on the Merkle tree, which takes up a lot of storage space. At the same time, the process of using bypass nodes to verify the Merkle tree root layer by layer is computationally intensive and the verification process is slow. Summary of the invention
[0004] The disclosed embodiments provide a method for querying the status of transaction data on a chain, a related device and a medium, which can reduce the occupancy of storage space and improve the verification efficiency of the reliability of the query status.
[0005] According to one aspect of the present disclosure, a method for querying the status of on-chain transaction data is provided, comprising:
[0006] Record the target transaction on the blockchain;
[0007] Determining a target transaction data state after recording the target transaction on the blockchain;
[0008] Writing the target transaction data state into a state storage space through a trusted execution environment;
[0009] In response to obtaining a status request for the target transaction data status from the target terminal, obtaining the target transaction data status from the state storage space through the trusted execution environment, and signing the target transaction data status;
[0010] The target transaction data status and the signature are sent to the object terminal so that the object terminal can verify the signature.
[0011] According to one aspect of the present disclosure, a device for querying the status of uplink transaction data is provided, comprising:
[0012] The on-chain unit is used to record the target transaction on the blockchain;
[0013] A first determining unit, configured to determine a target transaction data state after recording the target transaction on the blockchain;
[0014] A writing unit, used for writing the target transaction data state into the state storage space through a trusted execution environment;
[0015] an acquiring unit, configured to, in response to a status request for the target transaction data status acquired from the object terminal, acquire the target transaction data status from the status storage space through the trusted execution environment, and sign the target transaction data status;
[0016] A sending unit is used to send the target transaction data status and the signature to the object terminal so that the object terminal can verify the signature.
[0017] Optionally, the target transaction data state includes a state key and a state value; the state request includes the state key;
[0018] The acquisition unit is specifically used for:
[0019] The state value corresponding to the state key in the state request is obtained from the state storage space through the trusted execution environment, so as to integrate the state key and the state value into the target transaction data state.
[0020] Optionally, the trusted execution environment stores a key for encrypting the target transaction data state;
[0021] The writing unit is specifically used for:
[0022] Acquire the key stored in the trusted execution environment; encrypt the state key and the state value with the key, and write the encrypted state key and the encrypted state value into the state storage space;
[0023] The acquisition unit is specifically used for:
[0024] Through the trusted execution environment, the state key in the state request is encrypting with the key to obtain the encrypted state key; the encrypted state value corresponding to the encrypted state key is obtained from the state storage space; and the encrypted state value is decrypted with the key to obtain the state value.
[0025] Optionally, the key includes multiple keys corresponding to multiple object identifiers;
[0026] The writing unit is specifically used for:
[0027] Obtain the object identifier corresponding to the target transaction; encrypt the state key and the state value using the key corresponding to the object identifier;
[0028] Obtaining the object identifier corresponding to the status request; encrypting the status key in the status request with the key corresponding to the object identifier;
[0029] The encrypted state value is decrypted using the key corresponding to the object identifier.
[0030] Optionally, the state key includes a target data type corresponding to the target transaction data state, and a target object corresponding to the target transaction data state;
[0031] The acquisition unit is specifically used for:
[0032] Acquiring, through the trusted execution environment, a transaction data state of the target data type in the state storage space;
[0033] In the transaction data state of the target data type, the transaction data state of the target object is acquired, and the state value is taken out from the transaction data state of the target object.
[0034] Optionally, the writing unit is specifically used for:
[0035] Writing transaction data states of the same data type into the same partition address in the state storage space through a trusted execution environment, the transaction data states including the target transaction data state;
[0036] The acquisition unit is specifically used for:
[0037] The partition address corresponding to the target data type is determined through the trusted execution environment, and the transaction data state is read from the partition address.
[0038] Optionally, the acquiring unit is specifically used for:
[0039] Obtaining a digest algorithm and a private key of the trusted execution environment; generating a first digest of the target transaction data state using the digest algorithm; encrypting the first digest using the private key of the trusted execution environment to obtain the signature;
[0040] The signing of the target transaction data state includes: generating a first summary of the target transaction data state using the summary algorithm; obtaining a public key of the trusted execution environment; decrypting the signature using the public key to obtain a second summary; and verifying the signature based on a comparison of the first summary and the second summary.
[0041] Optionally, the acquiring unit is specifically used for:
[0042] receiving a first packet from the target terminal, the first packet having a plurality of status requests for a plurality of transaction data states, wherein the plurality of transaction data states include the target transaction data state;
[0043] Acquire the plurality of transaction data states from the state storage space through the trusted execution environment, and sign the plurality of transaction data states;
[0044] The sending unit is specifically used for:
[0045] The plurality of transaction data states and the signature are packaged into a second package and sent to the target terminal.
[0046] Optionally, the first packet is generated by the target terminal in the following manner:
[0047] Obtaining a read condition of a status read function in an object contract of the object terminal;
[0048] According to the reading condition, determining a plurality of transaction data states that need to be read;
[0049] The plurality of transaction data states are packaged into the first package.
[0050] Optionally, the acquiring unit is specifically used for:
[0051] receiving a plurality of status requests for a plurality of transaction data states from the object terminal, wherein each of the status requests has an object identifier, and the plurality of transaction data states include the target transaction data state;
[0052] Put the status request corresponding to each object identifier into a queue corresponding to the object identifier;
[0053] In response to determining that the queue satisfies a predetermined condition, the status request in the queue is discharged, and for the discharged status request, the corresponding transaction data status is obtained from the state storage space through the trusted execution environment, and the obtained transaction data status is signed;
[0054] The sending unit is specifically used for:
[0055] The acquired transaction data status and the signature are packed into a third packet, and sent to the object terminal corresponding to the object identifier.
[0056] Optionally, determining that the queue meets a predetermined condition includes:
[0057] If the number of status requests included in the queue reaches a first threshold, determining that the queue meets a predetermined condition;
[0058] If the number of status requests included in the queue does not reach the first threshold, but the time difference between the current time and the time when the queue was last discharged reaches the second threshold, it is determined that the queue meets the predetermined condition.
[0059] Optionally, the state storage space includes a plurality of state storage spaces corresponding to transaction types, and the state request includes the transaction type;
[0060] The writing unit is specifically used to: determine the transaction type corresponding to the target transaction data state through the trusted execution environment; write the target transaction data state into the state storage space corresponding to the transaction type;
[0061] The acquisition unit is specifically configured to: acquire the transaction type from the status request; and acquire the target transaction data state from the status storage space corresponding to the transaction type through the trusted execution environment.
[0062] Optionally, the trusted execution environment includes multiple trusted execution environments;
[0063] The writing unit is specifically used to: write the target transaction data state into the state storage space of each of the multiple trusted execution environments through the multiple trusted execution environments;
[0064] The acquisition unit is specifically used to: acquire the target transaction data state from the state storage space of each of the multiple trusted execution environments through the multiple trusted execution environments, and sign the target transaction data state;
[0065] The sending unit is specifically used to: have the multiple trusted execution environments send the target transaction data status and the signature generated by each of them to the object terminal, so that the object terminal verifies the target transaction data status and the signature obtained by the multiple trusted execution environments.
[0066] Optionally, the verifying the target transaction data status and the signature obtained based on the multiple trusted execution environments includes:
[0067] Performing sub-signature verification based on the target transaction data state and the signature obtained by the single trusted execution environment;
[0068] If the number of successful sub-verifications is greater than the number of failed sub-verifications, then the verification is determined to be successful.
[0069] Optionally, the trusted execution environment includes multiple trusted execution environments;
[0070] The writing unit is specifically used to: write the target transaction data state into the state storage space of each of the multiple trusted execution environments through the multiple trusted execution environments;
[0071] The acquisition unit is specifically used to: select a target trusted execution environment from multiple trusted execution environments based on the processing speed of the trusted execution environment and the number of queued status requests; obtain the target transaction data state from the state storage space through the target trusted execution environment, and sign the target transaction data state.
[0072] Optionally, the acquiring unit is specifically used for:
[0073] Determining a ratio of a processing speed of the trusted execution environment to a number of queued state requests;
[0074] Based on the ratio of the plurality of trusted execution environments, a target trusted execution environment is selected from the plurality of trusted execution environments.
[0075] According to one aspect of the present disclosure, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned on-chain transaction data status query method when executing the computer program.
[0076] According to one aspect of the present disclosure, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the method for querying the status of on-chain transaction data as described above is implemented.
[0077] According to one aspect of the present disclosure, a computer program product is provided, which includes a computer program, and the computer program is read and executed by a processor of a computer device, so that the computer device executes the on-chain transaction data status query method as described above.
[0078] In the disclosed embodiment, the bypass node verification method of the Merkle tree is replaced by a trusted execution environment. After the transaction is on-chain, the trusted execution environment immediately writes the data status after the transaction is completed into the state storage space. The characteristic of the trusted execution environment is that the calculation and operation of the data therein are protected by hardware isolation, and the hardware logic executed by it is solidified and cannot be tampered with. Therefore, cheating will not occur, and the transaction data status recorded by it must be true. When the object terminal wants to query a state, it queries through the trusted execution environment, and the characteristics of the hardware logic solidification and hardware isolation of the trusted execution environment determine that the query process cannot cheat, and the authenticity of the query result is guaranteed. The trusted execution environment signs the queried state. If the object terminal verifies that the signature passes, the reliability of the queried state is ensured, and the purpose of not using the Merkle tree to prove and also ensuring security is achieved. This scheme does not need to save all bypass nodes used for verification on the Merkle tree, which reduces the occupancy of storage space. At the same time, it does not need to use bypass nodes to verify the Merkle tree root layer by layer, which reduces the amount of calculation and improves the verification efficiency of the reliability of the query state.
[0079] Other features and advantages of the present disclosure will be described in the following description, and partly become apparent from the description, or understood by practicing the present disclosure. The purpose and other advantages of the present disclosure can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0080] The accompanying drawings are used to provide further understanding of the technical solution of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the technical solution of the present disclosure and do not constitute a limitation on the technical solution of the present disclosure.
[0081] Figure 1 It is a system architecture diagram of a system to which the method for querying the status of on-chain transaction data according to an embodiment of the present disclosure is applied;
[0082] Figure 2A -D is a schematic diagram of the application of the on-chain transaction data status query method in the resource processing strategy recommendation scenario according to an embodiment of the present disclosure;
[0083] Figure 3 is a flowchart of a method for querying the status of on-chain transaction data according to an embodiment of the present disclosure;
[0084] Figure 4A Shows Figure 3 A schematic diagram of the arrangement of multiple transaction data states in step 330 in the state storage space;
[0085] Figure 4B An exemplary structure of a status request in an embodiment of the present disclosure is shown;
[0086] Figure 4C An exemplary structure of a response received by the target terminal in an embodiment of the present disclosure is shown;
[0087] Figure 5 is a flowchart of a method for querying the status of on-chain transaction data according to another embodiment of the present disclosure;
[0088] Fig. 6A Shows Figure 3 Another schematic diagram of the arrangement of multiple transaction data states in step 330 in the state storage space;
[0089] Figure 6B An exemplary structure of a status request in another embodiment of the present disclosure is shown;
[0090] Figure 6C An exemplary structure of a response received by a target terminal in another embodiment of the present disclosure is shown;
[0091] Figure 7 is a flowchart of a method for querying the status of on-chain transaction data according to another embodiment of the present disclosure;
[0092] Fig. 8A Shows Figure 7 A schematic diagram of the first package of step 710 and the second package of step 730;
[0093] Figure 8B Shows Figure 7 Another schematic diagram of the first package of step 710 and the second package of step 730;
[0094] Fig. 9 Shows Figure 3 A schematic diagram of step 340;
[0095] Fig.10 is a flowchart of a method for querying the status of on-chain transaction data according to another embodiment of the present disclosure;
[0096] Fig.11A Shows Fig.10 A schematic diagram of queuing and packing;
[0097] Fig. 11B Shows Fig.10 Another schematic diagram of queuing and packing in ;
[0098] Fig.12 is a flowchart of a method for querying the status of on-chain transaction data according to another embodiment of the present disclosure;
[0099] Fig.13 Shows Fig.12 A schematic diagram of obtaining the target transaction data status according to the transaction type;
[0100] Fig.14 is a flowchart of a method for querying the status of on-chain transaction data according to another embodiment of the present disclosure;
[0101] Fig.15 Shows Fig.14 A schematic diagram of obtaining a target transaction data state according to multiple trusted execution environments;
[0102] Fig.16 is a flowchart of a method for querying the status of on-chain transaction data according to another embodiment of the present disclosure;
[0103] Fig.17 Detailed diagram of the implementation of the on-chain transaction data status query method of the embodiment of the present disclosure;
[0104] Fig.18 is a block diagram of an on-chain transaction data status query device according to an embodiment of the present disclosure;
[0105] Fig.19 is a structural diagram of an object terminal according to an embodiment of the present disclosure;
[0106] Fig. 20 is a structural diagram of a server according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0107] In order to make the purpose, technical solution and advantages of the present disclosure more clear, the present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not used to limit the present disclosure.
[0108] Before further describing the embodiments of the present disclosure in detail, the nouns and terms involved in the embodiments of the present disclosure are described. The nouns and terms involved in the embodiments of the present disclosure are subject to the following interpretations:
[0109] Blockchain: Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of information, which is used to verify the validity of the information (anti-counterfeiting) and associate with the previous block.
[0110] Smart contract: It is a piece of code written on the blockchain. Once the terms of the execution contract are triggered in the blockchain at a certain time, the code will be automatically executed.
[0111] Trusted Execution Environment (TEE): Protects operations and calculations involving private data through hardware isolation. Without cracking the hardware, attackers cannot directly read private data and system keys, thereby ensuring the confidentiality of the data. At the same time, attackers cannot tamper with detection through solidified hardware logic and hardware level, thereby ensuring that the operation process of the relevant system is not maliciously tampered with.
[0112] In the current blockchain transaction processing, when the object terminal generates a transaction that needs to be on-chain, the transaction is entrusted to the blockchain node to generate a block based on the transaction so as to record it on the blockchain. After the transaction is on-chain, the transaction data status changes. For example, after the transaction of employee A reimbursing an electronic invoice at enterprise B is on-chain, the number of resources of enterprise B will change. In the prior art, the blockchain node maintains a Merkle tree for various transaction data states. The summary of various transaction data states is used as the bottom node of the Merkle tree. Every two adjacent lower nodes of the Merkle tree perform summary operations to generate an upper node until the Merkle tree root is generated. Afterwards, when the object needs to query the relevant data status, the blockchain node returns the queried data status to the object. The blockchain node also returns the summary value of the data status to all bypass nodes required to generate the Merkle tree root upward in the Merkle tree, so that the object terminal can use these bypass nodes to verify the reliability of the returned data status.
[0113] In the above technology, the object terminal needs to save all bypass nodes used for verification on the Merkle tree, which takes up a lot of storage space. At the same time, the process of using bypass nodes to verify the Merkle tree root layer by layer is computationally intensive and the verification process is slow.
[0114] System architecture and scenario description of the application of the embodiments of the present disclosure
[0115] Figure 1 It is a system architecture diagram applied by the on-chain transaction data status query method according to an embodiment of the present disclosure, which includes an object terminal and a blockchain node.
[0116] The object terminal is a lightweight node connected to the blockchain node. The blockchain node refers to the node that generates blocks and records them on the blockchain. A lightweight node refers to a node that does not maintain data on the blockchain itself. It generates transactions to be uploaded to the blockchain and entrusts the blockchain node to upload them to the blockchain. After the transactions are uploaded to the blockchain, the blockchain node will not send all the uploaded data to the lightweight node. Only when the lightweight node needs to verify whether the transactions to be uploaded to the blockchain generated by itself are correctly uploaded to the blockchain, will the relevant verification information be sent to the lightweight node. Lightweight nodes include desktop computers, laptops, mobile phones, personal digital assistants (PDAs), vehicle-mounted terminals, dedicated terminals, servers and other forms. It can be a single device or a collection of multiple devices. In addition, the object terminal contains an accounting program, which is a separate binary executable program. It is a computer program used to obtain a transaction or transaction data status query request, pass the transaction or transaction data status query request to the blockchain node, and verify the correctness of the transaction data status returned by the blockchain node in processing the transaction data status request, so as to return a correct and reliable transaction data status query result to the object. A transaction refers to an event that needs to be put on the chain. For example, the event of an object reimbursing an electronic invoice needs to be put on the chain, which is a transaction; object A transferring 100 resources to object B is also a transaction. When a transaction is executed correctly, it will cause a change in the transaction data state, causing the transaction data to be converted from one state to another. For example, employee X reimburses an electronic invoice at enterprise Y, causing the resource value of enterprise Y to change. The resource value of enterprise Y is a transaction data state. Object A transfers 100 resources to object B, causing the resource value of object A to change. The resource value of object A is also a transaction data state. When an object needs to know the changed transaction data state, it must make a transaction data state query request. A transaction data state query request refers to a request to query the transaction data state. A transaction data state query request can be a request to query the resource value of a resource pool, logistics information, etc.
[0117] A blockchain node can be an independent device, such as a separate computer or server, or a part of an independent device, such as a virtual machine partitioned from a server. The blockchain node contains an accounting program, which is a separate binary executable program and is a computer program required to maintain the blockchain and package and verify transactions. The accounting program receives multiple transactions from the object terminal, executes the transaction, packages multiple transactions into transaction blocks, and reaches consensus among multiple blockchain nodes in the blockchain network, puts the blocks on the chain, and generates transaction data status. At this time, if the generated transaction data status is returned to the object terminal, out of distrust of the blockchain node, the object terminal will verify the reliability of the transaction data status through Merkle proof, resulting in the object terminal having to store all the information used for Merkle proof, with a space complexity of o(n) and a time complexity of o'(n), where n is the number of layers of the Merkle tree. When the object terminal verifies the data status, the time complexity and space complexity required for verification will increase linearly with the increase in the number of layers of the Merkle tree, resulting in a waste of storage space and low verification efficiency. The disclosed embodiment introduces a trusted hardware execution environment and a state storage space in a blockchain node, and verifies the transaction data status through the interaction of an accounting program, a trusted hardware execution environment, and a state storage space, to replace the verification method of the Merkle proof. The specific implementation method will be described in detail below.
[0118] The embodiments of the present disclosure can be applied in various scenarios, such as Figure 2A -D shows the recommended scenarios for resource processing strategies, etc.
[0119] The object has a virtual resource pool on the blockchain network. When the resource status on its virtual resource pool meets certain conditions, a resource processing strategy is recommended to the object so that the object can transfer and merge the virtual resources on its virtual resource pool according to the resource processing strategy in the blockchain processing application, which is convenient for the object to manage its virtual resources. Taking electronic invoices as an example, the resource pool stores the total number of resources for electronic invoice reimbursement of enterprise objects. When processing related requests for electronic invoices, different processing strategies need to be adopted according to the total number of resources for electronic invoice reimbursement of enterprise objects. For example, the larger the total number of resources for electronic invoice reimbursement of enterprise objects, the higher the priority needs to be given when queuing requests.
[0120] Combine the following Figure 2A -D Provides a detailed description of the scenario in which resource processing strategies are recommended based on the resource status of certain eligible objects.
[0121] Object contracts are smart contracts deployed on object terminals and blockchain nodes. Object terminals and blockchain nodes cooperate with each other to complete the operations required by the object based on the object contract. Figure 2AAs shown, the object contract runs on the object terminal, and there are various functions in the object contract. When running to the XX function, it may be necessary to obtain the resource status of the object that meets certain conditions. For example, the object contract is used to recommend different strategies (such as giving different queue priorities) based on the total number of resources for electronic invoice reimbursement of qualified corporate objects. The object contract has an XX function, which is used to find qualified corporate objects to obtain the resource status of these corporate objects. The interface will display "Running the XX function in the object contract to obtain the resource status of qualified objects."
[0122] Next, run the XX function to get a list of objects that meet the conditions. However, their resource status is not in the object terminal, but in the blockchain node. Therefore, it is necessary to request the blockchain node to obtain their resource status through the trusted execution environment. Figure 2B As shown, the interface displays "After judgment, the list of objects that meet the conditions is as follows: ... Do you want to obtain their resource status through the trusted execution environment?".
[0123] like Figure 2C As shown, after the object clicks the "OK" button, the blockchain node will run according to the on-chain transaction data status query method of the disclosed embodiment, obtain the resource status of all objects in the object list (for example, the total number of resources for electronic invoice reimbursement of each enterprise object) through the trusted hardware execution environment, sign the resource status, return the resource status and signature to the object terminal, and enable the object terminal to verify the signature. When entering the signature verification process, the interface will display "The resource status of the object in the object list and the signature of the trusted execution environment have been obtained from the trusted execution environment, and the signature is being verified..." to prompt the object to wait for the result of the signature verification.
[0124] like Figure 2D As shown in the figure, when the signature verification is successful, the words "Signature Verification Successful" will be displayed on the interface to prompt the result of the object signature verification. Then, the object terminal will call the XX function in the object contract to recommend a processing strategy based on the resource status of each object in the object list. For example, the larger the total number of electronic invoice reimbursement resources of the enterprise object, the greater the priority given when the request is queued.
[0125] General description of the disclosed embodiments
[0126] According to an embodiment of the present disclosure, a method for querying the status of transaction data on a blockchain is provided. Querying the status of transaction data on a blockchain refers to querying the status of the data of transactions recorded on a blockchain, which is often used for example Figure 2A-D resource processing strategy recommendation and other tasks. The transaction data state refers to the changes in related data after the transaction is executed and uploaded to the chain. For example, employee X reimburses an electronic invoice at enterprise Y, which changes the resource value of enterprise Y. The resource value of enterprise Y is a transaction data state.
[0127] like Figure 3 As shown, the method for querying the status of uplink transaction data according to an embodiment of the present disclosure may include:
[0128] Step 310: Record the target transaction on the blockchain;
[0129] Step 320: Determine the data status of the target transaction after recording the target transaction on the blockchain;
[0130] Step 330: Write the target transaction data state into the state storage space through the trusted execution environment;
[0131] Step 340: in response to obtaining a status request for a target transaction data status from the target terminal, obtaining the target transaction data status from the state storage space through the trusted execution environment, and signing the target transaction data status;
[0132] Step 350: Send the target transaction data status and signature to the target terminal so that the target terminal can verify the signature.
[0133] Steps 310 - 350 are briefly described below.
[0134] In step 310, the blockchain network includes multiple blockchain nodes, each of which stores an identical blockchain. The blockchain is a chain data structure containing multiple blocks, and each block is connected in chronological order. The blockchain node is a full node, which refers to the node that actually runs the blockchain accounting program, maintains all on-chain transaction information and the transaction data status of all on-chain transactions, and processes blockchain transactions. According to the block packaging protocol of traditional blockchain technology, each block contains multiple transactions within a period of time. The target transaction is the transaction that is currently concerned and sent by the object terminal to the blockchain node, and other transactions are transactions that are not currently concerned and sent by the object terminal to the blockchain node. Multiple transactions (including target transactions and other transactions) sent by the object terminal to the blockchain node are recorded on the blockchain.
[0135] The object terminal is a light node. It does not store all the transaction information on the chain and the transaction data status of all the transactions on the chain. It cannot independently verify the transactions on the chain and needs to request the Merkle tree-related proof from the full node for verification. The object terminal generates the target transaction based on the operation behavior of the object, and sends the target transaction and the digital signature of the object terminal to the adjacent blockchain node on the blockchain network, so that the blockchain node can verify the authenticity of the target transaction. When verifying, the blockchain node verifies the digital signature using the public key of the object terminal to obtain the first summary value of the target transaction, and calculates the summary of the target transaction according to the summary algorithm to obtain the second summary value of the target transaction. The first summary value and the second summary value are compared. If the first summary value and the second summary value are the same, the verification is passed and the target transaction is a real transaction generated by the object terminal.
[0136] After verification, the target transaction and other transactions sent by the target terminal are accumulated. When the accumulation reaches a certain level (for example, the number of accumulated transactions reaches a certain threshold, or the accumulation time reaches a certain threshold), these transactions are packaged into blocks and sent to other blockchain nodes in the blockchain network for consensus. After the consensus is successful, each blockchain node records the block to the blockchain maintained by each blockchain node.
[0137] In step 320, the transaction data state after recording the multiple transactions on the blockchain is determined, and the transaction data state includes the target transaction data state. After the transaction is executed and the transaction block is uploaded to the blockchain, the target transaction data state is obtained. For example, the original employees of enterprise X reimbursed a total of 15,000 resource values of electronic invoices, and employee Y reimbursed an electronic invoice of 1,000 resource values. The total resource value of the electronic invoice reimbursement of enterprise X, which is the target transaction data state, becomes 16,000 resource values.
[0138] In step 330, the trusted execution environment is deployed on the trusted hardware, which refers to a secure isolation area of the trusted hardware central processor, storing the key used to encrypt the target transaction data state. The trusted execution environment has a physically isolated key storage space and a physically isolated code execution environment, wherein the physically isolated code execution environment is called an enclave. After the trusted hardware generates a key pair, the public key is published and the private key is stored in the enclave, so the key used to encrypt the target transaction data state is the private key. The specific process of how to encrypt the target transaction data state by the key and write the target transaction data into the state storage space is expanded in the detailed description of step 330 below.
[0139] Since the trusted execution environment has a physically isolated code running environment, unauthorized applications or programs cannot be loaded into the code running environment, so that the programs executed in the trusted execution environment cannot be tampered with, and the trusted execution environment can only execute the programs pre-burned in the code running environment. Even if the trusted execution environment is controlled by the outside world, the programs executed inside it cannot be changed, so that the programs executed inside the trusted execution environment have high security and reliability. At the same time, the trusted execution environment has a physically isolated key storage space, and unauthorized applications or programs cannot obtain the private key in the key storage space. Although the data stored in the trusted execution environment will be stored in the state storage space outside the trusted execution environment, they are all encrypted and stored with the private key in the key storage space, and only the programs in the code running environment know the location of these data storages, and these programs are pre-burned in the code running environment and cannot be obtained by the outside world. Only the trusted execution environment itself can know the location of the encrypted target transaction data state stored in the state storage space, and accurately retrieve the target transaction data state and decrypt it, and return it to the target terminal. In the above manner, the security of the target transaction data state is guaranteed. Even if the bypass node in the Merkle tree proof is cancelled for verification by the target terminal, the target terminal can still believe that the requested target transaction data state is credible.
[0140] Trusted hardware provides the underlying hardware foundation for the trusted execution environment. It refers to hardware devices embedded with trusted computing modules. Trusted computing modules can be security chips, hardware trust roots, etc., and hardware devices can be servers, routers, etc.
[0141] The state storage space is used to store the state of the target transaction data. The state storage space can be the storage space inside the blockchain node, or the memory, disk and other storage space of the external server connected to the blockchain node, or an external database such as Oracle or MySQL.
[0142] In step 340, the status request refers to a request for obtaining the target transaction data status. As described above, in step 330, the trusted execution environment writes the target transaction data status encrypted with the private key of the trusted execution environment into the state storage space. Then, the trusted execution environment saves the location where the target transaction data status is written into the state storage space in the trusted execution environment. When the trusted execution environment receives the status request of the object terminal, it reads the location where the target transaction data status is written into the state storage space from inside the trusted execution environment, reads the encrypted target transaction data status in the state storage space according to the location, and decrypts it with the public key of the trusted execution environment to obtain the target transaction data status.
[0143] Then, the trusted execution environment signs the target transaction data state. When signing, the trusted execution environment first obtains the digest algorithm and the private key of the trusted execution environment, uses the digest algorithm to generate a first digest for the target transaction data state, and encrypts the first digest with the private key of the trusted execution environment to obtain a signature. The digest algorithm is pre-burned in the physically isolated code running environment and cannot be tampered with. After the above-mentioned process of generating the digest and encrypting, a signature is obtained. The signature represents that the target transaction data state is truly made by the trusted execution environment. Due to the particularity of the trusted execution environment as described above, there is no possibility of tampering with the process of generating, storing and reading the target transaction data state by the trusted execution environment. At this time, a signature of a trusted execution environment is used to indicate that the target transaction data state is truly made by the trusted execution environment, so that the authenticity of the target transaction data state obtained by the object terminal can be guaranteed.
[0144] In step 350, the target transaction data status and signature are sent to the target terminal, and the target transaction data status and signature constitute a response to the status request. In order to ensure that the queried target transaction data status is trustworthy, the target terminal verifies the signature after receiving the response to the status request for the target transaction data status.
[0145] The process of the object terminal verifying the signature includes: using a digest algorithm to generate a first digest of the target transaction data state; obtaining the public key of the trusted execution environment, decrypting the signature with the public key to obtain a second digest; and verifying the signature based on the comparison of the first digest and the second digest. Note that the digest algorithm used here should be the same digest algorithm as that used for signing in step 340 to ensure the uniformity of the signing and verification process. The digest algorithm can be generated in advance by the trusted execution environment and notified to the object terminal. The public key of the trusted execution environment is also generated in advance by the trusted execution environment and notified to the object terminal. For example, the trusted execution environment generates a public-private key pair at the same time, saves the private key in its own key storage space, and broadcasts the public key. The object terminal receives the broadcasted public key of the trusted execution environment and stores it in the memory of the object terminal. When verifying the signature based on the comparison of the first digest and the second digest, generally speaking, if the first digest and the second digest are the same, the verification is successful. Otherwise, the verification fails. The above-mentioned signing and verification process ensures that the target transaction data state received by the object terminal is truly sent by the trusted execution environment through simple operations, and no loss occurs during transmission.
[0146] As described above, the disclosed embodiment can verify whether the received target transaction data status is authentic by performing a signature verification operation on the trusted execution environment once. There is no need to repeatedly perform summary operations on the Merkle tree from the bottom to the root based on the Merkle tree proof. The time complexity of the verification is o(1), which improves the verification speed while ensuring the accuracy of the verification.
[0147] The above is a general description of steps 310-350. For some of the steps or some combinations of steps, there are different implementation methods. The implementation methods of these steps or combinations of steps will be described in detail below.
[0148] Detailed description of the process of writing and reading the target transaction data status
[0149] The target transaction data state is written into the state storage space, which is the above step 330, and the target transaction data state is read, which is the above step 340. The two steps cooperate with each other. There are some implementation methods for the specific implementation of these two steps. The specific implementation method of the combination of these two steps is described in detail below.
[0150] In one embodiment, the target transaction data state includes a state key and a state value. The key-value pair is the implementation of the mapping in the mathematical concept of the programming language. The key is used as the index of the element, and the value represents the data stored and read. The state key is the index of the transaction data state, and the state value is the specific value of the transaction data state. For example, if the target transaction data state is the total resources for electronic invoice reimbursement of enterprise A, then the state key is "the total resources for electronic invoice reimbursement of enterprise A", and the state value is the numerical value of the total resources for electronic invoice reimbursement of enterprise A. At this time, Figure 4A The storage of various transaction data states in the state storage space is shown, in which it can be seen that in each transaction data state, the state key and the state value are stored correspondingly, and these state keys and state values include the state key of the target transaction data state and the state value of the target transaction data state.
[0151] The status request received from the target terminal in step 340 may include a status key, such as "Company A electronic invoice reimbursement total resources", which is used to find the value of the total electronic invoice reimbursement resources of Company A. Figure 4B The structure of a status request is shown, wherein the status request includes an object terminal identifier, a trusted execution environment identifier, and a status key of the target transaction data status. The object terminal identifier is a mark that distinguishes the object terminal from other object terminals, such as the object terminal IP address, the object terminal serial number, etc. The trusted execution environment identifier is a mark that distinguishes the trusted execution environment from other trusted execution environments, such as the trusted execution environment IP address, the trusted execution environment serial number, etc. In network transmission, the object terminal identifier is used to identify the source address, and the trusted execution environment identifier is used to identify the destination address.
[0152] In step 340, the target transaction data state is obtained from the state storage space through the trusted execution environment, including: obtaining the state value corresponding to the state key in the state request from the state storage space through the trusted execution environment, so as to integrate the state key and the state value into the target transaction data state and return it to the target terminal. Figure 4C As shown, the response returned by the trusted execution environment to the object terminal includes the target transaction data state (state key and state value) and the signature of the trusted execution environment. The signature and verification process has been introduced in the general description of the above-mentioned embodiment of the present disclosure. The response also includes the object terminal identifier and the trusted execution environment identifier, which are used to identify the destination address and source address in the transmission.
[0153] For example, the status key in the status request is "Company A's total resources for electronic invoice reimbursement". Figure 4A In the data, the status value stored corresponding to the status key "Company A Electronic Invoice Reimbursement Total Resources" is 15,000 resources. Figure 4B In the target transaction data status, the status key is "Company A Electronic Invoice Reimbursement Total Resources". Figure 4A The corresponding status value "15000" is found in the status storage space, and the target transaction data status of the status key and status value is integrated into "Company A electronic invoice reimbursement total resources 15000", such as Figure 4C As shown, it is returned to the target terminal in the response to the target terminal.
[0154] Through the above key-value storage and search method, the target transaction data status can be quickly retrieved, thereby improving the search efficiency of the target transaction data status.
[0155] The above embodiment adopts the key-value storage and search method to improve the search efficiency of the target transaction data state, but the state key and state value are in plain text. In another embodiment, in order to further improve the security of the target transaction data state storage and search, the target transaction data state is stored and searched in ciphertext. In this embodiment, Figure 5 As shown, the process of writing the target transaction data state into the state storage space may include but is not limited to steps 510 to 530:
[0156] Step 510: Obtain the key stored in the trusted execution environment;
[0157] Step 520: Encrypt the state key and the state value with the key;
[0158] Step 530: Write the encrypted state key and the encrypted state value into the state storage space;
[0159] Accordingly, the process of reading the target transaction data state from the state storage space may include but is not limited to steps 540 to 560:
[0160] Step 540: Encrypt the state key in the state request with the key through the trusted execution environment to obtain the encrypted state key;
[0161] Step 550: Obtain the encrypted state value corresponding to the encrypted state key from the state storage space;
[0162] Step 560: Decrypt the encrypted state value using the key to obtain the state value.
[0163] The above steps 510 to 560 are described in detail below.
[0164] In step 510, the enclave stores the key used to encrypt the target transaction data state.
[0165] In the previous step 320, the determined target transaction data state includes a state key and a state value. In step 520, the state value and the state value are encrypted with the key of the trusted execution environment to obtain the encrypted state key and the state value. For example, the "Company A electronic invoice reimbursement total resources" is encrypted to obtain the encrypted state key "%¥3*@"; the "15000 resources" is encrypted to obtain the encrypted state value "&tu%3". After obtaining the encrypted state key and the encrypted state value, the encrypted state key and the encrypted state value can be written into the state storage space in step 530.
[0166] In order to avoid repeated writing, which causes redundancy of the transaction data state in the state storage space, the encrypted state key and the encrypted state value are compared with the state key and the state value that have been written into the state storage space. If the encrypted state key is different from the existing state key, the encrypted state key and the encrypted state value are written into the state storage space. If the encrypted state key is the same as one of the existing state keys, and the encrypted state value is different from the existing state value, the encrypted state value is used to update the existing state value. If the encrypted state key is the same as an existing state key, and the encrypted state value is the same as the state value corresponding to the existing state key, no write operation is performed. This embodiment can reduce the state storage redundancy in the state storage space and improve the overall storage space utilization efficiency.
[0167] In step 540, the state request includes an unencrypted state key. Since the encrypted state key is stored in the state storage space, in order to achieve consistency in storage and reading, the state key in the state request needs to be encrypted using the private key of the trusted execution environment to obtain the encrypted state key.
[0168] In step 550, after obtaining the encrypted state key corresponding to the state key in the state request, the encrypted state value corresponding to the encrypted state key is obtained from the state storage space.
[0169] In step 560, since the state value needs to be returned to the target terminal, and the encrypted state value is obtained in step 550, the encrypted state value needs to be decrypted with a key to obtain the state value. In the case of symmetric encryption, the key here is the key in the enclave, that is, the same key as that used for encryption. The encrypted state value is decrypted with the same key as that used for encryption to obtain the state value. The state key and the state value are integrated into a key-value pair to obtain the target transaction data state.
[0170] This embodiment realizes the rapid retrieval of the target transaction data state according to the key-value pair when the data is encrypted and stored in the state storage space. When the data is encrypted and stored in the state storage space, the retrieval efficiency of the target transaction data state is improved.
[0171] In one embodiment, multiple transaction data states are encrypted using the same key. Step 520 includes: encrypting multiple state keys and multiple state values of the multiple transaction data states according to the same key. Step 540 includes: encrypting multiple state keys in multiple state requests for the multiple transaction data states using the same key to obtain multiple encrypted state keys. Step 560 includes: decrypting multiple encrypted state values corresponding to the multiple encrypted state keys using the same key to obtain multiple state values. The same key here refers to the key stored in the enclave.
[0172] In another embodiment, in order to increase the security of the transaction data state and prevent the security of all encrypted transaction data states stored in the state storage space from being challenged once the unique key is cracked, different keys are used to encrypt multiple transaction data states. Specifically, different objects correspond to different keys. Once the key of an object is cracked, the security of the transaction data states of other objects will not be affected. In this embodiment, the key includes multiple keys corresponding to multiple object identifiers to encrypt the transaction data states from different object terminals differently. Step 520 includes: obtaining the object identifier corresponding to the target transaction, and encrypting the state key and the state value with the key corresponding to the object identifier. Step 540 includes: obtaining the object identifier corresponding to the state request; encrypting the state key in the state request with the key corresponding to the object identifier. Step 560 includes decrypting the encrypted state value with the key corresponding to the object identifier.
[0173] There are multiple ways to obtain the object identifier corresponding to the target transaction in step 520. In one way, if the target transaction contains the object identifier, the object identifier can be directly obtained from the target transaction. In another way, a query request can be sent to the object terminal, and the object identifier can be obtained from the response of the object terminal.
[0174] There are multiple ways to obtain the object identifier corresponding to the status request in step 540. In one way, the status request contains the object identifier, and the object identifier can be directly obtained from the status request. In another way, a query request can be sent to the object terminal, and the object identifier can be obtained from the response of the object terminal.
[0175] Through the above steps 510 to 560, the security of the target transaction data state can be improved so that once a key is cracked, the security of all transaction data states will not be affected.
[0176] The above steps 540 to 560 describe the process of obtaining the state value from the state storage space according to the encrypted state key. An example of an encrypted state key is the total resources of electronic invoice reimbursement of enterprise A, where "Enterprise A" belongs to the target object and "total resources of electronic invoice reimbursement" belongs to the target data type. The target object refers to the object to which the target transaction data belongs. The target data type refers to the type of the target transaction data. For example, the total resources of electronic invoice reimbursement of enterprise A and the number of reimbursed electronic invoices are two different data types. Although the total resources of electronic invoice reimbursement of enterprise A and the total resources of electronic invoice reimbursement of enterprise B belong to the same data type, they belong to different objects and therefore correspond to different target objects. The combination of the target data type and the target object defines the state key. The following describes the process of reading the state value according to the target data type and the target object.
[0177] In this embodiment, the state key includes the target data type corresponding to the target transaction data state and the target object corresponding to the target transaction data state. Fig. 6A As shown in the figure, the data type, object and state value are stored in the state storage space correspondingly to form a transaction data state. Figure 4A The difference is that the state key is decomposed into data types and objects. Figure 6B As shown, the status request contains the target data type and target object, which is the same as Figure 4B The difference is that Figure 4B The state key of the transaction data state is decomposed into the target data type and the target object. Figure 6C As shown, the response received by the target terminal also includes the target data type and target object, which is the same as Figure 4C The difference is that Figure 4C The state key of the transaction data state is decomposed into the target data type and the target object.
[0178] The above process of obtaining the state value corresponding to the state key in the state request from the state storage space through the trusted execution environment includes: obtaining the transaction data state of the target data type in the state storage space through the trusted execution environment; obtaining the transaction data state of the target object in the transaction data state of the target data type, and taking out the state value from the transaction data state of the target object.
[0179] Data Types Object Status value Electronic Invoice Reimbursement Total Resources Company B 12000 Number of electronic invoice reimbursements Company A 25 Electronic Invoice Reimbursement Total Resources Company A 15000 Resources in the resource pool Company A 380000 Resources in the resource pool Company C 134000
[0180] Table 1
[0181] As shown in Table 1 above, if the target data type is "total resources for electronic invoice reimbursement" and the target object is "Enterprise A", first, according to the target data type "total resources for electronic invoice reimbursement" in the state storage space shown in Table 1, the transaction data status of the target data type "total resources for electronic invoice reimbursement" is filtered out, that is, the first transaction data status and the third transaction data status. Then, among the filtered first transaction data status and the third transaction data status, the third transaction data status is filtered out according to the target object "Enterprise A", and the status value 15000 is taken out.
[0182] In the above embodiment, all transaction data states stored in the state storage space are screened layer by layer according to the target data type and the target object, thereby improving the efficiency of obtaining the target transaction data state from the state storage space.
[0183] In order to further improve the efficiency of obtaining the target transaction data state from the state storage space, in one embodiment, the state storage space can be partitioned according to data type, that is, the transaction data state of the same data type is stored in one partition. Step 330 includes: writing the transaction data state of the same data type to the same partition address in the state storage space through the trusted execution environment. Fig. 6AAs shown, the state storage space includes partitions 1...n. Partition 1 corresponds to data type 1, has a partition address of partition 1, and all transaction data states of data type 1 are written into the partition address of partition 1; partition 2 corresponds to data type 2, has a partition address of partition 2, and all transaction data states of data type 2 are written into the partition address of partition 2; ... partition n corresponds to data type n, has a partition address of partition n, and all transaction data states of data type n are written into the partition address of partition n. These partitions include partitions corresponding to the target data type, and corresponding to the target data type, all transaction data states of the target data type are written into the partition address of the partition. Transaction state data of the same data type are written into the same partition address, and the same partition stores transaction state data of multiple objects of the same data type, which is conducive to improving the orderliness of the state storage space and facilitating the management of the state storage space to improve the reading efficiency of the transaction data state.
[0184] In the above embodiment, the process of obtaining the transaction data state of the target data type from the state storage space includes: determining the partition address corresponding to the target data type through the trusted execution environment; and reading the transaction data state in the partition address.
[0185] The trusted execution environment stores a table of correspondence between data types and partition addresses, and determines the partition address corresponding to the target data type through the object relationship table. Figure 6B As shown, the status request may include a target data type and a target object. In response to obtaining a status request for a target transaction data status from an object terminal, the target data type is obtained from the status request, and a corresponding relationship table is searched based on the target data type to determine the partition address corresponding to the target data type. Through the trusted execution environment, the transaction data status of the partition corresponding to the partition address is obtained from the status storage space to obtain the transaction data status of the target data type. Next, the target object is obtained from the status request, the target transaction data status of the target object is located in the transaction data status of the target data type, and the target transaction data status (target data type, target object, status value of the target transaction data status) is placed in a response of the trusted execution environment and returned to the object terminal, such as Figure 6C shown.
[0186] The advantage of this embodiment is that, through partitioned storage, the target transaction data state can be quickly located from the state storage space according to the target data type and the target object, thereby improving the reading efficiency of the target transaction data state.
[0187] Solution for reading multiple transaction data states simultaneously
[0188] According to the above embodiment, each time the object terminal generates a status request, the object terminal must establish a connection with the blockchain node and obtain the target transaction data status corresponding to the status request through the trusted execution environment. However, the object terminal often does not need to read only one transaction data status at a time. For example, for the enterprise objects under a certain city, it is necessary to screen out the enterprise objects whose total resources for electronic invoice reimbursement are greater than a certain threshold, and then adopt a certain information recommendation strategy. At this time, there is more than one subordinate enterprise object in the city, and the total resources for electronic invoice reimbursement of each enterprise object must be obtained to determine whether it is greater than a certain threshold. At this time, it is necessary to obtain multiple transaction data states of multiple enterprise objects at the same time. Requesting the blockchain node to establish a connection and obtain the transaction data status again and again increases the transmission overhead and processing load. In the following embodiment, a method of accumulating several transaction data states and sending them together in a package will be adopted to reduce network transmission overhead and processing load.
[0189] Combine the following Figure 7 An embodiment of simultaneously reading multiple transaction data states is described in detail.
[0190] In this embodiment, step 340 includes:
[0191] Step 710, receiving a first packet from a target terminal;
[0192] Step 720, obtaining multiple transaction data states from the state storage space through the trusted execution environment, and signing the multiple transaction data states;
[0193] Step 730: Pack multiple transaction data statuses and signatures into a second package and send it to the target terminal.
[0194] In step 710, the first packet has multiple status requests for multiple transaction data states, including the overall request for the target transaction. The object terminal may generate multiple status requests simultaneously or over a period of time to request multiple different transaction data states. At this time, it may be necessary to establish a connection with the blockchain node once for each status request and send the corresponding status request, which has low network transmission efficiency and increases the processing load. In this embodiment, the object terminal can package multiple status requests for different transaction data states generated simultaneously or over a period of time into a first packet and send it to the blockchain node. Compared with the solution of sending a status request for each required transaction data state, the waste of network resources and the processing load are greatly reduced.
[0195] like Fig. 8AAs shown, the object terminal generates n status requests at the same time, among which the first status request is used to obtain the transaction data status of data type 1 and object 1, the second status request is used to obtain the transaction data status of data type 2 and object 2... The nth status request is used to obtain the transaction data status of data type n and object n. These n status requests contain status requests for obtaining the transaction data status of the target data type and target object. The object terminal packs them into the first packet and sends them to the trusted execution environment.
[0196] In one embodiment, the first packet is generated by the target terminal in the following manner:
[0197] Get the read condition of the state read function in the object contract of the object terminal;
[0198] According to the reading condition, determine the states of multiple transaction data that need to be read;
[0199] The status requests for the plurality of transaction data statuses are packaged into a first packet.
[0200] An object contract is a smart contract signed between an object and a blockchain network, in which the actions that the object wishes to perform can be specified. Part of the object contract is on the object terminal, and part is on the blockchain node. A state reading function is a function in an object contract that is used to read the transaction data state. For example, there is a program segment in an object contract that is used to obtain the total resources of electronic invoice reimbursement for all enterprise objects in H City. The total resources of electronic invoice reimbursement are a transaction data state, so this program segment is a state reading function. The reading condition is the condition for reading the transaction data state. In the above example, the reading condition is "all enterprise objects in H City".
[0201] According to the reading conditions, the object contract searches the local database and can determine the status keys of all transaction data states that meet the reading conditions. Taking the total electronic invoice reimbursement resources of all enterprise objects in H city as an example, the local database is searched and it is found that there are 1,000 enterprise objects in H city. It is determined that the total electronic invoice reimbursement resources of these 1,000 enterprise objects need to be read, and 1,000 corresponding status requests are issued, and these 1,000 status requests are packaged into the first package.
[0202] The advantage of the above embodiment is that the status request that is packaged into the first packet and transmitted to the trusted execution environment is related to a status reading function in the object contract. If the transaction data status that the same status reading function needs to read can be returned together or within a short time interval, it is greatly beneficial to the execution efficiency of the object contract. Therefore, this embodiment can improve the execution efficiency of the object contract.
[0203] In step 720, the target terminal sends the first packet to the trusted execution environment, obtains multiple transaction data states from the state storage space through the trusted execution environment, and signs the multiple transaction data states with a private key. The trusted execution environment signs the multiple transaction data states in two ways: one by one and one by one. Fig. 8A As shown, each transaction data state has a signature, and the unified signature method is as follows Figure 8B As shown, the entire transaction data state has one signature.
[0204] As the signature method of the trusted execution environment changes, the signature verification method of the target terminal also changes. When the signature method is adopted one by one, the target terminal uses the public key of the trusted execution environment to verify the multiple signatures of multiple transaction data states one by one; when the unified signature method is adopted, the target terminal uses the public key of the trusted execution environment to verify one signature of multiple transaction data states once.
[0205] In step 730, in order to reduce the network overhead caused by multiple transmissions of multiple transaction data states, the multiple transaction data states and signatures obtained in step 720 are packaged into a second packet and sent to the target terminal. The second packet obtained by signing one by one, such as Fig. 8A The second package obtained by using the unified signature method is as follows Figure 8B As shown, it can be seen that the difference between the second package and the first package is that the second package adds the status value of each transaction data status queried and the signature of the trusted execution environment.
[0206] like Fig. 9 As shown, in a specific execution process of the embodiment of the present disclosure, in response to the object initiating the object contract execution request, the object terminal accounting program starts to execute the object contract. When executing the state reading function of the object contract, the multiple transaction data states that need to be read are determined according to the reading conditions of the state reading function. Specifically, the key field Key of the multiple transaction data states that need to be read is determined. These transaction data states are stored in different partitions in the state storage space according to the data type in the key field Key. The partition address is represented by Addr. Fig. 9In , multiple transaction data states that need to be read are organized into a required state list, where Addr1: Key1, Key2 represent two transaction data states stored in the first partition, and their key fields are Key1 and Key2 respectively. They are both stored in the first partition, indicating that the data types of the two transaction data states are the same, and the key fields are different because the objects are different. Addr2: Key1, Key2 represent two transaction data states stored in the second partition, and their key fields are Key1 and Key2 respectively. After the status requests of these multiple transaction data states that need to be read are packaged into the first package, the first package is sent to the blockchain node accounting program, and the blockchain node accounting program searches for the transaction data states requested by each status request of the first package through the trusted execution environment. Specifically, the state value Valve in the transaction data state requested by each status request of the first package is found. Addr1: (Key1, Value1) indicates that the status request for the transaction data status with the key field Key1 stored in the first partition finds the status value Value1; Addr1: (Key2, Value2) indicates that the status request for the transaction data status with the key field Key2 stored in the first partition finds the status value Value2; Addr2: (Key1, Value3) indicates that the status request for the transaction data status with the key field Key1 stored in the second partition finds the status value Value3; Addr2: (Key2, Value4) indicates that the status request for the transaction data status with the key field Key2 stored in the second partition finds the status value Value4. The trusted execution environment returns the multiple transaction data statuses (status keys and status values) queried and the signature of the trusted execution environment to the object terminal. The object terminal verifies the signature. After the verification is successful, the object terminal accounting program uses the queried transaction data status to execute the subsequent object contract and returns the object contract execution result to the object.
[0207] Through the above steps 710 to 730, resource occupation caused by the trusted execution environment responding multiple times to multiple status requests can be avoided.
[0208] In addition, if a blockchain node receives status requests for transaction data status of multiple objects, it needs to search for status requests for transaction data status of multiple objects in the status storage space. The efficiency of searching for status requests for transaction data status of multiple different objects in the status storage space is lower than the efficiency of searching for status requests for transaction data status of the same object in the status storage space, because when searching for status requests for transaction data status of the same object in the status storage space, a unified search can be performed according to the status value of the same object, thereby improving the retrieval speed. Therefore, in one embodiment, when multiple status requests for multiple transaction data status of multiple objects are received, the multiple status requests are queued by object, and one object corresponds to one queue. When a queue meets a predetermined condition, the status requests in the queue are packaged and sent to the trusted execution environment at one time. Since the status requests in the queue are all for the same object, the efficiency of the trusted execution environment in searching in the state storage space is improved.
[0209] Combine the following Fig.10 Expand the detailed description.
[0210] like Fig.10 As shown, step 340 includes:
[0211] Step 1010: receiving multiple status requests for multiple transaction data statuses from the target terminal;
[0212] Step 1020: Put the status request corresponding to each object identifier into the queue corresponding to the object identifier;
[0213] Step 1030: In response to determining that the queue meets the predetermined condition, the status request in the queue is discharged, and for the discharged status request, the corresponding transaction data status is obtained from the state storage space through the trusted execution environment, and the obtained transaction data status is signed.
[0214] In step 1010, each status request received includes an object identifier, such as Fig.11A - Objects 1-n in B are used to distinguish status requests for transaction data states of different objects. The multiple transaction data states include the target transaction data state.
[0215] In step 1020, the queue is a container for storing status requests during the status request transmission process. Fig.11A-B, queue 1 corresponds to object 1, and the status requests received from each object terminal with the object identification field of object 1 are all queued in queue 1; queue 2 corresponds to object 2, and the status requests received from each object terminal with the object identification field of object 2 are all queued in queue 2... Queue n corresponds to object n, and the status requests received from each object terminal with the object identification field of object n are all queued in queue n. Note that the object terminal identification in the status request is not the object identification here. The object identification is the identification of the object for which the transaction data status requested is targeted. The object terminal identification is the identification of the terminal that issued the status request.
[0216] In step 1030, the predetermined condition may be set in a variety of ways.
[0217] In one embodiment, the predetermined condition may be: when the number of status requests contained in the queue reaches a first threshold, it is determined that the queue meets the predetermined condition. The advantage of this embodiment is that when a certain number of status requests are accumulated in the queue, the status requests in the queue are sent to the trusted execution environment for query, so that a communication connection with the trusted execution environment is not established for a small number of status requests, which wastes transmission resources, reduces the communication overhead between the accounting program of the blockchain node and the trusted execution environment, and improves resource utilization.
[0218] In one embodiment, the predetermined condition may be: determining that the queue satisfies the predetermined condition at every predetermined period. The advantage of this embodiment is that no matter how many status requests are accumulated in the queue, as long as the predetermined period is separated, the status requests in the queue are sent to the trusted execution environment for query. The advantage of this embodiment is that some status requests will not be unable to be executed due to too few status requests in the queue, thereby improving the real-time performance of status query.
[0219] In another embodiment, determining that a queue satisfies a predetermined condition includes:
[0220] If the number of status requests included in the queue reaches a first threshold, determining that the queue meets a predetermined condition;
[0221] If the number of status requests included in the queue does not reach the first threshold, but the time difference between the current time and the time when the queue was last discharged reaches the second threshold, it is determined that the queue meets the predetermined condition.
[0222] This embodiment comprehensively considers the number of status requests in the queue and the time the status requests have been queued, which not only reduces the situation where some status requests cannot be executed due to the small number of status requests in the queue, but also avoids transmitting too few status requests at a time as much as possible, thereby improving the utilization rate of transmission resources.
[0223] When it is determined that the queue meets the predetermined conditions, the status request in the queue can be discharged, and the corresponding transaction data status is obtained from the status storage space through the trusted execution environment for the discharged status request. Fig.11A -B, it is expressed as obtaining the status value of the corresponding transaction data status. Then, the obtained transaction data status is signed. Fig.11A It shows the situation of signing each transaction data status obtained one by one. Fig. 11B It shows the situation of uniformly signing each acquired transaction data state.
[0224] Through the above steps 1010 to 1030, the status requests for the transaction data status of the same object are placed in the same queue and packaged and sent according to predetermined conditions, which improves the efficiency of the trusted execution environment in searching in the state storage space and reduces the communication overhead between the accounting program of the blockchain node and the trusted execution environment.
[0225] When the embodiment of the present disclosure is applied to multiple state storage spaces
[0226] The above describes the case where the embodiment of the present disclosure is applied to a single state storage space, but in fact, the embodiment of the present disclosure can also be applied to multiple state storage spaces, each state storage space corresponding to a transaction type. The transaction type is the type of transaction for which the transaction data state is directed. For example, an electronic invoice transaction is a transaction type, and transaction data states such as the total resources for electronic invoice reimbursement, the number of electronic invoice reimbursements, and the number of electronic invoices received all correspond to this transaction type and are stored in the state storage space corresponding to this type; a resource transfer transaction is a transaction type, and transaction data states such as the resource pool resource value and the number of resource transfers all correspond to this type and are stored in the state storage space corresponding to this type. Searching different state storage spaces according to different transaction types can improve the efficiency of retrieving the target transaction data state in the state storage space.
[0227] like Fig.12 As shown, in this embodiment, step 330 includes:
[0228] Step 1210: Determine the transaction type corresponding to the target transaction data state through the trusted execution environment;
[0229] Step 1220: Write the target transaction data state into the state storage space corresponding to the transaction type.
[0230] Correspondingly, step 340 includes:
[0231] Step 1230: Get the transaction type from the status request;
[0232] Step 1240: Obtain the target transaction data state from the state storage space corresponding to the transaction type through the trusted execution environment.
[0233] In step 1210, the target transaction data state includes a target data type, a target object, and a state value. The transaction type can be determined based on the target data type. A data type and transaction type correspondence table can be pre-set. In the correspondence table, data types such as the total resources for electronic invoice reimbursement, the number of electronic invoice reimbursements, and the number of electronic invoices received all correspond to the transaction type of the electronic invoice type; data types such as the resource pool resource value and the number of resource transfers all correspond to the transaction type of the resource transfer type, and so on. Therefore, the transaction type can be obtained by searching the correspondence table according to the target data type.
[0234] In step 1220, the target transaction data state is written into the state storage space corresponding to the transaction type. Fig.13 As shown, the same state storage space stores multiple transaction data states of the same transaction type, different data types, and different objects, and the transaction data states of multiple transaction types are stored in multiple state storage spaces respectively.
[0235] There are many implementations of step 1230.
[0236] In one embodiment, the status request contains a transaction type corresponding to the target transaction data status, such as Fig.13 At this time, the transaction type corresponding to the target transaction data status can be directly read from the status request.
[0237] In another embodiment, the transaction type can be determined based on the target data type in the status request, which is basically the same as the determination method in step 1210, so it is not repeated here.
[0238] In step 1240, if Fig.13 As shown, through the trusted execution environment, the state storage space corresponding to the transaction type is first found. For example, the electronic invoice type corresponds to the state storage space 1, the resource transfer type corresponds to the state storage space 2, and so on. Then, the target transaction data state is obtained from the state storage space corresponding to the transaction type, which is mainly reflected in obtaining the state value corresponding to the target data type and the target object.
[0239] In the above steps 1210 to 1240, different state storage spaces are searched according to different transaction types, so as to improve the efficiency of retrieving the state of target transaction data in the state storage space.
[0240] The present disclosure is applied to multiple trusted execution environments.
[0241] When a trusted execution environment returns the transaction data status and signature to the target terminal, the credibility of the transaction data status is determined only by the trusted execution environment, which will cause the target terminal to distrust the trusted execution environment. In order to improve the credibility of the transaction data status, multiple trusted execution environments are used to respond to the same status request to read the target transaction data status. Fig.14 The specific process of reading the target transaction data status through multiple trusted execution environments is described in detail.
[0242] In one embodiment, step 330 includes: step 1410, writing the target transaction data state into the state storage space of each of the multiple trusted execution environments through the multiple trusted execution environments;
[0243] Step 340 includes: Step 1420, obtaining the target transaction data state from the state storage space of each of the multiple trusted execution environments through the multiple trusted execution environments, and signing the target transaction data state;
[0244] Step 350 includes: Step 1430, multiple trusted execution environments send their own generated target transaction data states and signatures to the object terminal, so that the object terminal verifies the target transaction data states and signatures based on the multiple trusted execution environments.
[0245] In step 1410, if Fig.15 As shown, after the blockchain node accounting program generates the target transaction data state, it is sent to multiple trusted execution environments at the same time, and multiple trusted execution environments record the same target transaction data state in their respective state storage spaces. Once one or some trusted execution environments are tampered with, the correct target transaction data state can still be found because more trusted execution environments have not been tampered with.
[0246] In step 1420, if Fig.15 As shown, in response to a status request from an object terminal, a target data type and a target object of a target transaction data state are obtained from the status request through multiple trusted execution environments, and the target data type and the state value corresponding to the target object are retrieved from the respective state storage spaces according to the target data type and the target object. Each trusted execution environment integrates the target data type, the target object and the state value it finds into the target transaction data state it obtains and signs it.
[0247] In step 1430, if Fig.15 As shown, multiple trusted execution environments send their generated target transaction data states and signatures to the target terminal so that the target terminal can verify the multiple signatures.
[0248] There are many ways to verify the signature.
[0249] In one method, sub-verification is performed based on the target transaction data state and signature obtained by a single trusted execution environment; if the number of sub-verifications that succeed is greater than the number of sub-verifications that fail, the verification is determined to be successful. This method is a verification method where the minority obeys the majority. Assume that there are 10 trusted execution environments, 5 sub-verifications succeed, and 5 sub-verifications fail. At this time, the number of sub-verifications that succeed is not greater than the number of sub-verifications that fail, and the verification cannot be considered successful.
[0250] In another way, sub-verification is performed based on the target transaction data status and signature obtained by a single trusted execution environment; if the number of successful sub-verifications is greater than the third threshold, the verification is determined to be successful. This method is the passing verification method. Assume that there are 10 trusted execution environments in total, and 6 successful sub-verifications are considered passing. The third threshold is 6. For 10 groups of target transaction data status and signatures obtained from 10 trusted execution environments, 10 sub-verifications are performed. If more than 6 of them are successful sub-verifications, it indicates that they are passing, and the verification can be determined to be successful. In this method, since the third threshold can be flexibly set, the credibility standard can be adjusted according to actual needs, which has greater flexibility.
[0251] The manner in which a single trusted execution environment performs sub-signature verification can refer to the step in which the object terminal verifies the signature in step 350, which will not be repeated here.
[0252] After the signature verification is successful, the object terminal runs the object contract in the virtual machine and performs subsequent calculations on the target transaction data status. For example, after obtaining the total electronic invoice reimbursement resources of each enterprise object in City H, the enterprise objects whose total electronic invoice reimbursement resources are greater than a certain threshold are screened out, and some information recommendation strategy is adopted in the future.
[0253] The above steps 1410 to 1430 can improve the trust level of the object terminal in the target transaction data status by verifying the signatures of multiple trusted execution environments, and ensure that the object of the object terminal can obtain the correct status data.
[0254] In the above steps 1410 to 1430, the target transaction data status is stored in the state storage space of each of the multiple trusted execution environments. If multiple trusted execution environments respond to the same status request, some trusted execution environments will be overloaded due to too many status requests to be processed. Considering the matching between the load of each trusted execution environment and its actual processing capacity, in another embodiment, a trusted execution environment with a better matching degree between the load and its actual processing capacity is selected from multiple trusted execution environments to obtain the target transaction data status. Fig.16 Describe in detail how to obtain the target transaction data status.
[0255] like Fig.16 As shown, in this embodiment, step 330 includes: step 1610, writing the target transaction data state into the state storage space of each of the multiple trusted execution environments through the multiple trusted execution environments;
[0256] Correspondingly, step 340 includes:
[0257] Step 1620, selecting a target trusted execution environment from multiple trusted execution environments based on the processing speed of the trusted execution environment and the number of queued state requests;
[0258] Step 1630: Obtain the target transaction data state from the state storage space through the target trusted execution environment, and sign the target transaction data state.
[0259] In step 1610, the process of writing the target transaction data state through multiple trusted execution environments has been described in 1410 and will not be repeated here.
[0260] In step 1620, the processing speed can be reflected as the number of status requests that the trusted execution environment can process per unit time, which can measure the processing capacity of the trusted execution environment. The number of queued status requests refers to the number of status requests queued in the queue waiting for the trusted execution environment to execute, which can measure the load of the trusted execution environment. The processing speed and the number of queued status requests of the trusted execution environment can reflect the matching degree between the load borne by the trusted execution environment and its actual processing capacity. Based on this, selecting a target trusted execution environment from multiple trusted execution environments is conducive to improving the comprehensive operation efficiency of resources.
[0261] In step 1630, the steps of obtaining the target transaction data state from the state storage space and signing it can refer to the description of step 1420 and step 1430, which will not be repeated here.
[0262] In the above steps 1610 to 1630, a trusted execution environment with a better match between the load undertaken and its actual processing capability is selected from multiple trusted execution environments, thereby improving the comprehensive operating efficiency of resources and the efficiency of obtaining the target transaction data status.
[0263] In one embodiment, step 1620 includes:
[0264] Determining a ratio of a processing speed of the trusted execution environment to a number of queued status requests;
[0265] Based on the ratio of the multiple trusted execution environments, a target trusted execution environment is selected from the multiple trusted execution environments.
[0266] The faster the processing speed of a trusted execution environment, the more it should be selected for query among multiple trusted execution environments. In other words, the priority of selecting a trusted execution environment is an increasing function of the processing speed of the trusted execution environment. The smaller the number of queued status requests, the more it should be selected for query among multiple trusted execution environments. In other words, the priority of selecting a trusted execution environment is a decreasing function of the number of queued status requests of the trusted execution environment. Therefore, a variable is set to be equal to the ratio of the processing speed of the trusted execution environment to the number of queued status requests. Then, based on the variable, a target trusted execution environment is selected from multiple trusted execution environments, for example, the trusted execution environment with the largest variable is selected as the target trusted execution environment.
[0267] This embodiment selects a target trusted execution environment from multiple trusted execution environments in a quantitative manner, thereby improving the accuracy of selecting the target trusted execution environment.
[0268] Detailed diagram of the implementation of the on-chain transaction data status query method of the disclosed embodiment
[0269] Refer to the following Fig.17 , the implementation details of the blockchain transaction processing method of the embodiment of the present disclosure are explained in detail and by way of example.
[0270] In step 1701, the employee object opens the blockchain processing application on the object terminal, enters the first operation instruction for reimbursement of the electronic invoice, and instructs the transfer of the resources of the enterprise object to the employee object.
[0271] In step 1702, the object terminal generates a target transaction according to the first operation instruction of the employee object for reimbursement of the electronic invoice, and sends the target transaction to the accounting program of the blockchain node.
[0272] In step 1703, the accounting program of the blockchain node records the target transaction on the blockchain maintained by the blockchain node, determines the target transaction data status after recording the target transaction on the blockchain, and submits the target transaction data status to the trusted execution environment.
[0273] In step 1704, the trusted execution environment receives the target transaction data state and determines the object identifier and data type of the target transaction data state.
[0274] In step 1705, the state key and state value of the target transaction data state are encrypted using the key corresponding to the object identifier.
[0275] In step 1706, a transaction type is determined according to the data type, a state storage space is determined according to the transaction type, and a partition address of the state storage space is determined according to the data type.
[0276] In step 1707, the encrypted state key and the encrypted state value are written into the partition corresponding to the partition address.
[0277] In step 1708, the enterprise object opens the blockchain processing application on the object terminal and inputs a second operation instruction for querying the total resources for electronic invoice reimbursement.
[0278] In step 1709, the object terminal generates a status request according to the second operation instruction of the enterprise object to query the total resources of electronic invoice reimbursement, and sends the status request to the trusted execution environment.
[0279] In step 1710, the trusted execution environment receives the status request, obtains the object identifier of the status request, and encrypts the status key in the status request with the key corresponding to the object identifier.
[0280] In step 1711, the transaction type is determined according to the data type in the encrypted state key, the state storage space is determined according to the transaction type, and the partition address of the state storage space is determined according to the data type.
[0281] In step 1712, a read request for reading the encrypted state value from the partition address is sent to the state storage space.
[0282] In step 1713, after receiving the read request, the state storage space reads the encrypted state value from the partition address and returns the encrypted state value to the trusted execution environment.
[0283] In step 1714, after receiving the encrypted state value, the trusted execution environment decrypts the encrypted state value with the same key as that used for encryption, integrates the state key and the encrypted state value into the target transaction data state, and signs it.
[0284] In step 1715, the target transaction data status and signature are sent to the target terminal;
[0285] In step 1716, the target terminal verifies the signature.
[0286] In step 1717, after the signature verification is successful, the target transaction data status is returned to the enterprise object.
[0287] Description of the apparatus and device of the present disclosure
[0288] It is to be understood that, although the steps in the above-mentioned flowcharts are sequentially displayed according to the characterization of arrows, these steps are not necessarily executed in sequence according to the order of arrow characterization. Unless there is a clear description in the present embodiment, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the above-mentioned flowcharts can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the steps or stages in other steps.
[0289] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to the characteristics of the target object such as the target object attribute information or attribute information set, the permission or consent of the target object will be obtained first, and the collection, use and processing of these data will comply with the relevant laws, regulations and standards of the relevant countries and regions. In addition, when the embodiment of the present application needs to obtain the attribute information of the target object, the separate permission or separate consent of the target object will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the separate permission or separate consent of the target object, the necessary target object-related data used to enable the normal operation of the embodiment of the present application will be obtained.
[0290] Fig.18 The schematic diagram of the structure of the uplink transaction data status query device 1800 provided in the embodiment of the present disclosure. The uplink transaction data status query device 1800 includes:
[0291] The on-chain unit 1810 is used to record the target transaction on the blockchain;
[0292] A first determining unit 1820, configured to determine a target transaction data state after the target transaction is recorded on the blockchain;
[0293] A writing unit 1830 is used to write the target transaction data state into the state storage space through the trusted execution environment;
[0294] The acquiring unit 1840 is configured to acquire the target transaction data state from the state storage space through the trusted execution environment in response to a state request for the target transaction data state acquired from the target terminal, and sign the target transaction data state;
[0295] The sending unit 1850 is used to send the target transaction data status and signature to the target terminal so that the target terminal can verify the signature.
[0296] Optionally, the target transaction data state includes a state key and a state value; the state request includes a state key;
[0297] The acquisition unit 1840 is specifically used for:
[0298] Through the trusted execution environment, the state value corresponding to the state key in the state request is obtained from the state storage space to integrate the state key and the state value into the target transaction data state.
[0299] Optionally, the trusted execution environment stores a key for encrypting the target transaction data state;
[0300] The writing unit 1830 is specifically used for:
[0301] Obtain the key stored in the trusted execution environment; encrypt the state key and the state value with the key, and write the encrypted state key and the encrypted state value into the state storage space;
[0302] The acquisition unit 1840 is specifically used for:
[0303] Through the trusted execution environment, the state key in the state request is encrypted with the key to obtain the encrypted state key; the encrypted state value corresponding to the encrypted state key is obtained from the state storage space; the encrypted state value is decrypted with the key to obtain the state value.
[0304] Optionally, the key includes multiple keys corresponding to multiple object identifiers;
[0305] The writing unit 1830 is specifically used for:
[0306] Obtain the object identifier corresponding to the target transaction; encrypt the state key and state value using the key corresponding to the object identifier;
[0307] Obtain an object identifier corresponding to the status request; encrypt a status key in the status request using a key corresponding to the object identifier;
[0308] Decrypt the encrypted state value using the key corresponding to the object identifier.
[0309] Optionally, the state key includes a target data type corresponding to the target transaction data state, and a target object corresponding to the target transaction data state;
[0310] The acquisition unit 1840 is specifically used for:
[0311] Obtain the transaction data state of the target data type in the state storage space through the trusted execution environment;
[0312] In the transaction data state of the target data type, the transaction data state of the target object is obtained, and the state value is taken out from the transaction data state of the target object.
[0313] Optionally, the writing unit 1830 is specifically used for:
[0314] Writing transaction data states of the same data type into the same partition address in the state storage space through the trusted execution environment, the transaction data states including the target transaction data states;
[0315] The acquisition unit 1840 is specifically used for:
[0316] Through the trusted execution environment, the partition address corresponding to the target data type is determined, and the transaction data status is read from the partition address.
[0317] Optionally, the acquiring unit 1840 is specifically configured to:
[0318] Obtain a digest algorithm and a private key of a trusted execution environment; generate a first digest of the target transaction data state using the digest algorithm; encrypt the first digest using the private key of the trusted execution environment to obtain a signature;
[0319] Signing the target transaction data state includes: generating a first summary of the target transaction data state using a summary algorithm; obtaining a public key of a trusted execution environment; decrypting the signature using the public key to obtain a second summary; and verifying the signature based on a comparison between the first summary and the second summary.
[0320] Optionally, the acquiring unit 1840 is specifically configured to:
[0321] receiving a first packet from a target terminal, the first packet having a plurality of status requests for a plurality of transaction data states, wherein the plurality of transaction data states include a target transaction data state;
[0322] Obtain multiple transaction data states from the state storage space through the trusted execution environment, and sign the multiple transaction data states;
[0323] The sending unit 1850 is specifically used for:
[0324] Multiple transaction data statuses and signatures are packaged into a second package and sent to the target terminal.
[0325] Optionally, the first packet is generated by the target terminal in the following manner:
[0326] Get the read condition of the state read function in the object contract of the object terminal;
[0327] According to the reading condition, determine the states of multiple transaction data that need to be read;
[0328] Pack multiple transaction data states into the first package.
[0329] Optionally, the acquiring unit 1840 is specifically configured to:
[0330] receiving a plurality of status requests for a plurality of transaction data states from an object terminal, wherein each status request has an object identifier, and the plurality of transaction data states include a target transaction data state;
[0331] Put the status request corresponding to each object identifier into the queue corresponding to the object identifier;
[0332] In response to determining that the queue meets the predetermined condition, the status request in the queue is discharged, and for the discharged status request, the corresponding transaction data status is obtained from the state storage space through the trusted execution environment, and the obtained transaction data status is signed;
[0333] The sending unit 1850 is specifically used for:
[0334] The acquired transaction data status and signature are packed into a third package and sent to the object terminal corresponding to the object identifier.
[0335] Optionally, determining that the queue meets a predetermined condition includes:
[0336] If the number of status requests included in the queue reaches a first threshold, determining that the queue meets a predetermined condition;
[0337] If the number of status requests included in the queue does not reach the first threshold, but the time difference between the current time and the time when the queue was last discharged reaches the second threshold, it is determined that the queue meets the predetermined condition.
[0338] Optionally, the state storage space includes a plurality of state storage spaces corresponding to the transaction type, and the state request includes the transaction type;
[0339] The writing unit 1830 is specifically used to: determine the transaction type corresponding to the target transaction data state through the trusted execution environment; write the target transaction data state into the state storage space corresponding to the transaction type;
[0340] The acquisition unit 1840 is specifically used to: acquire the transaction type from the status request; and acquire the target transaction data state from the state storage space corresponding to the transaction type through the trusted execution environment.
[0341] Optionally, the trusted execution environment includes a plurality of trusted execution environments;
[0342] The writing unit 1830 is specifically used to: write the target transaction data state into the state storage space of each of the multiple trusted execution environments through the multiple trusted execution environments;
[0343] The acquisition unit 1840 is specifically used to: acquire the target transaction data state from the state storage space of each of the multiple trusted execution environments through the multiple trusted execution environments, and sign the target transaction data state;
[0344] The sending unit 1850 is specifically used to: send the target transaction data status and signature generated by the multiple trusted execution environments to the object terminal, so that the object terminal verifies the target transaction data status and signature obtained by the multiple trusted execution environments.
[0345] Optionally, the target transaction data status and signatures obtained based on multiple trusted execution environments are verified, including:
[0346] Perform sub-signature verification based on the target transaction data status and signature obtained from a single trusted execution environment;
[0347] If the number of successful sub-verifications is greater than the number of failed sub-verifications, then the verification is determined to be successful.
[0348] Optionally, the trusted execution environment includes a plurality of trusted execution environments;
[0349] The writing unit 1830 is specifically used to: write the target transaction data state into the state storage space of each of the multiple trusted execution environments through the multiple trusted execution environments;
[0350] The acquisition unit 1840 is specifically used to: select a target trusted execution environment from multiple trusted execution environments based on the processing speed of the trusted execution environment and the number of queued status requests; obtain the target transaction data state from the state storage space through the target trusted execution environment, and sign the target transaction data state.
[0351] Optionally, the acquiring unit 1840 is specifically configured to:
[0352] Determining a ratio of a processing speed of the trusted execution environment to a number of queued status requests;
[0353] Based on the ratio of the multiple trusted execution environments, a target trusted execution environment is selected from the multiple trusted execution environments.
[0354] Reference Fig.19 , Fig.19 The structural block diagram of the object terminal of the method for querying the status of uplink transaction data in the embodiment of the present disclosure is as follows: the object terminal includes: a radio frequency (RF) circuit 1910, a memory 1915, an input unit 1930, a display unit 1940, a sensor 1950, an audio circuit 1960, a wireless fidelity (WiFi) module 1970, a processor 1980, and a power supply 1990. Those skilled in the art can understand that Fig.19 The object terminal structure shown does not constitute a limitation on the mobile phone or computer, and may include more or fewer components than shown in the figure, or a combination of certain components, or a different arrangement of components.
[0355] RF circuit 1910 may be used for receiving and sending signals during information transmission or calls. In particular, after receiving downlink information from the base station, it is sent to processor 1980 for processing; in addition, the designed uplink data is sent to the base station.
[0356] The memory 1915 may be used to store software programs and modules. The processor 1980 executes various functional applications and data processing of the target terminal by running the software programs and modules stored in the memory 1915 .
[0357] The input unit 1930 may be used to receive input digital or character information and generate key signal input related to the setting and function control of the target terminal. Specifically, the input unit 1930 may include a touch panel 1931 and other input devices 1932.
[0358] The display unit 1940 may be used to display input information or provided information and various menus of the target terminal. The display unit 1940 may include a display panel 1941.
[0359] The audio circuit 1960, the speaker 1961, and the microphone 1962 may provide an audio interface.
[0360] In this embodiment, the processor 1980 included in the object terminal can execute the uplink transaction data status query method of the previous embodiment.
[0361] The target terminals of the embodiments of the present disclosure include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. The embodiments of the present invention can be applied to various scenarios, including but not limited to data security, blockchain, data storage, information technology, etc.
[0362] Fig. 20A block diagram of the structure of a portion of a server 2000 for implementing the method for querying the status of transaction data on the chain of an embodiment of the present disclosure. The server 2000 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPUs) 2022 (for example, one or more processors) and a memory 2032, and one or more storage media 2030 (for example, one or more mass storage devices) storing application programs 2042 or data 2044. Among them, the memory 2032 and the storage medium 2030 may be short-term storage or permanent storage. The program stored in the storage medium 2030 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server 2000. Furthermore, the central processing unit 2022 may be configured to communicate with the storage medium 2030 and execute a series of instruction operations in the storage medium 2030 on the server 2000.
[0363] The server 2000 may also include one or more power supplies 2026, one or more wired or wireless network interfaces 2050, one or more input and output interfaces 2058, and / or one or more operating systems 2041, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0364] The central processor 2022 in the server 2000 can be used to execute the on-chain transaction data status query method of the embodiment of the present disclosure.
[0365] The embodiments of the present disclosure also provide a computer-readable storage medium, which is used to store program codes, and the program codes are used to execute the on-chain transaction data status query method of each of the aforementioned embodiments.
[0366] The embodiment of the present disclosure also provides a computer program product, which includes a computer program. The processor of the computer device reads and executes the computer program, so that the computer device executes and implements the above-mentioned on-chain transaction data status query method.
[0367] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "comprises" and "comprising" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0368] It should be understood that in the present disclosure, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0369] It should be understood that in the description of the embodiments of the present disclosure, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood to not include the number, and above, below, within, etc. are understood to include the number.
[0370] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0371] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0372] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or 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 software functional units.
[0373] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.
[0374] It should also be understood that the various implementations provided in the embodiments of the present disclosure can be combined arbitrarily to achieve different technical effects.
[0375] The above is a specific description of the implementation methods of the present disclosure, but the present disclosure is not limited to the above implementation methods. Technical personnel familiar with the art can also make various equivalent modifications or substitutions without violating the spirit of the present disclosure. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present disclosure.
Claims
1. A method for querying the status of transaction data on a blockchain, characterized in that: include: Record the target transaction on the blockchain; Determining a target transaction data state after recording the target transaction on the blockchain; Writing the target transaction data state into a state storage space through a trusted execution environment; In response to obtaining a status request for the target transaction data status from the target terminal, obtaining the target transaction data status from the state storage space through the trusted execution environment, and signing the target transaction data status; The target transaction data status and the signature are sent to the object terminal so that the object terminal can verify the signature.
2. The method for querying the status of on-chain transaction data according to claim 1, characterized in that: The target transaction data state includes a state key and a state value; The status request includes the status key; The acquiring the target transaction data state from the state storage space through the trusted execution environment includes: The state value corresponding to the state key in the state request is obtained from the state storage space through the trusted execution environment, so as to integrate the state key and the state value into the target transaction data state.
3. The method for querying the status of on-chain transaction data according to claim 2, characterized in that: The trusted execution environment stores a key for encrypting the target transaction data state; The step of writing the target transaction data state into the state storage space through the trusted execution environment includes: obtaining the key stored in the trusted execution environment; encrypting the state key and the state value with the key, and writing the encrypted state key and the encrypted state value into the state storage space; The method of obtaining the state value corresponding to the state key in the state request from the state storage space through the trusted execution environment includes: encrypting the state key in the state request with the key through the trusted execution environment to obtain the encrypted state key; obtaining the encrypted state value corresponding to the encrypted state key from the state storage space; and decrypting the encrypted state value with the key to obtain the state value.
4. The method for querying the status of on-chain transaction data according to claim 3, characterized in that: The key includes a plurality of keys corresponding to a plurality of object identifiers; The step of encrypting the state key and the state value with the key comprises: obtaining the object identifier corresponding to the target transaction; encrypting the state key and the state value with the key corresponding to the object identifier; The step of encrypting the state key in the state request with the key comprises: obtaining the object identifier corresponding to the state request; and encrypting the state key in the state request with the key corresponding to the object identifier; The decrypting the encrypted state value by using the key includes: decrypting the encrypted state value by using the key corresponding to the object identifier.
5. The method for querying the status of on-chain transaction data according to claim 2, characterized in that: The state key includes a target data type corresponding to the target transaction data state, and a target object corresponding to the target transaction data state; The obtaining, from the state storage space, the state value corresponding to the state key in the state request through the trusted execution environment, includes: Acquiring, through the trusted execution environment, a transaction data state of the target data type in the state storage space; In the transaction data state of the target data type, the transaction data state of the target object is acquired, and the state value is taken out from the transaction data state of the target object.
6. The method for querying the status of on-chain transaction data according to claim 5, characterized in that: The step of writing the target transaction data state into the state storage space through the trusted execution environment comprises: writing transaction data states of the same data type into the same partition address in the state storage space through the trusted execution environment, the transaction data states including the target transaction data state; The acquiring, through the trusted execution environment, the transaction data state of the target data type in the state storage space includes: determining, through the trusted execution environment, the partition address corresponding to the target data type, and reading the transaction data state in the partition address.
7. The method for querying the status of on-chain transaction data according to claim 1, characterized in that: The signing of the target transaction data state includes: obtaining a digest algorithm and a private key of the trusted execution environment; generating a first digest of the target transaction data state using the digest algorithm; encrypting the first digest using the private key of the trusted execution environment to obtain the signature; The verifying of the signature includes: using the digest algorithm to generate a first digest of the target transaction data state; obtaining a public key of the trusted execution environment; decrypting the signature with the public key to obtain a second digest; and verifying the signature based on a comparison between the first digest and the second digest.
8. The method for querying the status of on-chain transaction data according to claim 1, characterized in that: The step of obtaining the target transaction data state from the state storage space through the trusted execution environment in response to a state request for the target transaction data state obtained from the target terminal, and signing the target transaction data state includes: receiving a first packet from the target terminal, the first packet having a plurality of status requests for a plurality of transaction data states, wherein the plurality of transaction data states include the target transaction data state; Acquire the plurality of transaction data states from the state storage space through the trusted execution environment, and sign the plurality of transaction data states; The sending the target transaction data state and the signature to the target terminal includes: The plurality of transaction data states and the signature are packaged into a second package and sent to the target terminal.
9. The method for querying the status of transaction data on the chain according to claim 8, characterized in that: The first packet is generated by the target terminal in the following manner: Obtaining a read condition of a status read function in an object contract of the object terminal; According to the reading condition, determining a plurality of transaction data states that need to be read; Status requests for a plurality of the transaction data statuses are packaged into the first packet.
10. The method for querying the status of on-chain transaction data according to claim 1, characterized in that: The step of obtaining the target transaction data state from the state storage space through the trusted execution environment in response to a state request for the target transaction data state obtained from the target terminal, and signing the target transaction data state includes: receiving a plurality of status requests for a plurality of transaction data states from the object terminal, wherein each of the status requests has an object identifier, and the plurality of transaction data states include the target transaction data state; Put the status request corresponding to each object identifier into a queue corresponding to the object identifier; In response to determining that the queue meets a predetermined condition, the status request in the queue is discharged, and for the discharged status request, the corresponding transaction data status is obtained from the status storage space through the trusted execution environment, and the obtained transaction data status is signed.
11. The method for querying the status of on-chain transaction data according to claim 10, characterized in that: The determining that the queue meets a predetermined condition includes: If the number of status requests included in the queue reaches a first threshold, determining that the queue meets a predetermined condition; If the number of status requests included in the queue does not reach the first threshold, but the time difference between the current time and the time when the queue was last discharged reaches the second threshold, it is determined that the queue meets the predetermined condition.
12. The method for querying the status of on-chain transaction data according to claim 1, characterized in that: The state storage space includes a plurality of state storage spaces corresponding to transaction types, and the state request includes the transaction type; The step of writing the target transaction data state into a state storage space through a trusted execution environment comprises: determining a transaction type corresponding to the target transaction data state through a trusted execution environment; and writing the target transaction data state into a state storage space corresponding to the transaction type; The response to obtaining a status request for the target transaction data status from the object terminal, obtaining the target transaction data status from the status storage space through the trusted execution environment, includes: obtaining the transaction type from the status request; and obtaining the target transaction data status from the status storage space corresponding to the transaction type through the trusted execution environment.
13. The method for querying the status of on-chain transaction data according to claim 1, characterized in that: The trusted execution environment includes multiple trusted execution environments; The step of writing the target transaction data state into a state storage space through a trusted execution environment comprises: writing the target transaction data state into the state storage space of each of the plurality of trusted execution environments through the plurality of trusted execution environments; The step of obtaining the target transaction data state from the state storage space through the trusted execution environment and signing the target transaction data state comprises: obtaining the target transaction data state from the state storage spaces of the respective trusted execution environments through the multiple trusted execution environments and signing the target transaction data state; The sending of the target transaction data status and the signature to the object terminal so that the object terminal verifies the signature comprises: the multiple trusted execution environments sending the target transaction data status and the signature generated by each of them to the object terminal so that the object terminal verifies the signature based on the target transaction data status and the signature obtained by the multiple trusted execution environments.
14. The method for querying the status of on-chain transaction data according to claim 13, characterized in that: The verifying the target transaction data state and the signature obtained based on the multiple trusted execution environments includes: Performing sub-signature verification based on the target transaction data state and the signature obtained by the single trusted execution environment; If the number of successful sub-verifications is greater than the third threshold, the verification is determined to be successful.
15. The method for querying the status of on-chain transaction data according to claim 1, characterized in that: The trusted execution environment includes multiple trusted execution environments; The step of writing the target transaction data state into a state storage space through a trusted execution environment comprises: writing the target transaction data state into the state storage space of each of the plurality of trusted execution environments through the plurality of trusted execution environments; The step of obtaining the target transaction data state from the state storage space through the trusted execution environment and signing the target transaction data state comprises: selecting a target trusted execution environment from a plurality of the trusted execution environments based on a processing speed of the trusted execution environment and a number of queued status requests; obtaining the target transaction data state from the state storage space through the target trusted execution environment and signing the target transaction data state.
16. The method for querying the status of on-chain transaction data according to claim 15, characterized in that: The step of selecting a target trusted execution environment from a plurality of trusted execution environments based on a processing speed of the trusted execution environment and a number of queued status requests includes: Determining a ratio of a processing speed of the trusted execution environment to a number of queued state requests; Based on the ratio of the plurality of trusted execution environments, a target trusted execution environment is selected from the plurality of trusted execution environments.
17. A device for querying the status of transaction data on a chain, characterized in that: include: The on-chain unit is used to record the target transaction on the blockchain; A first determining unit, configured to determine a target transaction data state after recording the target transaction on the blockchain; A writing unit, used for writing the target transaction data state into the state storage space through a trusted execution environment; an acquiring unit, configured to, in response to a status request for the target transaction data status acquired from the object terminal, acquire the target transaction data status from the status storage space through the trusted execution environment, and sign the target transaction data status; A sending unit is used to send the target transaction data status and the signature to the object terminal so that the object terminal can verify the signature.
18. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method for querying the status of up-chain transaction data according to any one of claims 1 to 16 is implemented.
19. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for querying the status of up-chain transaction data according to any one of claims 1 to 16 is implemented.
20. A computer program product, comprising a computer program, wherein the computer program is read and executed by a processor of a computer device, so that the computer device executes the method for querying the status of on-chain transaction data according to any one of claims 1 to 16.
Citation Information
Cited By
Trusted monitoring and auditing system fusing TEE and block chain
CN120471723A
