# US 2021/0342133 A1 · Methods, blockchain nodes and storage media for deploying smart contract

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0342133 A1
- Document ID: US20210342133A1
- Status: Published application
- Kind: A1
- Application number: 17/357,179
- Filed: 2021-06-24
- Published: 2021-11-04
- Earliest claimed: 2020-08-31
- Assignees: Alipay (Hangzhou) Information Technology Co., Ltd.
- Applicants: Alipay (Hangzhou) Information Technology Co., Ltd.
- Inventors: Qi Liu
- Web page: https://patentgrep.com/patent/US20210342133A1

## CPC

- G06F 8/443: {Optimisation}
- H04L 9/3239: {involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD}
- G06F 21/51: at application loading time, e.g. accepting, rejecting, starting or inhibiting executable software based on integrity or source reliability
- G06F 21/57: Certifying or maintaining trusted computer platforms, e.g. secure boots or power-downs, version controls, system software checks, secure updates or assessing vulnerabilities
- G06F 21/645: {using a third party}
- H04L 9/0897: {involving additional devices, e.g. trusted platform module [TPM], smartcard or USB}
- H04L 9/30: Public key, i.e. encryption algorithm being computationally infeasible to invert or user's encryption keys not requiring secrecy
- H04L 63/062: {for key distribution, e.g. centrally by trusted party (cryptographic mechanisms or cryptographic arrangements for key distribution involving a central third party H04L9/0819)}
- H04L 63/126: {the source of the received data}
- H04L 9/50: {using hash chains, e.g. blockchains or hash trees}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)

## Abstract

A computer-implemented method, non-transitory, computer-readable medium, and computer-implemented system are provided for deploying a smart contract in a blockchain network. The computer-implemented method includes: receiving, by a blockchain node in a blockchain network, a transaction for creating a smart contract, wherein the transaction comprises a machine code of the smart contract, and the machine code of the smart contract is obtained by Ahead of Time (AoT) compilation of a bytecode of the smart contract in a first trusted execution environment (TEE); determining, by the blockchain node, that the machine code of the smart contract is obtained in a trusted TEE; and in response to determining that the machine code of the smart contract is obtained by the trusted TEE, completing, by the blockchain node, a deployment of the smart contract.

## Claims

### Claim 1

A computer-implemented method, comprising:
receiving, by a blockchain node in a blockchain network, a transaction for creating a smart contract, wherein the transaction comprises a machine code of the smart contract, and the machine code of the smart contract is obtained by Ahead of Time (AoT) compilation of a bytecode of the smart contract in a first trusted execution environment (TEE);
determining, by the blockchain node, that the machine code of the smart contract is obtained in a trusted TEE; and
in response to determining that the machine code of the smart contract is obtained by the trusted TEE, completing, by the blockchain node, a deployment of the smart contract.

### Claim 2 (depends on 1)

The computer-implemented method of claim 1, wherein the AoT compilation of the bytecode of the smart contract comprises:
performing an optimization in a process of the AoT compilation of the bytecode of the smart contract.

### Claim 3 (depends on 1)

The computer-implemented method of claim 1, wherein the first TEE is deployed on any one of: a client device that submits the transaction, any blockchain node in the blockchain network, or a third-party server different from the client device and the blockchain node.

### Claim 4 (depends on 1)

The computer-implemented method of claim 1, wherein determining, by the blockchain node, that the machine code of the smart contract is obtained by the trusted TEE comprises:
obtaining, by the blockchain node from the transaction, a signature of the machine code generated by the first TEE by using a private key;
verifying, by the blockchain node, the signature using a public key corresponding to a predefined trusted TEE mirror image; and
in response to determining that the signature is verified using the public key, determining, by the blockchain node, that the first TEE is the trusted TEE.

### Claim 5 (depends on 4)

The computer-implemented method of claim 4, wherein the private key is distributed to the first TEE by a key management server in response to determining that the first TEE passes remote certification.

### Claim 6 (depends on 4)

The computer-implemented method of claim 4, wherein the predefined trusted TEE mirror image comprises: a mirror image of a trusted enclave based on software guard protection (SGX).

### Claim 7 (depends on 4)

The computer-implemented method of claim 4, wherein the public key corresponding to the predefined trusted TEE mirror image is recorded in a system contract; the method further comprises:
invoking, by the blockchain node, the system contract;
passing, by the blockchain node, the signature to the system contract; and
receiving, by the blockchain node, an identification result returned by the system contract, wherein the identification result indicates whether the signature is verified by the public key corresponding to the predefined trusted TEE mirror image.

### Claim 8 (depends on 7)

The computer-implemented method of claim 7, wherein invoking, by the blockchain node, the system contract comprises:
reading, by the blockchain node, a contract address of the system contract from the transaction; and
invoking, by the blockchain node, the system contract based on the contract address.

### Claim 9 (depends on 7)

