X25519 Confidential Payload Spec
Date: 2026-03-11
Decision
Morpheus confidential payload transport is now defined as:
This is a full protocol replacement for the old RSA transport. No backward-compatibility path is retained in the worker runtime.
Goals
- keep the transport asymmetric
- reduce public-key and envelope size compared with RSA
- keep or improve classical security
- preserve the existing Oracle request / callback flow
- keep decryption exclusively inside the TEE
Security Position
The new scheme uses:
- key agreement:
- key derivation:
- payload cipher:
Security comparison:
- is roughly classical security
- is roughly classical security
Therefore the new transport is shorter and stronger than the old
transport.Worker Public-Key API
now exposes:
Envelope Format
Confidential payloads are encoded as:
Then the whole JSON object is UTF-8 encoded and base64 wrapped before being placed in:
depending on the request type.
Key Lifecycle
The worker stores one stable X25519 private key per deployment environment.
That key is:
- generated inside the Phala worker runtime
- sealed with a dstack-derived wrapping key
- stored at
The client does not know the worker private key. Each client request instead creates a fresh ephemeral X25519 keypair locally.
So the server does not accumulate one decryption private key per user or per request.
Browser Encryption Flow
- fetch
- import the raw X25519 public key
- generate an ephemeral X25519 keypair in the browser
- derive a shared secret with the worker public key
- derive an AES-256-GCM key using HKDF-SHA256
- encrypt the plaintext JSON payload
- send only the envelope fields on-chain
Worker Decryption Flow
- parse the base64 envelope
- import the sealed worker private key
- import the sender ephemeral public key from
- derive the same shared secret
- derive the AES-256-GCM key with HKDF-SHA256
- decrypt inside the TEE
- merge the decrypted JSON patch into the request payload
On-Chain Publication
The Oracle contracts continue to expose:
They now store:
- algorithm string:
- public key string: raw X25519 public key encoded as base64
This fits within the existing contract storage shape and length bounds.
Affected Components
The protocol cutover touches:
- browser helper:
- worker key management and decryption:
- worker public-key metadata:
- example helpers:
- mainnet validation matrix:
Mainnet Validation Scope
The mainnet validation set for the new scheme covers:
- builtin provider request with public params
- builtin provider request with encrypted params
- builtin compute request with encrypted payload
- custom compute script with encrypted payload
- custom URL Oracle request with encrypted params
- custom URL Oracle request with encrypted params plus custom JS function
- builtin provider request with encrypted params plus custom JS function
Operational Rollout
Required sequence:
- deploy worker runtime with X25519 support
- verify returns the new algorithm and raw public key
- publish the new public key on-chain with
- switch example/test clients to X25519 envelopes
- run the mainnet privacy validation matrix
Non-Goals
This migration does not provide post-quantum confidentiality.
If post-quantum encryption is required later, it should be treated as a separate protocol upgrade.