TEE-based alliance chain intelligent contract integrity protection method and system
By adopting TEE-based methods in the alliance chain to generate and verify trusted credentials for smart contracts, the problem of smart contract integrity protection is solved and efficient and secure transaction execution is achieved.
Patent Information
- Application Number
- CN202411461741.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-10-18
AI Technical Summary
The integrity of smart contracts in existing alliance chains is difficult to effectively protect, especially when the endorsement nodes are not trusted, resulting in the trustworthy execution of transactions being threatened.
Using a TEE-based method, the contract execution of trusted credentials are generated for contract execution with contract integrity status information and verified the integrity of these credentials on each node of the consortium chain to ensure the trustworthiness of the transaction's contract execution.
It realizes comprehensive protection of alliance chain smart contracts, improves verification level, ensures the security and reliability of transactions, and has good universality, scalability and efficiency.
Smart Images

Figure CN119513859A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of security technology of alliance chains, and specifically to a method and system for protecting the integrity of alliance chain smart contracts based on TEE. Background Art
[0002] The consortium chain is maintained by different organizations and can ensure the security, reliability and traceability of transactions between multiple interest entities. In contrast to public blockchains such as Bitcoin and Ethereum, the consortium chain network consists of known participants, but these participants do not necessarily trust each other. In the consortium chain, all on-chain transactions are executed through smart contracts, which are executable computer codes that run in the specific environment of the blockchain system and are distributed on different blockchain nodes. Smart contracts are usually programmed in high-level programming languages (such as Solidity), then compiled into binary code or bytecode, and executed in Docker containers or contract virtual machines to reduce potential vulnerabilities that may affect the security of the platform. Fabric, as the most famous consortium chain system, executes smart contracts in Docker containers and supports various high-level programming languages (such as Go, Java, and Node.js) to implement customizable contract logic. Fabric's smart contracts usually run in stateless containers and need to interact with Peer nodes. The validity of transactions in Fabric is driven by the endorsement policy of the smart contract, and only transactions that meet the endorsement policy are considered valid. Fabric's transaction execution mainly includes the following stages: Phase I. Before calling a smart contract function, the smart contract must be installed and instantiated on the Peer node (i.e., started in a Docker container). Phase 2. After the smart contract is installed and instantiated, the client (application) can send a request (transaction proposal) to the Peer node to call the smart contract function. This phase is called execution or endorsement, where the Peer executes the called smart contract function and sends the response back to the client. The transaction response is signed by the Peer and contains the execution response message as well as the read-write set. The read set represents all key-value pairs that the Peer has queried from the ledger through GetState during execution. The write set contains all key-value pair updates generated by the Peer through PutState. When the client collects enough responses according to the endorsement policy, it sends them to the sorting service. Phase 3. The sorting service uniformly sorts the transactions and puts them into a block, and sends the block to all Peer nodes. Phase 4. In the verification phase, the Peer node checks whether the transaction meets the endorsement policy and whether there are read-write conflicts between different transactions, and finally records the transaction on the ledger. The ledger has two components: the blockchain and the world state. The world state is a pluggable database that stores the current values of the keys contained in the blockchain, thus enabling efficient retrieval of the latest state.
[0003] In traditional consortium chains represented by Fabric, smart contracts run within a set of predefined endorsement nodes. By tampering with the endorsement results, it is greatly reduced for attackers to affect the integrity of smart contract calculations. This is because the validity of the contract results is mainly determined by the endorsement nodes, and the endorsement nodes are only a subset of all peer nodes. Therefore, the reduced degree of decentralization leads to reduced security. At the same time, it is difficult for non-endorsing nodes to verify the correctness of contract execution, which will lead to new security and trust issues. Therefore, it is an important issue to ensure the integrity of smart contracts and the trusted execution of transactions on consortium chains. On the other hand, there is currently a lack of models and methods for evaluating contract integrity, making it difficult to evaluate the contract integrity and transaction security changes during the contract execution process when introducing different security mechanisms or under different consortium chain organizations. Existing solutions based on TEE protection contracts all use isolation to protect, but there are the following disadvantages to protecting contract execution based on TEE isolation: First, since the computing resources in TEE are usually limited, deploying a large number of contracts or contracts with large amounts of code in TEE and saving the relevant states of the contract will cause a bottleneck in system performance, especially frequent world switching will significantly reduce system performance. Secondly, existing TEEs usually only natively support C language, and lack sufficient support for popular and complex high-level programming languages used in smart contracts. This will increase the difficulty of deploying smart contracts written in different types of programming languages into TEEs, making the smart contract development and deployment process complicated. In addition, protecting contracts based on isolation will result in more and more contract codes and states managed by TEEs, and vulnerabilities in smart contracts may expand the attack surface of TEEs themselves.
[0004] As a highly secure technology, TEE can create an isolated execution environment for upper-level software to prevent interference and attacks from malware. TEE uses hardware-level security mechanisms to ensure that the code and data stored in it are not tampered with without authorization, thereby ensuring the integrity of key data and code. Therefore, the integrity protection of TEE plays a vital role in ensuring the processing of sensitive information and enhancing the security defense capabilities of the system, providing solid security protection for various application scenarios. Therefore, the integrity protection of alliance chain smart contracts based on TrustZone technology has good application prospects and is a key technical issue that needs to be studied urgently. Summary of the invention
[0005] Technical problem to be solved by the present invention: In view of the above-mentioned problems of the prior art, a method and system for integrity protection of a consortium chain smart contract based on TEE is provided. The present invention aims to achieve integrity protection of the consortium chain smart contract, which has the advantages of comprehensive protection, high verification level, security and reliability, good versatility, strong scalability and high efficiency.
[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is: A TEE-based alliance chain smart contract integrity protection method includes the following steps: S1, generates a trusted certificate with contract integrity status information for the transaction obtained by contract execution ; S2, will be accompanied by a trusted certificate Generate blocks after sorting transactions and broadcast the blocks to all nodes in the alliance chain; S3, each node in the alliance chain verifies the trusted credentials carried by the transaction in the block The integrity of the transaction is verified to verify the credibility of the contract execution of the transaction. Depending on whether the verification is successful, the transaction is marked as a valid transaction or an invalid transaction and submitted to the alliance chain.
[0007] Optionally, in step S1, a trusted certificate with contract integrity status information is generated for the transaction obtained by executing the contract. When , the generating function expression of the contract integrity state is: , In the above formula, is the contract integrity status on the consortium chain, ST =1 means that the integrity of the contract on the alliance chain has not been destroyed, that is, the execution result of the contract meets expectations. ST =-1 means the integrity of the contract on the alliance chain is destroyed. Representation Statistics The number of elements whose median value is 1, is the set of contract integrity status of all organizations, , The minimum number of endorsing organizations required to reach an endorsement agreement between organizations. " indicates AND logic operation, ~ They are No. 1~ The contract integrity status of an organization, is the organization set of the alliance chain, any j Contract integrity status of an organization satisfy , Indicates j The contractual integrity of the organization has not been compromised, Indicates j The contractual integrity of an organization is compromised and there is: , In the above formula, Representation Statistics The number of elements whose median value is 1, For thej The contract integrity status set of the endorsement nodes of each organization, , For the j The set of endorsement nodes within an organization, any i The contract integrity status of the endorsing nodes satisfy , Indicates i The contract integrity of the endorsing nodes has not been compromised. Indicates i The contract integrity of the endorsing nodes is compromised. For the j The minimum number of endorsement nodes that an organization reaches for valid endorsement, and the contract integrity status on the consortium chain , all j Contract integrity status of an organization And all i The contract integrity status of the endorsing nodes Form three levels of contract integrity status in the alliance chain.
[0008] Optionally, in step S1, a trusted certificate with contract integrity status information is generated for the transaction obtained by executing the contract. When the trusted certificate The calculation function expression is: , In the above formula, is a transaction identifier list, the format of which is n >, where H1~H n is a unique identifier for n transactions, A list of transaction identifiers The associated smart contract integrity status information, v(S) includes the set of associated smart contracts in the transaction identifier list I <S1,...,S n >Each smart contract S i The contract id, hash value and security status; The platform security vector is the current security state of the system components on the platform, which is composed of the trusted state of the system components stored in the TEE and the Merkle root of the system component list items in the security object list L; It is a random number generated by TEE to prevent replay attacks. Sign the TEE.
[0009] Optionally, step S1 includes: S1.1, the client sends a proposal to the endorsing node; S1.2, the endorsing node executes the proposal through a smart contract; S1.3, the endorsing node creates a trusted certificate with contract integrity information ; S1.4, the endorsing node returns a trusted certificate The endorsement result is given to the client; S1.5, client verifies endorsement result and trusted certificate , if the verification is successful, jump to the next step; S1.6, the client will carry a trusted certificate The transactions are submitted to the sorting service for sorting.
[0010] Optionally, before step S1.2, the following steps are included: S101, the endorsement node inserts a hook function Hook into the key component used to control the operation of the contract before startup; S102, the endorsement node loads a trusted proxy module that can be connected to TEE through the hook function Hook before startup; S103, the endorsement node first starts the trusted proxy module when starting; S104, the trusted proxy module of the endorsement node establishes a connection and session with the TEE of the endorsement node. If the connection and session are established successfully, jump to the next step; otherwise, end and exit; S105, TEE initializes the integrity measurement module, the security data management module and the key management module, wherein the integrity measurement module is used to perform integrity measurement, the security data management module is used to manage the security data obtained by the integrity measurement through the security object list L, the table items of the security object list L include objects, hash values and their trusted status, and the key management module is used to provide the generation of trusted credentials Required signatures; S106, TEE measures the key components on the REE side for controlling the operation of the contract based on the security object list L built into the security data management module; S107, TEE updates the status of the security object list L based on the measurement results, and updates the trusted status of the system components and the Merkle root of the system component list items in the security object list L based on the latest status of the security object list L. If the status is normal, jump to the next step; otherwise, end and exit; S108, after the endorsement node starts the service, it continues to run and receive proposals from the client; if a transaction proposal is received from the client, it jumps to step S1.2; if a contract installation proposal is received, it jumps to step S109; if a proposal for instantiation of an installed contract is received, it jumps to step S113; if a proposal for updating an installed contract is received, it jumps to step S117; S109, the endorsing node parses the contract code and signature of the smart contract in the received contract installation proposal and passes it to TEE; S110, TEE verifies the contract code and signature of the proposed smart contract through the integrity measurement module. If the code and signature verification of the proposed contract pass, jump to the next step; otherwise, it is determined that the installation fails and jump to step S112; S111, the endorsement node stores the code of the smart contract to the platform, and TEE registers the contract to the contract item of the security object list L, determines that the installation is successful, and jumps to step S112; S112, the endorsement node sends the result of installation success or failure as a response with the TEE signature to the client, and jumps to step S108; S113, the endorsing node parses the instantiation request and signature in the received instantiation proposal and passes it to the feasible execution environment TEE; S114, the feasible execution environment TEE re-measures the smart contract specified in the instantiation proposal and updates the corresponding contract entry in the security object list L. If the integrity of the smart contract is not destroyed, jump to the next step; otherwise, it is determined that the instantiation fails and jump to step S116; S115, the endorsement node runs the instantiation of the smart contract, and during the operation of the smart contract, the feasible execution environment TEE regularly monitors the security status of the contract; if the instantiation is successful, jump to step S116; S116, the endorsing node sends the instantiation success or failure result as a response with the feasible execution environment TEE signature to the client, and jumps to step S108; S117, before the contract is updated, the installation process of the new contract is completed. The endorsement node parses the update request and signature in the proposal for the update of the installed smart contract and passes it to the feasible execution environment TEE; S118, the feasible execution environment TEE verifies the specified contract code and signature in the contract update proposal through the integrity measurement module. If the verification is successful, jump to the next step; otherwise, the update is judged to have failed and jump to step S121; S119, the endorsement node deactivates the old version of the smart contract, and the feasible execution environment TEE checks the status of the old version of the smart contract and updates the security object list L. If the old version of the contract is deactivated, jump to the next step; otherwise, it is determined that the update fails and jumps to step S121; S120, the endorsement node starts the new version of the smart contract, updates the corresponding contract item status in the security object list L in the feasible execution environment TEE, determines that the update is successful, and jumps to step S121; S121, the endorsing node sends the update success or failure result as a response to the client with the feasible execution environment TEE signature attached, and jumps to step S108.
[0011] Optionally, in step S1.2, the endorsement node executes the proposal through the smart contract, which means that the endorsement node executes the proposal through the local smart contract S or calls other smart contracts S' through the local smart contract S to execute the proposal, wherein calling other smart contracts S' through the local smart contract S to execute the proposal includes: S201, smart contract S creates a trusted certificate with contract integrity information ; S202, smart contract S sends a trusted certificate to other smart contract S' The calling parameters; S203, smart contract S' verifies the trusted credential If the verification is successful, jump to the next step; otherwise, report an error and exit; S204, the smart contract S' generates the execution result and creates a trusted certificate with contract integrity information ; S205, the smart contract S' will carry a trusted certificate The response is returned to the smart contract S; S206, smart contract S verifies the trusted credential If the verification is successful, jump to the next step; otherwise, report an error and exit; S207, smart contract S will continue to execute based on the execution result returned by smart contract S', obtain the final execution result of smart contract S and return the execution result to the endorsement node.
[0012] Optionally, step S2 will carry a trusted credential The transaction sorting includes that after receiving a batch of transactions, the sorting service determines an order for the batch of transactions through a preset consensus algorithm and links them to an ordered block; step S3 also includes verification of endorsement and verification of read-write sets. The verification of endorsement means that after a node receives a new block, it checks whether the endorsement result and trusted credential of each transaction in the block meet the endorsement policy and credibility requirements associated with it. The verification of read-write sets means checking whether there is a conflict between the read-write set version of the transaction and the key-value pair.
[0013] In addition, the present invention also provides a TEE-based alliance chain smart contract integrity protection system, including an interconnected microprocessor and a memory, and the microprocessor is programmed or configured to execute the TEE-based alliance chain smart contract integrity protection method.
[0014] In addition, the present invention also provides a computer-readable storage medium, which stores a computer program or instruction, and the computer program or instruction is programmed or configured to execute the TEE-based alliance chain smart contract integrity protection method through a processor.
[0015] In addition, the present invention also provides a computer program product, including a computer program or instructions, which are programmed or configured to execute the TEE-based alliance chain smart contract integrity protection method through a processor.
[0016] Compared with the prior art, the present invention has the following advantages: The TEE-based alliance chain smart contract integrity protection method of the present invention includes generating a trusted certificate with contract integrity status information for the transaction obtained by contract execution. , will be accompanied by a trusted certificate After the transactions are sorted, blocks are generated and broadcast to all nodes in the alliance chain. Each node in the alliance chain verifies the trusted credentials carried by the transactions in the block. The integrity of the contract is verified to verify the credibility of the transaction execution. The transaction is marked as a valid transaction or an invalid transaction based on whether the verification is successful and submitted to the alliance chain. The present invention can realize the integrity protection of the alliance chain smart contract, and has the advantages of comprehensive protection, high verification level, safety and reliability, good versatility, strong scalability and high efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 Schematic diagram of the basic flow of the method of the embodiment of the present invention.
[0018] Figure 2 The figure is a schematic diagram of the working principle of the method according to the embodiment of the present invention.
[0019] Figure 3 Schematic diagram of the normal world and the secure world of the endorsement node in an embodiment of the present invention. DETAILED DESCRIPTION
[0020] Since the contracts of blockchain systems are carried out through distributed computing, single-point attacks are usually ineffective, so it is difficult to evaluate their security changes. In order to evaluate the scope of attacks on contract integrity and the changes in the security of alliance chain transactions after the introduction of security mechanisms such as contract integrity protection, this paper proposes a TEE-based alliance chain smart contract integrity protection method-level system for endorsement mechanisms. Specifically, Figure 1 As shown, the TEE-based alliance chain smart contract integrity protection method of this embodiment includes the following steps: S1, generates a trusted certificate with contract integrity status information for the transaction obtained by contract execution ; S2, will be accompanied by a trusted certificate Generate blocks after sorting transactions and broadcast the blocks to all nodes in the alliance chain; S3, each node in the alliance chain verifies the trusted credentials carried by the transaction in the block The integrity of the transaction is verified to verify the credibility of the contract execution of the transaction. Depending on whether the verification is successful, the transaction is marked as a valid transaction or an invalid transaction and submitted to the alliance chain.
[0021] In step S1 of this embodiment, a trusted certificate with contract integrity status information is generated for the transaction obtained by contract execution. When , the generating function expression of the contract integrity state is: , In the above formula, is the contract integrity status on the consortium chain, ST =1 means that the integrity of the contract on the alliance chain has not been destroyed, that is, the execution result of the contract meets expectations. ST =-1 means the integrity of the contract on the alliance chain is destroyed. Representation Statistics The number of elements whose median value is 1, is the set of contract integrity status of all organizations, , The minimum number of endorsing organizations required to reach an endorsement agreement between organizations. " indicates AND logic operation, ~ They are No. 1~ The contract integrity status of an organization, is the organization set of the alliance chain, which can be expressed as: , In the above formula, ~ For the 1st to nth organizations in the alliance chain, ; The contract integrity status of any j-th organization satisfy , Indicates that the contract integrity of the jth organization has not been compromised, It means that the contract integrity of the jth organization is destroyed, and: , In the above formula, Representation Statistics The number of elements whose median value is 1, For the j The contract integrity status set of the endorsement nodes of an organization can be expressed as: , In the above formula, For the j The set of endorsement nodes within an organization, any i The contract integrity status of the endorsing nodes satisfy , Indicates i The contract integrity of the endorsing node is not compromised (i.e., the result obtained by the endorsing node is as expected), Indicates i The contract integrity of an endorsement node is compromised (i.e., the result given by the endorsement node does not meet expectations). For the j The minimum number of endorsement nodes required for an organization to reach a valid endorsement. Since malicious nodes hope to tamper with the final transaction, it is assumed here that the malicious results given by malicious endorsement nodes are all the same value, which will make it easier for attackers to affect the final integrity of the contract.
[0022] In this embodiment, a new trusted credential-based The transaction execution and verification mechanism is used to enhance the trusted verification of contract integrity between endorsement nodes, thereby ensuring the reliability and trustworthiness of transactions. It represents the integrity and status of the contract-based transaction Tx execution, involves the integrity and status of the contract and the platform, and reflects the degree of trust between them. As an optional implementation, in step S1 of this embodiment, a trusted certificate with contract integrity status information is generated for the transaction obtained by contract execution. When the trusted certificate The calculation function expression is: , In the above formula, is a transaction identifier list, the format of which is n >, where H1~H n is a unique identifier for n transactions, A list of transaction identifiers The associated smart contract integrity status information, v(S) includes the set of associated smart contracts in the transaction identifier list I <S1,...,S n >Each smart contract S i The contract id, hash value and security status; The platform security vector is the current security state of the system components on the platform, which is composed of the trusted state of the system components stored in the feasible execution environment TEE and the Merkle root of the system component list items in the security object list L; A random number generated by the TEE to prevent replay attacks. Sign the feasible execution environment TEE. Before receiving the transaction, the endorsing node must initialize and complete the trusted contract deployment. During the contract execution phase, when a proposal completes the contract execution, the execution result will be attached with the feasible execution environment TEE's trusted certificate for the transaction and contract integrity. . In the transaction sorting phase, carry trusted credentials The transactions are sorted and broadcast to all nodes. During the transaction verification and submission phase, the nodes verify the trusted credentials. The integrity of the contract is checked to confirm the credibility of the contract execution, and then the endorsement and read-write set verification operations are completed, and the successfully verified valid transactions are submitted to the blockchain.
[0023] like Figure 2 As shown, in this embodiment, step S1 includes: S1.1, the client sends a proposal to the endorsing node; S1.2, the endorsing node executes the proposal through a smart contract; S1.3, the endorsing node creates a trusted certificate with contract integrity information ; S1.4, the endorsing node returns a trusted certificate The endorsement result is given to the client; S1.5, client verifies endorsement result and trusted certificate , if the verification is successful, jump to the next step; S1.6, the client will carry a trusted certificate The transactions are submitted to the sorting service for sorting.
[0024] Figure 3 This is a schematic diagram of the normal world and secure world of the endorsement node in this embodiment. The normal world is the world where the rich execution environment REE is located, and the secure world is the world where the feasible execution environment TEE is located. The normal world and the secure world can call and switch with each other through the security monitor SMC.
[0025] In this embodiment, the steps before step S1.2 include: S101, the endorsement node inserts a hook function Hook into the key component used to control the operation of the contract before startup; S102, the endorsement node loads a trusted proxy module that can be connected to the feasible execution environment TEE through the hook function Hook before startup; S103, the endorsement node first starts the trusted proxy module when starting; S104, the trusted proxy module of the endorsement node establishes a connection and session with the feasible execution environment TEE of the endorsement node. If the connection and session are established successfully, jump to the next step; otherwise, end and exit; S105, the feasible execution environment TEE initializes the integrity measurement module, the security data management module and the key management module, wherein the integrity measurement module is used to perform integrity measurement, the security data management module is used to manage the security data obtained by the integrity measurement through the security object list L, the table items of the security object list L include objects, hash values and their trusted states (abbreviated as states in the figure), and the key management module is used to provide the generation of trusted credentials Required signatures; S106, the feasible execution environment TEE measures the key components on the REE side for controlling the operation of the contract based on the security object list L built into the security data management module; S107, the feasible execution environment TEE updates the status of the security object list L based on the measurement results, and updates the trusted status of the system components and the Merkle root of the system component list items in the security object list L based on the latest status of the security object list L. If the status is normal, jump to the next step; otherwise, end and exit; S108, after the endorsement node starts the service, it continues to run and receive proposals from the client; if a transaction proposal is received from the client, it jumps to step S1.2; if a contract installation proposal is received, it jumps to step S109; if a proposal for instantiation of an installed contract is received, it jumps to step S113; if a proposal for updating an installed contract is received, it jumps to step S117; S109, the endorsing node parses the contract code and signature of the smart contract in the received contract installation proposal and passes it to the feasible execution environment TEE; S110, the feasible execution environment TEE verifies the contract code and signature of the proposed smart contract through the integrity measurement module. If the code and signature verification of the proposed contract pass, jump to the next step; otherwise, it is determined that the installation fails and jump to step S112; S111, the endorsement node stores the code of the smart contract to the platform, and the feasible execution environment TEE registers the contract to the contract table item of the security object list L, determines that the installation is successful, and jumps to step S112; S112, the endorsement node sends the result of installation success or failure as a response to the client with the signature of the feasible execution environment TEE, and jumps to step S108; S113, the endorsing node parses the instantiation request and signature in the received instantiation proposal and passes it to the feasible execution environment TEE; S114, the feasible execution environment TEE re-measures the smart contract specified in the instantiation proposal and updates the corresponding contract entry in the security object list L. If the integrity of the smart contract is not destroyed, jump to the next step; otherwise, it is determined that the instantiation fails and jump to step S116; S115, the endorsement node runs the instantiation of the smart contract, and during the operation of the smart contract, the feasible execution environment TEE regularly monitors the security status of the contract; if the instantiation is successful, jump to step S116; S116, the endorsing node sends the instantiation success or failure result as a response with the feasible execution environment TEE signature to the client, and jumps to step S108; S117, before the contract is updated, the installation process of the new contract is completed. The endorsement node parses the update request and signature in the proposal for the update of the installed smart contract and passes it to the feasible execution environment TEE; S118, the feasible execution environment TEE verifies the specified contract code and signature in the contract update proposal through the integrity measurement module. If the verification is successful, jump to the next step; otherwise, the update is judged to have failed and jump to step S121; S119, the endorsement node deactivates the old version of the smart contract, and the feasible execution environment TEE checks the status of the old version of the smart contract and updates the security object list L. If the old version of the contract is deactivated, jump to the next step; otherwise, it is determined that the update fails and jumps to step S121; S120, the endorsement node starts the new version of the smart contract, updates the corresponding contract item status in the security object list L in the feasible execution environment TEE, determines that the update is successful, and jumps to step S121; S121, the endorsing node sends the update success or failure result as a response to the client with the feasible execution environment TEE signature attached, and jumps to step S108.
[0026] In this embodiment, smart contracts can access other smart contracts to call other functions or traverse different ledgers (interoperability), thereby achieving complex business modularization and circumventing the resource limitations of a single contract. The contract execution process often involves multiple smart contracts. For example, in a business contract execution workflow involving multi-party asset transactions and loans, the commercial contract will call different loan contracts for execution through a bridge contract. During the execution process, the lack of trust between smart contracts may cause errors to propagate along the contract call chain. Therefore, during the transaction execution process of cross-contract calls, it is necessary to verify the integrity of the smart contract and the contract execution platform during the contract execution to ensure the trusted execution of the contract call chain. In the cross-contract call scenario, the integrity of the contract can be verified through the trusted credentials of the feasible execution environment TEE, thereby ensuring the reliable propagation of the integrity of the contract call chain. Specifically, in step S1.2 of this embodiment, the endorsement node executes the proposal through the smart contract, which means that the endorsement node executes the proposal through the local smart contract S or calls other smart contracts S' through the local smart contract S across contracts to execute the proposal, where the execution proposal of other smart contracts S' through the local smart contract S across contracts includes: S201, smart contract S creates a trusted certificate with contract integrity information ; S202, smart contract S sends a trusted certificate to other smart contract S' The calling parameters; S203, smart contract S' verifies the trusted credential If the verification is successful, jump to the next step; otherwise, report an error and exit; S204, the smart contract S' generates the execution result and creates a trusted certificate with contract integrity information ; S205, the smart contract S' will carry a trusted certificate The response is returned to the smart contract S; S206, smart contract S verifies the trusted credential If the verification is successful, jump to the next step; otherwise, report an error and exit; S207, smart contract S will continue to execute based on the execution result returned by smart contract S', obtain the final execution result of smart contract S and return the execution result to the endorsement node.
[0027] In this embodiment, the trusted credentials will be carried in step S2 The transaction sorting includes that after receiving a batch of transactions, the sorting service determines an order for the batch of transactions through a preset consensus algorithm and links them to an ordered block; step S3 also includes verification of endorsement and verification of read-write sets. The verification of endorsement means that after a node receives a new block, it checks whether the endorsement result and trusted credential of each transaction in the block meet the endorsement policy and credibility requirements associated with it. The verification of read-write sets means checking whether there is a conflict between the read-write set version of the transaction and the key-value pair.
[0028] When the system is first deployed, the endorsement node (Peer node) will start the trusted proxy module at startup. The trusted proxy module maintains a secure context and session with the TEE to access secure measurement services. The hook function Hooks inserted in the Peer node calls the trusted proxy module, which in turn calls the feasible execution environment TEE to trigger measurement events. The design of the hook function Hooks decouples the Peer from the original logic, ensuring that the normal execution logic of the original Peer node is not affected, and allows flexible customization of the logic. The hook function Hooks inserted in the Peer performs measurement verification based on the feasible execution environment TEE at key points in the life cycle of the smart contract. The trusted proxy module will parse the events triggered by the hook function Hooks, execute the corresponding measurement behavior, and issue an alarm when malicious behavior is detected. When the trusted proxy module establishes a connection with the feasible execution environment TEE, the feasible execution environment TEE verifies the integrity of the Peer node and system components to ensure that the Peer is trustworthy. A forged Peer will not be able to establish a connection with the feasible execution environment TEE and will not be able to generate trusted credentials. The transaction collector in the trusted proxy module ensures that trusted credentials can be generated in batches for transactions within a specified time period, thereby improving the efficiency of trusted credential generation. The life cycle of a trusted contract measured and verified by the feasible execution environment TEE is as follows: Phase 1: Contract registration. To ensure the integrity and reliability of the contract, the contract must first be registered in the feasible execution environment TEE. After the developer submits the contract code, it is sent to the endorsement node for installation. During installation, the feasible execution environment TEE verifies the signature of the contract and then stores the benchmark value information in the secure object list L of the feasible execution environment TEE. Phase 2: Instantiation verification. Before the contract is instantiated, the feasible execution environment TEE will re-measure and verify the integrity of the contract. If the measurement result of the contract matches the contract benchmark value stored in the secure object list L at this time, the contract can be successfully instantiated and the state of the secure object list L will be updated. On the contrary, if the verification fails, the instantiation of the contract will be rejected. Phase 3: Runtime monitoring. After the contract is started, the feasible execution environment TEE monitors the contract security status, updates and maintains the integrity status of the contract. Phase 4: Contract update. When a contract is updated, the new contract needs to be re-verified by the feasible execution environment TEE. The feasible execution environment TEE needs to ensure that the new contract can be instantiated only after the original contract is deactivated, and update the security object list L state. The result of the contract update will be returned to the customer with a feasible execution environment TEE certificate.
[0029] The endorsement policy in this embodiment defines the minimum set of organizations required to endorse a transaction to make it valid. The endorsement policy of a contract in Fabric can be a flexible combination of AND, OR, and OutOf, where the logical combination of AND and OR can be represented by the general OutOf, so OutOf is used as an example in this embodiment. The condition for a successful contract endorsement is that there is only one set of nodes that meet the endorsement policy and give the same execution result with a valid signature. Endorsement policy: OutOf(2,'Org1.member','Org2.member', 'Org3.member') Any two members of the organization (member') in Org1, Org2, and Org3 are required to give the same contract execution results and provide valid signatures. The following is the definition of contract integrity and contract integrity status in the consortium chain: Definition 1: Contract integrity: Contracts on the consortium chain execute transactions and give expected calculation results.
[0030] The contract integrity status on the alliance chain in this embodiment , the contract integrity status of all j-th organizations And all i The contract integrity status of the endorsing nodes The three levels of contract integrity in the alliance chain are formed, so that the contract integrity can be divided into three levels: node level, organization level, and inter-organization level. The node-level contract integrity refers to the contract of a single endorsement node giving the expected calculation result. The intra-organization contract integrity refers to the endorsement node contract within the organization giving the expected calculation result that meets the endorsement success condition. The inter-organization contract integrity refers to the calculation result on the alliance chain that meets the endorsement success condition and meets the expectation, that is, the final contract integrity. The node-level contract integrity will affect the contract integrity within the organization, and then affect the final contract integrity between organizations.
[0031] Definition 2: Contract integrity status: whether the calculation results given by the contract on the alliance chain meet expectations.
[0032] In this embodiment, the contract integrity status model is divided into three layers: node, organization, and inter-organization. The violation of the contract integrity at the node level means that an endorsement node gives a calculation result that does not meet the expectations. The violation of the contract integrity within the organization means that the endorsement node within the organization gives a calculation result that meets the endorsement success condition but does not meet the expectations. The contract integrity status within the organization is expressed as st The final integrity of the contract is destroyed when the alliance chain gives an endorsement result that meets the endorsement success conditions but does not meet the expected endorsement result. The final integrity of the contract between organizations is expressed as STFor simplicity, we will not consider situations such as network congestion or downtime. Therefore, the contract integrity status of organization j is expressed as follows: , Assume that a transaction requires approval from at least T organizations to be considered valid.
[0033] The final integrity state of the smart contract can be expressed as: , t, T and The larger the value, the stronger the protection of contract integrity. However, practical considerations such as privacy protection and performance requirements often limit the range of choices. This model is used to analyze integrity issues during the contract execution phase, while the integrity of on-chain data relies on the inherent tamper-resistant protection of blockchain. Based on the above contract integrity model, different assumptions such as attacker capabilities, peer node defense capabilities, and alliance chain organizational structure can be simulated to quickly obtain changes in transaction security in different scenarios, guiding the security design of alliance chain systems.
[0034] To summarize, in the TEE-based consortium chain smart contract integrity protection method of this embodiment, when the endorsement node (Peer node) is deployed for the first time, a hook function Hook is inserted into the key code segment of the Peer node, a trusted agent module is built in the Peer node, and an integrity monitoring module, a security data management module and a key management module are built in the feasible execution environment TEE; when the Peer node runs for the first time, the trusted agent module establishes a secure connection with the feasible execution environment TEE, the feasible execution environment TEE verifies the integrity of key components such as blockchain programs and configuration files in the REE operating system, and the integrity monitoring module of the feasible execution environment TEE measures the integrity of key components of the REE side system. When the peer starts, if the integrity measurement result of the feasible execution environment TEE verification matches the baseline value of the default security object list in the feasible execution environment TEE, the trusted agent module of the peer node is allowed to establish a connection with the feasible execution environment TEE, otherwise it is rejected; in the contract measurement scenario, when the hook function Hook of the peer node is called during the installation, instantiation, operation, and update of the contract, the current contract status will be judged and the corresponding operation will be performed based on the security object list L in the feasible execution environment TEE. Specifically, during installation, the peer node will measure and verify the integrity of the contract file based on the feasible execution environment TEE, and obtain and store the benchmark value of the contract to the security object list L; during instantiation, the feasible execution environment TEE will measure the contract file (including the image) and compare it with the baseline value. If it does not match, instantiation is not allowed; during operation, the security status of the contract and the platform is monitored and the security object list L is updated in real time; when updating the contract, first verify that the status of the old version of the contract is already inactive, and then verify the integrity of the new contract. If the integrity of the new contract is not destroyed and the old contract is inactive, the contract is allowed to be updated. The hash algorithm for measurement can be SHA256; in the transaction endorsement scenario, before the transaction is endorsed, the feasible execution environment TEE provides the current contract and platform's trusted credentials, which are generated based on the security object list L. For a Peer node, if it receives proposal requests for multiple endorsement transactions, it will call the trusted proxy module to obtain the trusted credentials after the corresponding contract execution is completed. The trusted proxy module has been running and accepting the transaction's credential generation request, batch-acquires the transaction information to be proved through the transaction collector, and uniformly calls the feasible execution environment TEE to generate the corresponding trusted credentials and returns them to the Peer node. The Peer node encapsulates the trusted credentials in the endorsement response and returns it to the client. The client will verify the endorsement response and the trusted credentials. If the endorsement policy is met, it will be submitted to the sorting service to generate a block and broadcast to all Peer nodes. Finally, the Peer node will verify the trusted credentials again before the transaction is put on the chain.In cross-contract calls, when smart contract S calls another smart contract S' for execution, first, the called smart contract S' must verify whether the call request comes from the trusted smart contract S through the trusted credentials provided by smart contract S before execution, so as to prevent malicious contract calls. On the other hand, after the execution, smart contract S' also needs to provide trusted credentials in the execution result to return to smart contract S. Smart contract S can use the trusted credentials to verify that the response received from smart contract S' has not been tampered with. The security design and analysis of the alliance chain architecture, based on the proposed contract integrity model, simulates the organizational structure, attacker capabilities, node defense capabilities, etc. of the alliance chain in different scenarios, and quickly obtains the changes in transaction security after the integrity protection mechanism is introduced in the alliance chain, thereby guiding the architectural design of the alliance chain system. It can be seen that the alliance chain smart contract integrity protection method based on the feasible execution environment TEE in this embodiment can realize the integrity protection of the alliance chain smart contract based on the feasible execution environment TEE, and has the advantages of comprehensive protection, high verification level, security and reliability, good versatility, strong scalability, and high efficiency.
[0035] In addition, this embodiment also provides a TEE-based alliance chain smart contract integrity protection system, including an interconnected microprocessor and a memory, and the microprocessor is programmed or configured to execute the TEE-based alliance chain smart contract integrity protection method.
[0036] In addition, this embodiment also provides a computer-readable storage medium, which stores a computer program or instructions, and the computer program or instructions are programmed or configured to execute the TEE-based consortium chain smart contract integrity protection method through a processor.
[0037] In addition, this embodiment also provides a computer program product, including a computer program or instructions, which are programmed or configured to execute the TEE-based alliance chain smart contract integrity protection method through a processor.
[0038] Those skilled in the art should understand that the technical solutions provided by the embodiments of the present application may be in the form of methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the process Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0039] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.
Claims
1. A TEE-based alliance chain smart contract integrity protection method, characterized in that: The steps include: S1, generates a trusted certificate with contract integrity status information for the transaction obtained by contract execution ; S2, will be accompanied by a trusted certificate Generate blocks after sorting transactions and broadcast the blocks to all nodes in the alliance chain; S3, each node in the alliance chain verifies the trusted credentials carried by the transaction in the block The integrity of the transaction is verified to verify the credibility of the contract execution of the transaction. Depending on whether the verification is successful, the transaction is marked as a valid transaction or an invalid transaction and submitted to the alliance chain.
2. The TEE-based alliance chain smart contract integrity protection method according to claim 1 is characterized in that: In step S1, a trusted certificate with contract integrity status information is generated for the transaction obtained by contract execution When , the generating function expression of the contract integrity state is: , In the above formula, The contract integrity status on the alliance chain. ST =1 means that the integrity of the contract on the alliance chain has not been destroyed, that is, the execution result of the contract meets expectations. ST =-1 means the integrity of the contract on the alliance chain is destroyed. Representation Statistics The number of elements whose median value is 1, is the set of contract integrity status of all organizations, , The minimum number of endorsing organizations required to reach endorsement agreement between organizations," " indicates AND logic operation, ~ They are No. 1~ The contract integrity status of an organization, is the set of organizations in the alliance chain, and the contract integrity status of any j-th organization satisfy , Indicates j The contractual integrity of the organization has not been compromised, Indicates j The contractual integrity of an organization is compromised and there is: , In the above formula, Representation Statistics The number of elements whose median value is 1, is the contract integrity status set of the endorsement node of the jth organization, , For the j The set of endorsement nodes within an organization, any i The contract integrity status of the endorsing nodes satisfy , Indicates i The contract integrity of the endorsing nodes has not been compromised. Indicates i The contract integrity of the endorsing nodes is compromised. For the j The minimum number of endorsement nodes that an organization reaches for valid endorsement, and the contract integrity status on the consortium chain , all j Contract integrity status of an organization And all i The contract integrity status of the endorsing nodes Form three levels of contract integrity status in the alliance chain.
3. The TEE-based alliance chain smart contract integrity protection method according to claim 1 is characterized in that: In step S1, a trusted certificate with contract integrity status information is generated for the transaction obtained by contract execution When the trusted certificate The calculation function expression is: , In the above formula, is a transaction identifier list, the format of which is n >, where H1~H n is a unique identifier for n transactions, A list of transaction identifiers The associated smart contract integrity status information, v(S) includes the set of associated smart contracts in the transaction identifier list I <S1,...,S n >Each smart contract S i The contract id, hash value and security status; The platform security vector is the current security state of the system components on the platform, which is composed of the trusted state of the system components stored in the feasible execution environment TEE and the Merkle root of the system component list items in the security object list L; A random number generated by the TEE to prevent replay attacks. Sign the TEE. 4. The TEE-based alliance chain smart contract integrity protection method according to claim 3 is characterized in that: Step S1 includes: S1.1, the client sends a proposal to the endorsing node; S1.2, the endorsing node executes the proposal through a smart contract; S1.3, the endorsing node creates a trusted certificate with contract integrity information ; S1.4, the endorsing node returns a trusted certificate The endorsement result is given to the client; S1.5, client verifies endorsement result and trusted certificate , if the verification is successful, jump to the next step; S1.6, the client will carry a trusted certificate The transactions are submitted to the sorting service for sorting.
5. The TEE-based alliance chain smart contract integrity protection method according to claim 4 is characterized in that: Step S1.2 includes: S101, the endorsement node inserts a hook function Hook into the key component used to control the operation of the contract before startup; S102, the endorsement node loads a trusted proxy module that can be connected to the feasible execution environment TEE through the hook function Hook before startup; S103, the endorsement node first starts the trusted proxy module when starting; S104, the trusted proxy module of the endorsement node establishes a connection and session with the feasible execution environment TEE of the endorsement node. If the connection and session are established successfully, jump to the next step; otherwise, end and exit; S105, the feasible execution environment TEE initializes the integrity measurement module, the security data management module and the key management module, wherein the integrity measurement module is used to perform integrity measurement, the security data management module is used to manage the security data obtained by the integrity measurement through the security object list L, the table items of the security object list L include objects, hash values and their trusted status, and the key management module is used to provide the generation of trusted credentials Required signatures; S106, the feasible execution environment TEE measures the key components on the REE side for controlling the operation of the contract based on the security object list L built into the security data management module; S107, the feasible execution environment TEE updates the status of the security object list L based on the measurement results, and updates the trusted status of the system components and the Merkle root of the system component list items in the security object list L based on the latest status of the security object list L. If the status is normal, jump to the next step; otherwise, end and exit; S108, after the endorsement node starts the service, it continues to run and receive proposals from the client; if a transaction proposal is received from the client, it jumps to step S1.2; if a contract installation proposal is received, it jumps to step S109; if a proposal for instantiation of an installed contract is received, it jumps to step S113; if a proposal for updating an installed contract is received, it jumps to step S117; S109, the endorsing node parses the contract code and signature of the smart contract in the received contract installation proposal and passes it to the feasible execution environment TEE; S110, the feasible execution environment TEE verifies the contract code and signature of the proposed smart contract through the integrity measurement module. If the code and signature verification of the proposed contract pass, jump to the next step; otherwise, it is determined that the installation fails and jump to step S112; S111, the endorsement node stores the code of the smart contract to the platform, and the feasible execution environment TEE registers the contract to the contract table item of the security object list L, determines that the installation is successful, and jumps to step S112; S112, the endorsement node sends the result of installation success or failure as a response to the client with the signature of the feasible execution environment TEE, and jumps to step S108; S113, the endorsing node parses the instantiation request and signature in the received instantiation proposal and passes it to the feasible execution environment TEE; S114, the feasible execution environment TEE re-measures the smart contract specified in the instantiation proposal and updates the corresponding contract entry in the security object list L. If the integrity of the smart contract is not destroyed, jump to the next step; otherwise, it is determined that the instantiation fails and jump to step S116; S115, the endorsement node runs the instantiation of the smart contract, and during the operation of the smart contract, the feasible execution environment TEE regularly monitors the security status of the contract; if the instantiation is successful, jump to step S116; S116, the endorsing node sends the instantiation success or failure result as a response with the feasible execution environment TEE signature to the client, and jumps to step S108; S117, before the contract is updated, the installation process of the new contract is completed. The endorsement node parses the update request and signature in the proposal for the update of the installed smart contract and passes it to the feasible execution environment TEE; S118, the feasible execution environment TEE verifies the specified contract code and signature in the contract update proposal through the integrity measurement module. If the verification is successful, jump to the next step; otherwise, the update is judged to have failed and jump to step S121; S119, the endorsement node deactivates the old version of the smart contract, and the feasible execution environment TEE checks the status of the old version of the smart contract and updates the security object list L. If the old version of the contract is deactivated, jump to the next step; otherwise, it is determined that the update fails and jumps to step S121; S120, the endorsement node starts the new version of the smart contract, updates the corresponding contract item status in the security object list L in the feasible execution environment TEE, determines that the update is successful, and jumps to step S121; S121, the endorsing node sends the update success or failure result as a response to the client with the feasible execution environment TEE signature attached, and jumps to step S108.
6. The TEE-based alliance chain smart contract integrity protection method according to claim 4 is characterized in that: In step S1.2, the endorsement node executes the proposal through the smart contract, which means that the endorsement node executes the proposal through the local smart contract S or calls other smart contracts S' through the local smart contract S to execute the proposal. The execution of the proposal through the local smart contract S calling other smart contracts S' through the local smart contract S includes: S201, smart contract S creates a trusted certificate with contract integrity information ; S202, smart contract S sends a trusted certificate to other smart contract S' The calling parameters; S203, smart contract S' verifies the trusted credential If the verification is successful, jump to the next step; otherwise, report an error and exit; S204, the smart contract S' generates the execution result and creates a trusted certificate with contract integrity information ; S205, the smart contract S' will carry a trusted certificate The response is returned to the smart contract S; S206, smart contract S verifies the trusted credential If the verification is successful, jump to the next step; otherwise, report an error and exit; S207, smart contract S will continue to execute based on the execution result returned by smart contract S', obtain the final execution result of smart contract S and return the execution result to the endorsement node.
7. The TEE-based alliance chain smart contract integrity protection method according to claim 1 is characterized in that: Step S2 will carry the trusted credentials The transaction sorting includes that after receiving a batch of transactions, the sorting service determines an order for the batch of transactions through a preset consensus algorithm and links them to an ordered block; step S3 also includes verification of endorsement and verification of read-write sets. The verification of endorsement means that after a node receives a new block, it checks whether the endorsement result and trusted credential of each transaction in the block meet the endorsement policy and credibility requirements associated with it. The verification of read-write sets means checking whether there is a conflict between the read-write set version of the transaction and the key-value pair.
8. A TEE-based alliance chain smart contract integrity protection system, comprising an interconnected microprocessor and a memory, characterized in that: The microprocessor is programmed or configured to execute the TEE-based consortium chain smart contract integrity protection method described in any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program or instruction stored therein, characterized in that: The computer program or instruction is programmed or configured to execute the TEE-based consortium chain smart contract integrity protection method described in any one of claims 1 to 7 through a processor.
10. A computer program product comprising a computer program or instructions, characterized in that The computer program or instruction is programmed or configured to execute the TEE-based consortium chain smart contract integrity protection method described in any one of claims 1 to 7 through a processor.
Citation Information
Patent Citations
Internet of vehicles data sharing implementation method based on block chain and trusted execution environment
CN114117522A
Cross-chain data trusted interaction method and system supporting integrity auditing
CN117459539A