Blockchain Security Analysis: Trusted Execution Environment from NEO

00 Preface

The flying dragon is in the sky.

01 Background

The Trusted Execution Environment (TEE) is an isolation area directly managed by the processor. The code running in the TEE will be completely isolated from the system and the hypervisor. At present, the mainstream chip architecture platforms already have their own unique trusted execution environment. The ARM platform has TrustZone. Currently, we use Android or Apple. TrustZone is used to protect our personal privacy data such as fingerprint information, facial information, etc.; Intel platform has Software Guard Extensions (SGX), thanks to The convenient SDK and development environment provided by Intel, this is also the most widely used TEE platform in academia, and the only existing TEE used in blockchain projects; AMD's server chips include Secure Encrypted Virtualization (SEV ), this is mainly to encrypt the memory of the virtual machine running on the server. The principle is that a small ARM chip is built into the AMD processor to encrypt the memory of the virtual machine and encrypt the registers during state switching.

02 Application case of trusted execution environment in blockchain

ChainLink Oracle

In the world of blockchain, the outflow of data can only be through transactions constructed by users. It can be said that the blockchain itself is driven by user transactions. Whether it is an ordinary transfer transaction or a call to a contract, everything starts from user transactions. Start, and only from the user's transaction. However, although a closed system can work well when executing simple logic such as transfer transactions, it is stretched when it comes to contract execution. The combination of blockchain and the real world must require the blessing of smart contracts, but when executing smart contracts in an isolated environment such as a blockchain virtual machine, it often cannot meet the needs of various data in the real world. Therefore, the oracle came into being. The oracle of the blockchain is a system that provides real-world data for smart contracts, such as flight information, gold prices, etc., so that when the contract is executed, it can be based on real-world data. Execute judgment logic.

At present, there are two main ways to implement oracles. One is a consensus-based oracle. Consensus nodes perform consensus verification on specific data to determine whether the data in the real world is reliable. What NEO3.0 is developing is This kind. The other is to establish a trusted communication channel between the trusted execution environment and the trusted data source in the real world, and the reliable data source sends the data to the oracle system supported by the trusted execution environment, and then sends the data. to the blockchain. Since the program in the trusted execution environment will be executed strictly according to the set logic after passing the remote verification (Remote Attestation), the data obtained through this oracle is credible. ChainLink is an oracle blockchain system designed based on this logic.

The ChainLink project is based on Town Crier, a contract trusted data source developed by FanZhang of Cornell University. There is a dedicated node in the TownCrier system for running Intel SGX nodes. This node is used to establish Https connections with trusted data sources in the real world, and run contracts in the node's SGX to obtain specified data. In this data acquisition model, Intel SGX nodes are legal TEE nodes verified by Remote Attestation and run unmodified oracle contracts. Therefore, when acquiring data through such a model, there are only two results, either unavailable or authentic and credible data.

Ekiden privacy-preserving blockchain

Ekiden is also from Cornell University. I have a lot of resentment towards them, blaming me for entering the industry too late and being rubbish. Every time I have a new TEE-based blockchain idea, as long as I do a search, it is basically done by Cornell. . Ekiden mainly uses a trusted execution environment to execute smart contracts in a privacy-preserving form. In Ekiden's network, nodes are divided into computing nodes and contract nodes. Contract nodes are used for the management and maintenance of the blockchain itself, and computing nodes are used to execute user transactions. The user's transaction is directly sent to the execution node of the contract, and then runs in the TEE, and the execution result will be stored on the blockchain in the form of ciphertext.

TeeChan payment pipeline

The concept of payment channel, one of the solutions of blockchain layer 2, will not be introduced here. Unfamiliar students can search for the keyword "payment channel". Although the payment channel can solve the problems of data storage, consensus waiting, expensive handling fees and scalability of the blockchain itself, the process of creating a payment channel still requires users to send transactions to the blockchain to complete the process, which not only requires consumption procedures fee, and need to wait for the normal confirmation cycle. To solve this problem, Joshua Lind of Imperial College avoids the cumbersome process of creating payment channels by creating a blockchain account in TEE to manage payment channels.

In the TeeChan system, users without payment channels can directly create payment channels offline. Due to the isolation of the TEE environment, even users themselves cannot use the assets in the TEE account at will, so as long as there is a payment channel in the other party's TEE Create, then you don't need to worry about the other party using that money elsewhere without your permission. By creating payment channels in TEE, TeeChain avoids the long waiting process for channel creation.

In addition, if a state channel does not have any asset changes throughout its life cycle, users can also negotiate to close the channel directly in the TEE without submitting any transactions to the blockchain.

In particular, I want to add that TeeChan's enhanced younger brother, TeeChain, was published in SOSP, the most, most, most, top-level conference on computers. He simply drew his sword and looked around in a daze, an invincible hand in the world.

In fact, there are still many projects combining TEE and blockchain, which are not listed here.

03 The advantages of combining NEO with a trusted execution environment

In fact, after talking about so many other projects, what I want to talk about most is the natural advantage of combining NEO itself with TEE. After working on TEE and blockchain for many years, although the breakthrough pits have been occupied, there is still a lot to be said about some details.

centralized

