Prerequisites
Your application must be running in the Phala Cloud TEE environment with access to the dstack socket. In yourdocker-compose.yml
:
Quick Start
index.js
Parameters
path
(required): Unique identifier for the key. Use forward slashes to organize:app-name/feature/version
Advanced: Purpose ParameterThe This is equivalent to using a longer path:
getKey()
method accepts an optional second parameter called purpose
:getKey('wallet/ethereum/mainnet')
. The purpose parameter is purely for organization - use whichever approach feels cleaner to you.Key Properties
- Application-specific: Keys are derived from your app’s unique master key (tied to app ID)
- Deterministic: Same
path
+purpose
always generates the same key - Isolated: Different applications cannot derive each other’s keys
- 32 bytes: Raw key material suitable for various cryptographic operations
Common Use Cases
The 32-byte key can be used as:- AES-256 encryption key
- HMAC secret
- Random number generator seed
- Input for key derivation functions (KDF)
- Signing key for custom protocols
Best Practices
- Use descriptive paths:
app-name/feature/version
- Never log or expose keys outside TEE
- Use different paths for different purposes
- Version your keys in the path (e.g.,
/v1
,/v2
)