The computer-implemented method of claim 7, wherein invoking, by the blockchain node, the system contract comprises:
in response to determining that a transaction type of the transaction is a contract deployment type, invoking, by the blockchain node, the system contract based on a contract address of the system contract defined in a chain code of the blockchain node.

### Claim 10 (depends on 7)

The computer-implemented method of claim 7, wherein the system contract is deployed in a genesis block; or, a management authority of the system contract is a blockchain administrator.

### Claim 11

A non-transitory, computer-readable medium storing one or more instructions executable by a computer system to perform operations comprising:
receiving, by a blockchain node in a blockchain network, a transaction for creating a smart contract, wherein the transaction comprises a machine code of the smart contract, and the machine code of the smart contract is obtained by Ahead of Time (AoT) compilation of a bytecode of the smart contract in a first trusted execution environment (TEE);
determining, by the blockchain node, that the machine code of the smart contract is obtained in a trusted TEE; and
in response to determining that the machine code of the smart contract is obtained by the trusted TEE, completing, by the blockchain node, a deployment of the smart contract.

### Claim 12 (depends on 11)

The non-transitory, computer-readable medium of claim 11, wherein the first TEE is deployed on any one of: a client device that submits the transaction, any blockchain node in the blockchain network, or a third-party server different from the client device and the blockchain node.

### Claim 13 (depends on 11)

The non-transitory, computer-readable medium of claim 11, wherein determining, by the blockchain node, that the machine code of the smart contract is obtained by the trusted TEE comprises:
obtaining, by the blockchain node from the transaction, a signature of the machine code generated by the first TEE by using a private key;
verifying, by the blockchain node, the signature using a public key corresponding to a predefined trusted TEE mirror image; and
in response to determining that the signature is verified using the public key, determining, by the blockchain node, that the first TEE is the trusted TEE.

### Claim 14 (depends on 13)

The non-transitory, computer-readable medium of claim 13, wherein the private key is distributed to the first TEE by a key management server in response to determining that the first TEE passes remote certification.

### Claim 15 (depends on 13)

The non-transitory, computer-readable medium of claim 13, wherein the public key corresponding to the predefined trusted TEE mirror image is recorded in a system contract; the operations further comprise:
invoking, by the blockchain node, the system contract;
passing, by the blockchain node, the signature to the system contract; and
receiving, by the blockchain node, an identification result returned by the system contract, wherein the identification result indicates whether the signature is verified by the public key corresponding to the predefined trusted TEE mirror image.

### Claim 16

A computer-implemented system, comprising:
one or more computers; and
one or more computer memory devices interoperably coupled with the one or more computers and having tangible, non-transitory, machine-readable media storing one or more instructions that, when executed by the one or more computers, perform one or more operations comprising:
receiving, by a blockchain node in a blockchain network, a transaction for creating a smart contract, wherein the transaction comprises a machine code of the smart contract, and the machine code of the smart contract is obtained by Ahead of Time (AoT) compilation of a bytecode of the smart contract in a first trusted execution environment (TEE);
determining, by the blockchain node, that the machine code of the smart contract is obtained in a trusted TEE; and
in response to determining that the machine code of the smart contract is obtained by the trusted TEE, completing, by the blockchain node, a deployment of the smart contract.

### Claim 17 (depends on 16)

The computer-implemented system of claim 16, wherein the first TEE is deployed on any one of: a client device that submits the transaction, any blockchain node in the blockchain network, or a third-party server different from the client device and the blockchain node.

### Claim 18 (depends on 16)

The computer-implemented system of claim 16, wherein determining, by the blockchain node, that the machine code of the smart contract is obtained by the trusted TEE comprises:
obtaining, by the blockchain node from the transaction, a signature of the machine code generated by the first TEE by using a private key;
verifying, by the blockchain node, the signature using a public key corresponding to a predefined trusted TEE mirror image; and
in response to determining that the signature is verified using the public key, determining, by the blockchain node, that the first TEE is the trusted TEE.

### Claim 19 (depends on 18)

The computer-implemented system of claim 18, wherein the private key is distributed to the first TEE by a key management server in response to determining that the first TEE passes remote certification.

### Claim 20 (depends on 18)

The computer-implemented system of claim 18, wherein the public key corresponding to the predefined trusted TEE mirror image is recorded in a system contract; the one or more operations further comprise:
invoking, by the blockchain node, the system contract;
passing, by the blockchain node, the signature to the system contract; and
receiving, by the blockchain node, an identification result returned by the system contract, wherein the identification result indicates whether the signature is verified by the public key corresponding to the predefined trusted TEE mirror image.

### Claim 21

A computer-implemented method, comprising:
sending, by a device, a bytecode of a smart contract to a first trusted execution environment (TEE);
receiving, by the device, a machine code of the smart contract obtained by Ahead of Time (AoT) compilation of the bytecode of the smart contract by the first TEE; and
sending, by the device to a blockchain node of a blockchain network, a transaction for creating the smart contract, wherein the transaction comprises the machine code of the smart contract, and the machine code of the smart contract is used for deployment of the smart contract in the blockchain network.
