-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
26 lines (22 loc) · 814 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
from dstack_sdk import AsyncTappdClient, DeriveKeyResponse, TdxQuoteResponse
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "The World! Call /derivekey or /tdxquote"}
@app.get("/derivekey")
async def derivekey():
client = AsyncTappdClient()
deriveKey = await client.derive_key('/', 'test')
assert isinstance(deriveKey, DeriveKeyResponse)
asBytes = deriveKey.toBytes()
assert isinstance(asBytes, bytes)
limitedSize = deriveKey.toBytes(32)
return {"deriveKey": asBytes.hex(), "derive_32bytes": limitedSize.hex()}
@app.get("/tdxquote")
async def tdxquote():
client = AsyncTappdClient()
tdxQuote = await client.tdx_quote('test')
assert isinstance(tdxQuote, TdxQuoteResponse)
return {"tdxQuote": tdxQuote}