Block chain intelligent contract execution system supporting artificial intelligence model reasoning
By outsourcing AI model inference to off-chain using a trusted execution environment (TEE) in the blockchain smart contract execution system, the problem that existing blockchain smart contracts cannot support complex model inference is solved, and efficient and secure model inference and privacy protection are achieved.
Patent Information
- Application Number
- CN202311144839.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-06
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2043-09-06
AI Technical Summary
Existing blockchain smart contracts cannot support complex deep learning model inference, and model quantization technology will lead to a decrease inference accuracy and will not be compatible with the existing blockchain ecosystem.
By designing a blockchain smart contract execution system, using a trusted execution environment (TEE) to outsource AI model inference to off-chain, implement on-chain + off-chain joint execution, support non-deterministic AI inference, and protect model privacy through the TEE key management committee.
It realizes the execution of complex model inference functions on existing blockchains, breaks through the simple logic and deterministic requirements of smart contracts, improves the system concurrency and security, and protects model privacy.
Smart Images

Figure CN119583085A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain smart contract technology, and specifically to a blockchain smart contract execution system (SMART) that supports artificial intelligence model reasoning. Background Art
[0002] Due to the security and consistency requirements of blockchain systems, existing smart contracts can only execute simple deterministic programs and cannot support artificial intelligence (AI) model reasoning with complex calculations and non-deterministic outputs. In order to enable blockchain smart contracts to support AI model reasoning capabilities, some related work has implemented smart contract model reasoning functions through methods such as model quantization and adding AI operators to smart contract virtual machines. However, such methods can still only support simple model reasoning and cannot circumvent the limitations of the complexity of blockchain smart contracts. Among them, model quantization technology will also lead to a decrease in the accuracy of AI model reasoning, and the method of modifying the smart contract virtual machine will make the system incompatible with the existing mature blockchain ecosystem, such as Ethereum and Hyperledger. Summary of the invention
[0003] In view of the above-mentioned deficiencies in the prior art, the present invention proposes a blockchain smart contract execution system that supports artificial intelligence model reasoning, so as to support the function of implementing complex deep learning model reasoning in the existing blockchain and achieve four design goals: supporting non-deterministic AI reasoning, avoiding complex smart contract verification, being compatible with the existing blockchain, and protecting model privacy.
[0004] The present invention is achieved through the following technical solutions:
[0005] The present invention relates to a blockchain intelligent contract execution system supporting artificial intelligence model reasoning, comprising: a client for deploying a contract or intelligent contract supporting AI model reasoning, a blockchain node and a trusted execution environment (TEE) provider for maintaining the security and consistency of blockchain data, wherein: the client initializes the information of the AI model as a set of contract variables, stores the encrypted model file in an off-chain server, explicitly uses a precompiled function TEE.inference() in the contract to call the corresponding off-chain model reasoning program and distributes the model key fragments to a TEE key management committee composed of TEE providers; the blockchain node decouples the received contract call into an on-chain execution part and an off-chain execution part, outsources the contract call containing the precompiled function TEE.inference() to the TEE provider, and updates the on-chain contract transaction status according to the execution result from the TEE provider; the TEE provider runs the corresponding model reasoning program according to the TEE.inference() function, model information and the model key provided by the TEE key management committee to realize outsourcing.
[0006] The trusted execution environment refers to: a program trusted execution environment provided by trusted hardware. The program results executed in the TEE will not be tampered with by the external host machine, which can ensure the reliability of the program execution results and the confidentiality of the execution data in the TEE.
[0007] The contract variables include: the name of the AI model, the model version, the model file hash value, the reasoning framework used, and the model file access hyperlink (URL), which serve as the initialization value of the constructor when the contract is created, and provide the necessary security check information and input format information for subsequent contract model reasoning calls.
[0008] The execution result of the TEE provider refers to: the reasoning result of the TEE provider executing the model reasoning program within the TEE and the TEE authentication signature, wherein: the TEE authentication signature is used to verify the source credibility and data integrity of the reasoning result.
[0009] The updating of the on-chain contract transaction status refers to: including the inference result and TEE authentication signature output by the TEE in the on-chain contract transaction, and synchronizing them to other blockchain nodes to further verify the correctness of the inference result.
[0010] Preferably, for the same smart contract call request, the TEE provider can cache the most recent inference results and directly return the execution results to avoid redundant calculations.
[0011] The communication link between the TEE provider and the blockchain node ensures the integrity and confidentiality of the data through the secure transport layer protocol (TLS).
[0012] The present invention relates to a blockchain smart contract control method based on the above system, comprising:
[0013] Step 1) Contract creation and deployment: When creating a contract that supports AI model reasoning, the client specifies the model information as the initial variable of the contract, encrypts the model and saves it in the off-chain storage space, distributes the model key shards to the TEE key management committee, and publishes the deployment contract transaction to the peer-to-peer (P2P) network. The blockchain node will process this transaction and record it on the blockchain.
[0014] Step 2) Contract call execution: After the contract is successfully deployed, other clients call the contract through the remote procedure call (RPC) service on the blockchain node. The blockchain node processes the contract call request from the client and executes the contract.
[0015] 2.1) When the blockchain node determines that the contract call contains the model inference function TEE.inference(), the TEE.inference() function is outsourced to the TEE provider for execution in a secure and trusted TEE application container, which is the off-chain model inference part; and the contract call that does not contain the model inference function TEE.inference() is still executed by the blockchain node, which is the on-chain contract execution part.
[0016] 2.2) The blockchain node randomly selects a TEE provider and sends the corresponding model inference task to it. The TEE provider loads the required model from the off-chain storage server based on the model hash and off-chain storage URL, requests the model key from the TEE Key Management Committee, decrypts the model file in the TEE application container, and performs inference calculations.
[0017] The model reasoning task includes: the above-mentioned model information and model reasoning input data provided by the client.
[0018] 2.3) After the model reasoning is completed, the TEE executor returns the reasoning execution results and TEE authentication signature to the blockchain node; after receiving it, the blockchain node first checks the TEE authentication signature to verify that the model reasoning is executed in the valid TEE hardware, aggregates the reasoning results and attaches the TEE authentication signature to the contract transaction to update the contract call transaction status, generate a new block and broadcast it to other blockchain nodes.
[0019] Step 3) Transaction verification: When other blockchain nodes receive the new block generated in step 2), they verify the transactions contained in the block one by one: for the off-chain model reasoning part, only the validity of the TEE authentication signature attached to the transaction is verified to indicate whether the reasoning result is credible, avoiding the non-deterministic execution of model reasoning during the transaction verification process; for the on-chain contract execution part, the correctness of the execution result is verified by re-execution through the blockchain node.
[0020] In addition, since the verification of TEE authentication signatures needs to rely on the centralized authentication service provided by the TEE manufacturer, in order to avoid introducing long-term dependence on a trusted third party in a distributed system, the present invention uses blockchain nodes to build a distributed TEE authentication service. By allowing the blockchain nodes to cache the certificates required for the TEE authentication service and regularly synchronize updates to the TEE manufacturer, the verification process of the TEE authentication signature does not require the participation of the TEE manufacturer, and the verification can be completed directly at the blockchain node. Even if the TEE manufacturer cannot provide authentication services, it will not block the system process. Technical Effects
[0021] In view of the contradiction between the complexity and non-determinism of artificial intelligence model reasoning and the simple logic and determinism of blockchain smart contracts, the present invention realizes the execution of complex model reasoning functions on existing mainstream blockchain smart contracts through a combined on-chain and off-chain smart contract execution method, a distributed TEE authentication service protocol based on blockchain, and a model key provision scheme based on the TEE key management committee, breaking through the limitations of the simple logic and determinism requirements of existing smart contracts; the distributed TEE authentication service protocol based on blockchain gets rid of the bottleneck of centralized authentication services and improves the system concurrency and security; the model key provision scheme based on the TEE key management committee protects the privacy of the model from being leaked during the entire reasoning process. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a schematic diagram of the system of the present invention;
[0023] Figure 2 This is a schematic diagram of the joint execution process of on-chain and off-chain contracts;
[0024] Figure 3 A schematic diagram of a distributed authentication service based on blockchain nodes;
[0025] Figure 4 A schematic diagram of a scheme for providing model keys based on TEE key management committees;
[0026] Figure 5 End-to-end latency test for calling AI model inference for SMART contracts. DETAILED DESCRIPTION
[0027] like Figure 1As shown, this embodiment relates to a blockchain smart contract execution system that supports AI model reasoning, including: a client for deploying contracts or smart contracts that support AI model reasoning, a blockchain node and a trusted execution environment provider for maintaining the security and consistency of blockchain data, wherein: the client initializes the model information as a set of variables in the contract, and explicitly uses the precompiled function TEE.inference() to call the off-chain model reasoning process; the blockchain node processes the smart contract transaction from the client, decouples the received contract call into the on-chain execution part and the off-chain execution part, outsources the contract call containing the TEE.inference() function to the TEE provider and updates the transaction status according to the execution result from the TEE provider; the TEE provider runs the TEE.inference() function according to the data and model information input in the contract call from the blockchain node. In order to protect the privacy of the model from being leaked during the entire reasoning process, the client encrypts the model before uploading it to the off-chain storage server, and distributes the encryption key in pieces to the TEE key management committee for hosting, which is used for subsequent model decryption and reasoning within the TEE.
[0028] like Figure 2 As shown, the decoupling is achieved through a joint execution model on-chain and off-chain, specifically including:
[0029] Step 1) When a blockchain node receives a contract call transaction, it parses the contract call sentence by sentence according to its compiled bytecode. When encountering the model inference function TEE.inference(), it outsources the execution request to the TEE provider for non-deterministic off-chain execution. Specifically: the blockchain node first saves the execution context of the current contract, and then sends the input data, model hash, and model URL to the TEE application container for model inference, where the communication link is protected by the TLS protocol.
[0030] like Figure 4 As shown in the figure, when the client deploys its smart contract for the first time, it will establish a TLS secure channel with the n TEE providers in the key committee to transmit the key shards used to encrypt the model. When the model key is S, the client first randomly selects t-1 elements from the finite field GF(q) and constructs the polynomial f(x) = S + a1x + a2x 2 +…+a t-1 x t-1 , then the client randomly selects n points {(x,f(x))|x=1,...,n} on the polynomial f(x) and distributes these n nodes as n key shards to n TEE providers respectively.
[0031] Step 2) When the TEE provider receives a model inference request, it obtains the model file from the storage server according to the model file URL and verifies the model integrity using the received model hash. After preparing the necessary input data, the TEE application container uses the specified inference framework (such as PyTorch) to perform model inference and output the inference results.
[0032] Step 3) To prove that the model reasoning is performed in valid TEE hardware and the integrity of the reasoning results, the TEE application container will provide a TEE authentication signature for its identity and reasoning output. Therefore, the TEE provider returns the reasoning results and authentication signature to the blockchain node after completing the off-chain execution.
[0033] Step 4) After the blockchain node receives the returned result from the TEE provider, it checks the validity of the reasoning result by simply verifying the attached TEE authentication signature: if the result is valid, the blockchain node will restore the contract execution context and aggregate the off-chain execution results to update the contract status. When the contract call has not ended, the blockchain node will continue to parse the remaining contract bytecodes and execute the contract logic. If the current statement calls a smart contract, the blockchain node directly executes the contract call locally (on-chain part). For example, in Ethereum, the on-chain execution will be executed in the Ethereum Virtual Machine (EVM). At this time, the workflow degenerates to the contract execution, which is the same as the Ethereum smart contract without adding any additional overhead. In Ethereum, the switching between on-chain and off-chain execution can be achieved through pre-compiled contracts, and the present invention can be fully compatible without changing the workflow of Ethereum. After the contract call is completed, the blockchain node will update the contract status and record it in a new block.
[0034] Without losing generality, the present invention is also applicable to other existing blockchains that support smart contracts. For example, the smart contract (chain code) in the Hyperledger can be written in general programming languages such as Java / Go / Typescript and executed in a Docker container, so calling the off-chain model reasoning program in the chain code is more flexible and can be well compatible with the present invention.
[0035] The TEE provider verifies the validity of the execution results in the TEE hardware through identity registration and remote attestation on the blockchain: Taking Intel SGX as an example, Intel's DCAP service allows third-party users to construct their own attestation infrastructure to prove the quotes generated by the TEE provider through a traceable certificate chain; on the basis of the DCAP service, based on the basic idea of distributed authentication of blockchain nodes, the blockchain nodes cache the certificate chain and provide quote verification services locally, thereby avoiding frequent access to the centralized authentication server of the TEE manufacturer during runtime.
[0036] like Figure 3 As shown, the TEE provider identity registration is managed by registering the platform configuration ID (PPID) of the TEE provider through the TEE provider management (TPM) contract. The TPM contract provides three basic operations of TEE provider registration, update, and revocation. PPID is the unique identifier of the TEE provider and is used to represent the legal identity of the TEE provider. The Quoting Enclave (QE) first obtains the PPID from the Provisioning Certificate Enclave (PCE), and then the TEE provider stores its PPID in the TPM contract by calling the registration function. The blockchain node continuously monitors the update events of the TPM contract. When there is a newly registered TEE provider, the blockchain node will query the PPID of the TEE provider and obtain the corresponding authentication materials from the TEE manufacturer authentication server, including the provision authentication key (PCK) certificate, PCK certificate revocation list, trusted computing base (TCB) version, and the QE logo of the TEE platform. The blockchain node caches the above authentication materials in its local database for remote authentication verification. When a TEE provider needs to update its PCK, the QE should obtain a new PPID from the PCE and call the update function to update the PPID in the TPM contract. Once a blockchain node detects the PPID update, these nodes will obtain new proof materials for all updated TEE providers, similar to the registration process described above.
[0037] like Figure 3 As shown, the remote authentication refers to: generating a proof key through the QE of the TEE provider, and requesting the PCE to authenticate the proof key when it is first deployed; then the QE obtains the proof key certificate signed by the PCE, and generates a Quote structure containing TCB version number, TEE application container hash value, inference result, authentication key certificate, PCK and other information, and signs the Quote with the authentication key. The TEE provider sends the signed Quote to the blockchain node for remote proof verification. When the blockchain node receives the Quote, it queries the corresponding PCK certificate from the local database according to the PCK carried in the Quote, and uses the Quote certificate chain to verify the validity of the inference result (such as Figure 3 After completing these checks, the blockchain node can trust the reasoning results included in the Quote, so that the remote proof and verification between the blockchain node and the TEE provider does not require the participation of an additional third party.
[0038] To verify that the TEE provider runs in trusted TEE hardware, the TEE provider performs the above remote attestation process on the client before setting up the TLS connection. After verifying the identity of the TEE provider, the client transmits the key shard (x, f(x)) to the TEE provider. Since this key shard is transmitted through a TLS secure link, no one other than the trusted hardware of the TEE provider knows this key shard.
[0039] When other TEE providers need the key of the private model for inference, they establish a TLS secure link with randomly selected t (where t < n) TEE providers in the key committee and request t key shards. After the TEE provider obtains t key shards, it can recover the model key through polynomial interpolation. Therefore, the TEE provider can recover the key S inside the TEE hardware, decrypt the model, and execute the inference program.
[0040] Similarly, before transmitting the model key shards, the TEE providers can also authenticate each other through remote authentication. This ensures that the transmission of the key shards of the private model and the recovery of the model key are always kept within the TEE hardware, and even the TEE providers cannot know the key inside the TEE hardware.
[0041] Preferably, rewards and transaction fees for off-chain model inference are distributed to the TEE providers through registered blockchain accounts. The computational cost of model inference is quantified by the computational complexity and space complexity of the model, that is, the number of floating-point operations (FLOPs) and the number of parameters included in the model, thereby establishing a linear mapping from the model inference cost to the off-chain transaction fee. The system pays appropriate transaction fees to the TEE providers according to the computational cost consumed during the model inference process.
[0042] In this embodiment, the experimental setting uses FISCO BCOS as the underlying blockchain system, which is embedded with the EVM engine and is fully compatible with Ethereum smart contracts, verifying the compatibility of the present invention with the current mainstream blockchain system. The present invention implements context switching between the chain and the chain in the Ethereum smart contract through precompiled contract technology, which supports the chain contract to call the chain program, so the chain program (i.e., precompiled contract) connects the blockchain node and the TEE provider. The present invention uses Intel SGX as the experimental TEE hardware and PyTorch as the model reasoning framework. To simplify the deployment of SGX applications, Graphene-SGX is used to support model reasoning within the TEE application container without modifying the Python code. The present invention sets a four-node blockchain network and four TEE provider instances for experimental evaluation, and the system prototype is deployed on a laptop computer equipped with an Intel i7-8750H CPU and 16GB memory, and an Ubuntu 20.04 operating system.
[0043] In order to reflect the performance impact of introducing the SMART framework into the existing blockchain system, this embodiment writes a smart contract that supports deep learning model reasoning, including an inference function for calling off-chain model reasoning, to test the end-to-end delay of SMART contract calls and the time overhead of each part. Taking AlexNet, DenseNet161, ResNet18, SqueezeNet1.0, and VGG16 as examples, the end-to-end delay of SMART contract calls under public and private models is evaluated. Figure 5 shown.
[0044] After specific actual experiments, under the above experimental environment and parameter settings, due to the additional key provision, recovery and decryption operations, the contract call delay of the private model is about 5.15 seconds higher than that of the public model. The generation, verification and on-chain and off-chain switching time overhead of the TEE authentication signature (Quote) can be ignored. Figure 5It can be observed that the overall latency of the five models is distributed between 76-102 seconds, and the initialization of the TEE container application occupies the main time overhead, which is about 61.5 seconds. The reason is that the present invention uses Graphene-SGX to facilitate the development of SGX applications, but Graphene-SGX loads a large number of LibOS files and checks their integrity, which requires a certain amount of time overhead. This overhead can be achieved by directly using the Intel SGX SDK instead of TEE LibOS to implement TEE application container optimization for model reasoning, and some appropriate read-write optimization strategies can be used to reduce the time overhead caused by TEE page swapping. However, the above optimization requires users to invest more energy in rewriting and deploying TEE application container programs. Because the blockchain node adopts a request-response asynchronous mode, the off-chain reasoning delay of the SMART contract does not block the normal throughput of the blockchain, and the model reasoning task can be executed in parallel by multiple TEE providers, which can accelerate the overall off-chain reasoning execution efficiency of the system.
[0045] Compared with the prior art, the present invention does not require any modification to the existing blockchain system, and can perform AI model reasoning on the current mainstream blockchain smart contracts, further promoting the technical integration of AI and blockchain, and broadening the capabilities and application scenarios of blockchain. At the same time, the present invention can meet the system design goals in terms of system activity, execution correctness, and model privacy protection, specifically:
[0046] 1) System activity analysis: Both blockchain nodes and TEE providers contribute to ensuring the activity of the system. The activity guaranteed by blockchain nodes can be reduced to the activity of existing blockchain systems. In the SMART framework, model reasoning in smart contracts will be outsourced to TEE providers. Assuming that there is at least one TEE provider that is working properly, blockchain nodes can always find an available TEE provider to perform model reasoning. When a TEE provider is suddenly disconnected due to downtime or attack, the blockchain node may spend more time waiting for the response timeout and select another TEE provider to re-execute model reasoning. In this case, even if the end-to-end delay of the transaction increases, the transaction will eventually be completed under the assumption that the above TEE provider exists. Therefore, the activity of the system is maintained.
[0047] 2) Execution Correctness Analysis: The execution correctness of SMART contracts is divided into on-chain and off-chain execution parts. The correctness of on-chain execution is guaranteed by re-execution verification of other blockchain nodes, which is the same as the existing blockchain smart contract platform. When other blockchain nodes cannot obtain the same output by re-executing the on-chain part, these verification nodes will consider the transaction output to be wrong and discard the transaction. The correctness of off-chain execution depends on the trusted execution results provided by the TEE provider. Assuming that the TEE hardware is correctly implemented and securely manufactured, the blockchain node verifies the identity of the TEE provider through a distributed authentication service, so it can trust the integrity of the TEE provider's execution process. After receiving the model inference result, the blockchain node first checks whether the hash value of the TEE application container is consistent with the expected hash value, and whether the TEE authentication certificate is valid. If so, it indicates that the TEE provider executes model inference in the correct TEE application container, so that the blockchain node can trust the inference result. Other blockchain nodes verify the off-chain part by checking the validity of the TEE hardware and the hash value of the TEE application container, and determine whether the model inference result is correct, without the need to re-execute or find a new TEE provider to verify the off-chain execution result.
[0048] 3) Model privacy protection analysis: The client uses the symmetric key S to encrypt the private model and stores the encrypted model in the storage service. The n key shards are managed by the key management committee. The TEE provider obtains the encrypted model and checks whether the hash value is consistent with the hash value recorded in the contract. If so, the TEE provider will randomly select t TEE providers from the n members of the key management committee to establish a TLS secure link to obtain the key shard of the private model and rebuild the model key S locally. Since the entire process of key provisioning is protected by the TLS secure link and the key is only visible in the valid TEE hardware, no one else, including the TEE provider itself, can obtain the key of the private model, thereby ensuring the privacy of the model.
[0049] The above-mentioned specific implementation can be partially adjusted in different ways by those skilled in the art without departing from the principle and purpose of the present invention. The protection scope of the present invention shall be based on the claims and shall not be limited by the above-mentioned specific implementation. Each implementation scheme within its scope shall be subject to the constraints of the present invention.
Claims
1. A blockchain smart contract execution system supporting deep learning model reasoning, characterized in that: include: A client for deploying contracts or smart contracts that support AI model reasoning, a blockchain node and a trusted execution environment (TEE) provider for maintaining the security and consistency of blockchain data, wherein: the client initializes the information of the AI model as a set of contract variables, stores the encrypted model file in the off-chain server, explicitly uses the precompiled function TEE.inference() in the contract to call the corresponding off-chain model reasoning program and distributes the model key shards to the TEE key management committee composed of TEE providers; the blockchain node decouples the received contract call into the on-chain execution part and the off-chain execution part, outsources the contract call containing the precompiled function TEE.inference() to the TEE provider, and updates the on-chain contract transaction status according to the execution result from the TEE provider; the TEE provider runs the corresponding model reasoning program according to the TEE.inference() function, model information and the model key provided by the TEE key management committee to achieve outsourcing; The contract variables include: the name of the AI model, the model version, the model file hash value, the reasoning framework used, and the model file access hyperlink (URL), which serve as the initialization value of the constructor when the contract is created, and provide the necessary security check information and input format information for subsequent contract model reasoning calls.
2. The blockchain smart contract execution system supporting deep learning model reasoning according to claim 1 is characterized in that: The execution result of the TEE provider refers to: the reasoning result of the TEE provider executing the model reasoning program within the TEE and the TEE authentication signature, wherein: the TEE authentication signature is used to verify the source credibility and data integrity of the reasoning result.
3. The blockchain smart contract execution system supporting deep learning model reasoning according to claim 1 is characterized in that: The updating of the on-chain contract transaction status refers to: including the inference result and TEE authentication signature output by TEE in the on-chain contract transaction, and synchronizing them to other blockchain nodes to further verify the correctness of the inference result; For the same smart contract call request, the TEE provider caches the most recent inference results and directly returns the execution results to avoid redundant calculations.
4. The blockchain smart contract execution system supporting deep learning model reasoning according to claim 1 is characterized in that: The communication link between the TEE provider and the blockchain node ensures the integrity and confidentiality of the data through the secure transport layer protocol (TLS).
5. The blockchain smart contract execution system supporting deep learning model reasoning according to claim 1 is characterized in that: The decoupling is achieved through a joint execution model on-chain and off-chain, including: Step 1) When a blockchain node receives a contract call transaction, it parses the contract call sentence by sentence according to its compiled bytecode. When encountering the model inference function TEE.inference(), it outsources the execution request to the TEE provider for non-deterministic off-chain execution. Specifically: the blockchain node first saves the execution context of the current contract, and then sends the input data, model hash, and model URL to the TEE application container for model inference, where the communication link is protected by the TLS protocol; Step 2) When the TEE provider receives a model inference request, it obtains the model file from the storage server according to the model file URL and verifies the model integrity using the received model hash; after preparing the necessary input data, the TEE application container uses the specified inference framework to perform model inference and outputs the inference result; Step 3) To prove that the model reasoning is performed within the valid TEE hardware and the integrity of the reasoning results, the TEE application container will provide a TEE authentication signature for its identity and reasoning output; therefore, the TEE provider returns the reasoning results and authentication signature to the blockchain node after completing the off-chain execution; Step 4) After the blockchain node receives the returned result from the TEE provider, it checks the validity of the inference result by simply verifying the attached TEE authentication signature: if the result is valid, the blockchain node will restore the contract execution context and aggregate the off-chain execution results to update the contract status; when the contract call has not ended, the blockchain node will continue to parse the remaining contract bytecode and execute the contract logic; if the current statement calls a smart contract, the blockchain node directly executes the contract call locally (on-chain part); after the contract call is completed, the blockchain node will update the contract status and record it in a new block.
6. A blockchain smart contract control method based on the blockchain smart contract execution system supporting deep learning model reasoning as described in any one of claims 1-5, characterized in that: include: Step 1) Contract creation and deployment: When creating a contract that supports AI model reasoning, the client specifies the model information as the initial variable of the contract, encrypts the model and saves it in the off-chain storage space, distributes the model key shards to the TEE key management committee, and publishes the deployment contract transaction to the peer-to-peer (P2P) network. The blockchain node will process this transaction and record it on the blockchain; Step 2) Contract call execution: After the contract is successfully deployed, other clients call the contract through the remote procedure call (RPC) service on the blockchain node. The blockchain node processes the contract call request from the client and executes the contract; Step 3) Transaction verification: When other blockchain nodes receive the new block generated in step 2), they verify the transactions contained in the block one by one: For the off-chain model reasoning part, only the validity of the TEE authentication signature attached to the transaction is verified to indicate whether the reasoning result is credible, avoiding the non-deterministic execution of model reasoning during the transaction verification process; For the on-chain contract execution part, the correctness of the execution result is verified by re-execution through the blockchain node.
7. The blockchain smart contract control method according to claim 6 is characterized in that: The step 2 specifically includes: 2.1) When the blockchain node determines that the contract call contains the model inference function TEE.inference(), the TEE.inference() function is outsourced to the TEE provider for execution in a secure and trusted TEE application container, i.e., the off-chain model inference part; and the contract call that does not contain the model inference function TEE.inference() is still executed by the blockchain node, i.e., the on-chain contract execution part; 2.2) The blockchain node randomly selects a TEE provider and sends the corresponding model inference task to it. The TEE provider loads the required model from the off-chain storage server according to the model hash and off-chain storage URL, requests the model key from the TEE key management committee, decrypts the model file in the TEE application container, and performs inference calculations; 2.3) After the model reasoning is completed, the TEE executor returns the reasoning execution results and TEE authentication signature to the blockchain node; after receiving it, the blockchain node first checks the TEE authentication signature to verify that the model reasoning is executed in the valid TEE hardware, aggregates the reasoning results and attaches the TEE authentication signature to the contract transaction to update the contract call transaction status, generate a new block and broadcast it to other blockchain nodes.
8. The blockchain smart contract control method according to claim 6 or 7, characterized in that: Use blockchain nodes to build a distributed TEE authentication service. By allowing blockchain nodes to cache the certificates required for the TEE authentication service and regularly synchronize updates to TEE manufacturers, the verification process of the TEE authentication signature can be completed directly at the blockchain node.
9. The blockchain smart contract control method according to claim 6 or 7, characterized in that: The authentication refers to: generating a proof key through the QE of the TEE provider and requesting the PCE to authenticate the proof key when it is deployed for the first time; QE then obtains the attestation key certificate signed by PCE, generates a Quote structure containing TCB version number, TEE application container hash value, inference result, attestation key certificate, PCK and other information, and signs the Quote with the attestation key; the TEE provider sends the signed Quote to the blockchain node for remote attestation verification; When a blockchain node receives a quote, it queries the corresponding PCK certificate from the local database based on the PCK carried in the quote, and uses the quote certificate chain to verify the validity of the inference result.
10. The blockchain smart contract control method according to claim 6 is characterized in that: When the client deploys its smart contract for the first time, it establishes a TLS secure channel with n TEE providers in the key committee to transmit the key shards used for the encryption model. Specifically, the client first randomly selects t-1 elements from the finite field GF(q) and constructs a polynomial f(x)=S+a1x+a2x 2 +…+a t-1 x t-1 , then randomly select n points {(x,f(x))|x=1,...,n} on the polynomial f(x), and distribute these n nodes as n key shards to n TEE providers respectively, where: S is the model key.
Citation Information
Patent Citations
Edge computing framework based on blockchain and trusted execution environment
CN112380578A
Method and device for block chain to access machine learning model, equipment and medium
CN114327803A
Data security sharing and privacy protection method and system for intelligent medical engineering
CN114553436A
Automatic door system
KR102531391B1
Cited By
Trusted data acquisition verification method based on block chain, oracle machine, TEE and VRF
CN120086288A