Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed images/cloud-cert-chain.png
Binary file not shown.
4 changes: 2 additions & 2 deletions phala-cloud/attestation/api-quickstart.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
description: Get a shareable Intel DCAP quote verified with Phala Cloud's API in 5 minutes
description: Learn how to verify Intel TDX attestation quotes using Phala Cloud's API.
title: Cloud Attestation API
---

## Verify Your Quote in 5 Minutes
## Verify your quote

You have an attestation quote and want to verify it using Phala Cloud's API. This guide gets you working fast.

Expand Down
143 changes: 92 additions & 51 deletions phala-cloud/attestation/get-attestation.mdx
Original file line number Diff line number Diff line change
@@ -1,69 +1,110 @@
---
description: Generate Intel SGX and TDX attestation quotes using DStack SDK and Phala Cloud platform
title: Generate Attestation
description: Learn how to get CVM attestation on Phala Cloud using dashboard or dstack SDK.
title: Get Attestation
---

The cloud will generate a default RA report for your application when it is bootstrapped. You can view this report on the dashboard under the **Attestation** tab and verify it by clicking the **Check** **Attestation** button.
## Introduction

<Frame>
<img src="/images/cloud-cert-chain.png" alt="cert-chain" />
</Frame>
There are two ways to retrieve the attestation report of your CVM on Phala Cloud:

There are two steps needed to generate a new RA report, rather than using the default one, which allows you to prove the execution of your code.
1. **Dashboard** - View the default attestation report on the dashboard
2. **dstack SDK** - Generate a new attestation report programmatically within your application

### Config docker compose file
Choose the method that best fits your workflow. The dashboard is great for quick verification, while the SDK enables dynamic attestation generation in your applications.

This Docker Compose file spins up a Jupyter Notebook environment, and importantly, it's configured the `volumes` to connect to the Dstack API by mounting its socket file (`/var/run/tappd.sock`) into the container. This allows the Jupyter Notebook running inside the TEE to interact with the Dstack service like generate a remote attestation, get a TLS key, or generate a key for chains like ETH (`ECDSA, K256 curve`) or SOL (`ed25519`).
## View attestation report on dashboard

For development convenience, this setup grants sudo privileges inside the container (`environment`), runs the Jupyter server with root user permissions (`user`), and starts the notebook with token-based authentication using the `TOKEN` environment variable (`command`).
You can view the attestation report on the dashboard under the **Attestation** tab and verify it by clicking the **Check Attestation** button.

```yaml
version: '3'
services:
jupyter:
image: quay.io/jupyter/base-notebook
ports:
- 8080:8888
volumes:
- /var/run/tappd.sock:/var/run/tappd.sock
environment:
- GRANT_SUDO=yes
user: root
command: "start-notebook.sh --NotebookApp.token=${TOKEN}"
```

### Generate RA report inside your application code
## Generate attestation programmatically

In your application, you can generate the RA report using the [Dstack SDK](https://www.npmjs.com/package/@phala/dstack-sdk?activeTab=readme), which supports Python, JS, and Go. The `user-data` argument allows you to attach your own data to the RA report.
### Using dstack SDK

```javascript
import { TappdClient } from '@phala/dstack-sdk';
In your CVM application, you can generate attestation reports programmatically using the [dstack SDK](https://www.npmjs.com/package/@phala/dstack-sdk?activeTab=readme), which supports Python, JavaScript, and Go. The `user-data` argument allows you to attach custom data to the attestation report.

const client = new TappdClient();
<CodeGroup>
```javascript TypeScript
import { DstackClient } from '@phala/dstack-sdk';

// Show the information of the Base Image.
await client.info();

// Get a TDX quote for the given custom data and hash algorithm.
const quoteResult = await client.tdxQuote('user-data', 'sha256');
console.log(quoteResult.quote); // TDX quote in hex format
console.log(quoteResult.event_log); // Event log
const rtmrs = quoteResult.replayRtmrs(); // Replay RTMRs
```
const client = new DstackClient();

You can implement the above code in your application as an public API that anyone can call to generate a new RA report.
// Get TEE instance information
const info = await client.info();
console.log('App ID:', info.app_id);
console.log('Instance ID:', info.instance_id);
console.log('App Name:', info.app_name);
console.log('TCB Info:', info.tcb_info);

### Next Steps
// Generate remote attestation quote with custom data
const applicationData = JSON.stringify({
version: '1.0.0',
timestamp: Date.now(),
user_id: 'alice'
});

Once you have your quote generated, you can:
const quote = await client.getQuote(applicationData);
console.log('TDX Quote:', quote.quote);
console.log('Event Log:', quote.event_log);

1. **[Verify with API](/phala-cloud/attestation/api-quickstart)** - Upload your quote to Phala Cloud for verification
2. **[Understand the Data](/phala-cloud/attestation/overview)** - Learn what each field in your quote means
3. **[API Reference](/phala-cloud/phala-cloud-api/attestations)** - Complete verification service documentation

### Use Cases
// Verify measurement registers
const rtmrs = quote.replayRtmrs();
console.log('RTMR0-3:', rtmrs);
```

The `user-data` field enables powerful applications:
- **Key Binding**: Set a public key as user-data, then sign messages with the private key
- **Identity Proof**: Include application identifiers or certificates
- **Challenge Response**: Respond to verification challenges from remote parties
```python Python
import json
import time
from dstack_sdk import DstackClient

# Create synchronous client - automatically connects to /var/run/dstack.sock
client = DstackClient()

# Get TEE instance information
info = client.info()
print('App ID:', info.app_id)
print('Instance ID:', info.instance_id)
print('App Name:', info.app_name)
print('TCB Info:', info.tcb_info)

# Generate remote attestation quote
application_data = json.dumps({
"version": "1.0.0",
"timestamp": time.time(),
"user_id": "alice"
})

quote = client.get_quote(application_data.encode())
print('TDX Quote:', quote.quote)
print('Event Log:', quote.event_log)

# Verify measurement registers
rtmrs = quote.replay_rtmrs()
print('RTMR0-3:', rtmrs)
```
</CodeGroup>

You can implement this code in your application as a public API that anyone can call to generate new attestation reports on demand.

## Next steps

Once you have your attestation quote generated, you can:

<CardGroup cols={2}>
<Card
icon="shield-check"
href="/phala-cloud/attestation/verifying-attestation"
title="Verify Attestation"
arrow="true"
>
Learn how to verify your attestation quote using Phala Cloud's API
</Card>

<Card
icon="api"
href="/phala-cloud/attestation/api-quickstart"
title="API Quickstart"
arrow="true"
>
Get started with Phala Cloud's attestation verification API
</Card>
</CardGroup>
Loading