Encrypted Blobs
Client-side AES-256-GCM encryption, 32-byte per-blob content keys, envelope wrapping, and zero-plaintext availability guarantees.
Every payload published through Alder is encrypted locally before a single byte is encoded or transmitted. The alder_da Solana program stores only a 32-byte commitment_root, a 32-byte blob_id_hash, and a 32-byte policy_id_hash, while DA nodes store erasure-coded ciphertext cells.
Encryption Construction
@alder/sdk uses Web Crypto (globalThis.crypto.subtle) so the exact same implementation runs in browsers and Node.js 20+:
- Key generation: Generates a fresh 32-byte (256-bit) random content key via
crypto.getRandomValues(new Uint8Array(32)). - Nonce generation: Generates a fresh 12-byte (96-bit) random IV via
crypto.getRandomValues(new Uint8Array(12)). - Authenticated encryption with `blobId` AAD: Encrypts UTF-8 string or raw
Uint8Arrayplaintext withAES-256-GCM, appending a 16-byte authentication tag. WhenblobIdis provided (always set byputPrivateBlob),alder:blob:v1:<blobId>is bound as AES-GCM Additional Authenticated Data (AAD) so ciphertext cannot be re-anchored under anotherblobIdand still decrypt. - Encoding: Returns
ciphertext(Uint8Array),contentKeyBase64,nonceBase64, andencryptionAlg: 'AES-256-GCM'.
All client encryption in @alder/sdk and the Alder Studio uses AES-256-GCM (encryptionAlg: 'AES-256-GCM').
Ciphertext Length Framing
Before 2D Reed-Solomon encoding, encodeTcda prepends a 4-byte big-endian unsigned integer (exactLen) holding ciphertext.length to the ciphertext buffer and pads the buffer to k * k * cellSizeBytes, where:
cellSizeBytes = Math.max(32, Math.ceil((ciphertext.length + 4) / (k * k)))During reconstruction, decodeTcda reads the 4-byte length header and slices flat.slice(4, 4 + exactLen) before passing the exact ciphertext bytes and GCM authentication tag to decryptPayload. Any corrupted or tampered cell that escapes verification fails AES-GCM tag authentication during decryption.
What Leaves the Client
| Field | Sent to API / DA Nodes | Stored on Solana (BlobRecord) |
|---|---|---|
| Plaintext payload | Never | Never |
32-byte content key (contentKeyBase64) | Never | Never |
12-byte IV (nonceBase64) | Yes (metadata for reconstruction) | No |
Coded ciphertext cells (n x n matrix) | Yes (dispersed to bonded nodes) | No |
32-byte commitmentRoot | Yes | Yes (commitment_root: [u8; 32]) |
blobId / blob_id_hash | Yes (blobId string) | Yes (SHA-256(blobId)) |
policyId / policy_id_hash | Yes (policyId string) | Yes (SHA-256(policyId)) |
contentKeyBase64 never leaves the publisher's environment, losing the content key (and any wrapped viewing keys) makes the blob permanently unreadable even when 100% of coded cells are available.Direct Crypto Helpers in @alder/sdk
You can call encryptPayload and decryptPayload independently of the network API:
import { encryptPayload, decryptPayload } from '@alder/sdk'
const encrypted = await encryptPayload('private settlement batch #402')
// encrypted.ciphertext: Uint8Array (plaintext + 16-byte GCM tag)
// encrypted.contentKeyBase64: string (32 random bytes, base64)
// encrypted.nonceBase64: string (12 random bytes, base64)
// encrypted.encryptionAlg: 'AES-256-GCM'
const plainBytes = await decryptPayload(
encrypted.ciphertext,
encrypted.contentKeyBase64,
encrypted.nonceBase64,
)
console.log(new TextDecoder().decode(plainBytes))Size Limits and Validation
alder_daenforcesMAX_CELL_BYTES = 512on chain (payload_size_bytes <= k^2 * 512,AlderError::PayloadTooLargeForK, code6008), guaranteeing that any single cell plus its Merkle proof fits comfortably inside a Solana transaction forrespond_challenge.- On chain,
anchor_blobenforcespayload_size_bytes > 0(AlderError::InvalidPayloadSize, code6007). blobIdmust be 4 to 64 characters matching/^[a-zA-Z0-9_-]+$/.
Next Steps
- See how encrypted bytes are turned into recoverable cells in Tunable Coded Distributed Arrays.
- Learn how auditors decrypt blobs without receiving the raw owner key in Viewing Keys and Privacy Rings.