I don't mean to disparage the NEO project here, but I really feel that NEO is actually a relatively centralized project. This system of parliamentarians and speakers is somewhat similar to the democratic representative system. would be too big. I don't really understand why NEO has never thought about moving their minds here. There is no need to follow other people's ass. When others do zero-knowledge proof, NEO also follows one, others do sidechains, NEO also follows, and others pay channels, NEO Also follow one. If you always follow others, you will always live in the light of others. Shouldn't NEO analyze its own advantages and then develop its own unique technology to make others envy, jealous and hate? If there is a dream of vacating the sky, shouldn't it be the first to transform into a dragon?

Of course, my family's words, to be honest, don't really understand NEO's vision very much. I'm making a lot of noise here, and it's all a joke.

In my opinion, centralization is actually the most unique advantage of NEO itself. You can't have a heavy burden like Bitcoin and Ethereum. No matter what you do, you need to consider a lot of entanglements of interests, and there is no so-called belief suppression. You are struggling to innovate, and you betray Satoshi Nakamoto at every turn. Therefore, NEO can be more radical and explore new technologies boldly on the premise of ensuring safety.

In addition to centralization, the advantage of consensus node stability is that it can easily increase computing power. Referring to the EOS project's requirements for node configuration, NEO can provide stronger computing power support for transactions without worrying about it like Bitcoin or Ethereum. It will have the effect of DOS on some nodes.

consensus mechanism

I analyzed the advantages of the consensus mechanism of the NEO contract itself in my early blog post "A Possible Solution for NEO Chain Secure Random Numbers". The NEO consensus mechanism actually has a complex consensus negotiation process before executing a transaction. This process It seems to me that there is a lot to do. Can't there be other things that can be negotiated among the legislators apart from the consensus itself? Like random numbers? Since we trust the majority of parliamentarians, wouldn't it be good for the parliamentarians to jointly negotiate to generate a random number before generating a new block. This random number is generated after the user sends a transaction and before the new block is generated. No one can predict it. No one can change it. At least in my opinion, it is a feasible random number generation scheme. Such a scheme cannot be implemented in the PoW and PoS consensus mechanisms at all. It is simply the natural pearl of DBTF. Especially at present, it seems that random number generation is still a big problem in the blockchain world. If NEO is interested in developing in games, can this random number solution be a reference?

04 NEO under the blessing of trusted execution environment

The previous section analyzed some of the characteristics of NEO itself. These characteristics can actually be extended to play more functions, especially when combined with a trusted execution environment.

Privacy-preserving transactions

Referring to Ekiden's handling of private transactions, NEO is actually easier to implement privacy-protected transactions based on a trusted execution environment due to its relatively centralized nature. Of course, since NEO itself does not focus on privacy protection, there is no need to erase user information from all assets, but at least the information sent by users during contract invocation can be encrypted and protected.

private key recovery

If all parliamentary nodes support the TEE environment, then whether users are directly allowed to generate their own accounts on the NEO platform, the user's private key will be maintained by the parliamentary nodes in the form of dynamic privacy data sharing , and in the user's creation of private keys. When the key is obtained, let the user provide some information that only the user knows as a basis. When the user loses the key, he can restore the key and retrieve the assets by providing the key data to NEO. Since the collection of user information and the process of account generation are carried out directly through TEE, even NEO member nodes cannot obtain specific user privacy information.

secure random number

As I said when I analyzed the advantages of NEO, the unique consensus mechanism of NEO itself is actually very promising. Although we cannot trust the random number generated by a single node, we can rely on the negotiation process of parliamentarians before consensus to generate a multi-party The final secure random number, this generation process can also be carried out in the TEE, although it is not necessary.

trigger transaction

When I participated in the development of NNS in the NEL community, I found that a very uncomfortable part of the blockchain itself is that all transactions must be sent immediately and executed immediately. sad. If I have two or three transactions that need to be executed sequentially, and each transaction needs to be in a different block, then my only solution is to send the next transaction after the first transaction is executed successfully, and so on, so The operation method is very anti-human, and because of this, I don't like the CGAS exchange mechanism of NNS very much, but there is nothing I can do.

So can we implement a trigger transaction in TEE? Is it more convenient to send the trigger transaction to the TEE, and then attach to the specific event, send some information of the blockchain to the TEE to trigger the event, and then notify the transaction execution by the event?

Moreover, such a transaction form seems to be the most reliable only when combined with TEE, because in the NEO environment, even if the contract call transaction fails, it will still be written into the blockchain, which leads to the fact that if the user sends a trigger Transactions cannot be executed in strict order, so it is likely that the execution order will be disrupted and the final transaction will fail. And TEE can perfectly protect the transaction order.

05 Standing at the forefront of the times

The combination of trusted execution environment and blockchain should be a general trend. In the past, there will be many related articles on security every year. After several years of exploration in the field of scientific research, I believe that related projects will gradually appear in the industry in the future. I sincerely hope that NEO can make a breakthrough here.

06 Summary

This paper introduces TEE and lists several successful cases of combining TEE and blockchain. By analyzing the characteristics of the NEO project itself, this paper proposes several possible starting points for creatively combining a trusted execution environment with NEO. Even so, this article is still just a personal naive delusion, and I hope not to laugh at the unrealistic places. The author's strength is limited, and I hope to forgive me for the unavoidable omissions.

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324172168&siteId=291194637