Viewing Keys and Privacy Rings
Asymmetric X25519 viewing-key envelopes, disclosure policies, and composability with Solana Privacy Rings.
Confidential applications on Solana often need to prove compliance to an auditor, regulator, or counterparty without exposing encrypted state to DA nodes or the public ledger. Alder supports selective disclosure through disclosure policies and asymmetrically encrypted viewing-key envelopes (X25519 + HKDF-SHA256 + AES-256-GCM) that reveal zero bits of the content key without the auditor's private key.
Disclosure Policies
Every BlobRecord carries a policyId string in the API and its 32-byte SHA-256 hash (policy_id_hash) on chain. The contract defines four policy kinds (PolicyKindValues in @alder/contract):
| Policy ID | Intended Use |
|---|---|
private | Owner-only encrypted blobs; no viewing keys issued by default |
privacy-rings | Encrypted UTXO state diffs and compliance ring envelopes bound to Solana Privacy Rings |
auditor-scoped | Institutional or regulated payloads configured for named auditor viewing-key envelopes |
public-audit | Blobs whose viewing keys are published to designated public audit verifiers |
Custom policy strings up to 64 characters are also accepted by AnchorBlobBuildRequest.policyId and hashed to policy_id_hash on chain.
Asymmetric X25519 Viewing-Key Wrapping (v2)
@alder/sdk implements asymmetric viewing-key wrapping in generateAuditorKeypair, wrapViewingKey, and unwrapViewingKey (backend/packages/sdk/src/crypto.ts):
- Auditor keypair: The auditor calls
generateAuditorKeypair(), which generates a Web Crypto X25519 keypair. The auditor shares the 32-byte raw public key (publicKeyBase64) with publishers and keeps the PKCS8 private key (privateKeyBase64) strictly on their own device. - Ephemeral X25519 ECDH: To grant access, the publisher generates a fresh ephemeral X25519 keypair and computes a 256-bit shared secret via ECDH against
auditorX25519PubkeyBase64. - HKDF-SHA256 key derivation: Derives a 256-bit AES-GCM wrapping key bound to the ephemeral public key (salt) and context info:
info = "alder:viewing-key:x25519:v2:" || blobId || ":" || scope- AES-256-GCM key wrap: Encrypts the 32-byte blob content key with a random 12-byte IV, producing a 48-byte ciphertext + tag.
- 93-byte envelope layout: Packs
[version=2 (1B) | ephemeralX25519Pub (32B) | iv (12B) | ciphertext+tag (48B)]intowrappedKeyBase64. - Envelope registration:
grantViewingKeyposts{ issuer, auditorPubkey, scope, wrappedKeyBase64, expiresAt }toPOST /v1/blobs/:id/viewing-keys, returning aViewingKeyEnveloperecord.
wrappedKeyBase64 is encrypted with ephemeral X25519 ECDH to the auditor's public key, storing or reading the envelope publicly on GET /v1/blobs/:id/viewing-keys exposes zero bits of the content key. Only the holder of the auditor's X25519 private key can unwrap it.Auditor Decryption
An auditor holding auditorPrivateKeyBase64 calls sdk.reconstructBlob(blobId, { wrappedKeyBase64, auditorPrivateKeyBase64, scope }) or opens /app/vault:
- Fetches coded cells from
GET /v1/blobs/:id/cells. - Reconstructs the ciphertext locally via
decodeTcda. - Extracts the ephemeral X25519 public key and IV from the 93-byte v2 envelope, runs ECDH with
auditorPrivateKeyBase64, derives the HKDF-SHA256 wrap key for(blobId, scope), and decrypts the 32-byte content key viaunwrapViewingKey. - Decrypts the blob ciphertext locally via
decryptPayload.
If the auditor supplies the wrong private key, a mismatched blobId or scope, or a tampered envelope, AES-GCM authentication fails immediately on the client.
Solana Privacy Rings Composability
Solana Privacy Rings (live on mainnet November 2026) keeps encrypted token balances and custom compliance rings composable on chain. Applications using Privacy Rings can:
- Set
policyId: 'privacy-rings'when callingputPrivateBlobto bind encrypted state diffs, ring proofs, or settlement memos to a Privacy Ring workflow. - Anchor only the 32-byte
commitment_rootinBlobRecord(223bytes) on Solana instead of paying L1 rent for raw ciphertext bytes. - Issue time-bounded X25519 viewing-key envelopes (
expiresAtISO-8601 UTC timestamp) to ring compliance auditors who verify availability in/app/sampleand decrypt in/app/vault.
Next Steps
- Follow the step-by-step walkthrough in Selective Disclosure.
- See exact types for
generateAuditorKeypair,grantViewingKey,wrapViewingKey, andunwrapViewingKeyin `@alder/sdk` Reference.