Deploy Docker Apps in TEEs with Phala - ETHGlobal Bangkok 2024

ETHGlobal Bangkok · November 2024 · 12:34

Shelven Zhou and Joshua Waller of Phala Network explain how trusted execution environments have matured and how the dstack SDK lets developers run Docker apps inside them. Shelven covers better performance, simpler deployment and GPU support, plus a benchmark showing low overhead. Joshua then demonstrates a Next.js app that derives keys, signs messages, sends a transaction and produces remote attestation quotes that can be verified onchain. They also introduce an autonomous AI agent template.

Speakers

Topics

From ETHGlobal Bangkok, hosted by ETHGlobal.

Transcript

[Music] so hello everyone I'm shelvin from F Network and today I'm introduce some uh progress in the te world so how to sinlessly transition from web 2 to the web three with te yeah so f is a fiveyear project working on te for a long time and now we are managing the world largest decentralized te Network where all the te Hardware are coming for our community and X has been sta running for around five years yeah and uh recently there is some I will say evolution in the te world compared with previous like Intel sgx which I call the first generation of te

the latest te is a game changer compared to that because of the three features I'm interesting uh I think it's interesting so the first is better performance so in the previous World actually when you are using the Intel like sgx there is a memory limitation and now this is totally removed and previously you will suffer around like 25% of overhead and now you can see the current overhead by turning the program running into te is almost neglectable so and second I will say the usability So currently the uh solution like uh like AWS natural or like the Intel TDX or amdv they provide the system image level

uh virtualization support so that means uh you can just move your program get it running in Te with no modification so what you need to do is just dockerize it and uh leave the last job for us yeah so the third part is the GPU support so in the late last year Nvidia has just announced the world first GPU with te support so it's h100 series and now it has h200 series with larger uh memory so you can see uh I think this is very crucial for using te in more serios uh in more scenarios just like running the AI model or running the ZK circuit inside te yeah and what we introduced here is a

TDK called D stack so it's a flash Bots X Project which is jointly produced by F and Flash BS so it has four major uh features here the first is that support for darker images so just input the just uh make your own Docker compos file we are get this running on the te directly and second it's equipped with the remote attestation apis and the chain of trust visualization on web UI so any users they can easily verify whether the application is really running inside te the third uh it's equipped with the automatic IH https which means every application deploy in the te will be equipped with a domain and also with all

the TRS certificate that is totally generated and managed in the te so the end user they didn't even uh they can just use the current TS based solutions to connect to your application so the final things is unique from the follow part is that we will uh replace the current Hardware based root of trust with the decentralized root of trust that is controlled by the smart contract so this means your application data is safe even if a single te node is down because the state the data is STO is stored in something else so you can just initiate a new T instance to resume the execution yeah so this is one interesting part which is uh running uh

Power by this deck it's built by the professor Andrew Miller from the flashball team and he us this deck to build it so I say it's different from the others like AI agents in that the whole stack is controlled by the machine just imagine so from the X account so the email account that control the X account and also all the AI agents the AI Pi key is used all of them all of them are running inside the te so so now we can see okay with this this is the real AI agent that's controlled by the machine and you can trust yeah and this will unlock a lot of interesting use case uh finally we just published the world first Benchmark on the te gpus so

to to show how usable whether it's usable or not so the overall uh conclusion here is that the average overhead is less than 9% so which is quite good from my side yeah and in the next my colleagues Josh will show you the usage of the stack thank you okay um so what I'm going to do is show you just application uh that's deployed on our lab server right now just to give you an idea so here is a nextjs application it's uh that I've access publicly you can go to this link if you would like as well um what I can do is derive uh a ecdsa key pair here so this is an

account that is uh within the te uh from there I can start signing messages and we can see uh TX signature here that you can verify you can sign type data so I I I actually use the uh VM SDK just some of the examples they had in there and just kind of made a a mock template here that you can uh you can uh clone and then get started really quick um so and then also I I sent some uh some funds to this this uh wallet so that I can actually execute a transaction and this uh sent uh 420 guay uh to uh an account that I had just

sent it to uh sent to the uh te account that was derived and then also uh another key feature as well is that you can also remotely uh do a remote atation so on this case I actually uh created a remote atation with some random data and uh from there I'll just uh click here and it should uh generate a quote so I have my my quote here I I I you can uh then copy this go into the uh remote at the station explore paste it verify and um here you can see that this is actually running in a te environment

with the um the te simulator which is what we have you uh be able to develop on locally uh you would get something that would say uh unverified but um we can also uh do a little uh more checks because you don't want to just trust like our block Explorer and just take our word so you can go onchain as well and say you want to verify against uh automas a um a verifier here and you can see that we're verifying on chain and you can also um choose of the uh different um uh networks that they support as well um so the the next part I I'll show you as well is another application that's

deployed it's just like a a Jupiter notebook so that you can see like we're not you're able to uh also support uh whatever language you would like to build in and you can you can then uh start to get a little more creative but uh since you're able to connect to the socket for uh which is the tapd socket here you can then now have access to these um these uh two functions which will be TDX quote and uh the uh parameters that you would pass in is uh report data notebook this not jup notebook is itself is running inside te uh so I'll I'll uh zoom in

here so so people can see here um but yeah so you can you can run this uh here and get a quote so I have a a quotes here and then uh another key feature is is uh derived keys so you have this uh derived key function as well where you would Define your path so you could uh Define your like a root of trust and then uh pass it assault here from the subject uh and uh whenever you generate this you should uh this would generate the same key I believe on this uh one here so that you can uh derive a key and then you can then take this key and then either generate like a ecdsa uh key or uh say

Ed uh 25519 or whichever uh whichever curve you would like to uh choose but yeah this is kind of like the power that you have with you uh by building uh like dockerizing your applications and then being able to then run it in a te um some other other things uh that you could um uh get started with I have created a a little cheat sheet here um that you can access um uh at uh bit.ly dx- Che sheet um but anyways I uh here it'll it'll tell you how to get started with the uh local simulator um you can clone you'll clone the repo and

have the uh the same nextjs application as well I can uh zoom in here for anybody as well um and it'll it'll show you how to get started in just a few steps and then you're you're right away having a application uh running and being able to generate local remote at the stations and uh deriving key pairs from there as well um one of the uh interesting things that uh we we just um have like packaged up but uh want to see if any developer wants to kind of build upon it is uh we we created a a repo called ai6

ZTE um and here you can you have a a Docker file and you can uh build your own AI agent that can uh run autonomously and be able to to uh post on Twitter uh answer on Discord uh with like uh Voice or text you can choose whichever uh llm models through uh the red red pill uh API and uh also um you can have it connect to Telegram and then also generate use the uh derive key to generate uh wallet accounts for you so that you can then start uh uh transacting on chain uh autonomously with these agents so you can really get a creative and uh we have a repo here in the cheat sheet for you to uh check out

and you know get hacking on it um however you would like but um I I I wanted to uh save uh some time instead of uh going uh deep into the demo to see if there's any questions that some of the uh audience may have oh yes so um if you go to the Falla Network so so the question was is there any any templates or code that they can reference so that they can uh get started and be able to understand how to uh build say like a a model within a uh te um so if you go into the the follow Network repo here we have um a few uh

templates under uh the uh te Sim templates so this is like the te simulator we have like a a python template red pill template the uh a nextjs application but if you have like any like kind of like example like where you want to run a model uh please come byy our booth we're we're over here on this back wall so that we can kind of like guide you and tell you how you can uh get started really quick with this as well because we have our uh full uh full engineering team for you to uh for you to ask questions for us [Music]

Related talks