When sensitive data is processed on third-party platforms or untrusted compute environments, standard storage-layer encryption is not enough: the compute layer still sees plaintext. The Confidential Engine for Apache Spark for AnalyticDB for MySQL integrates encryption directly into the query execution pipeline, keeping data encrypted during both storage and computation. Only key owners can decrypt the data, and keys never leave your control.
The engine is one of the first products certified by the China Academy of Information and Communications Technology (CAICT) for performance and security in trusted execution environments (TEEs).
Two editions are available: Basic Edition for straightforward ciphertext storage, and High-performance Edition (recommended) for vectorized, Parquet-native encryption with no external tool dependencies.
Use cases
The Confidential Engine addresses data security in three scenarios:
-
Secure data storage and computing: In untrusted environments such as third-party platforms, the engine protects key analytics applications — for example, investment and financial analysis — ensuring data stays encrypted during both storage and computation and reducing the risk of plaintext exposure.
-
Sensitive data compliance: When sensitive data such as personally identifiable information (PII) or genetic data is processed by a third party, the engine enforces end-to-end encryption to meet compliance requirements.
-
Secure data sharing: Key ownership controls data usage rights and access frequency, enabling secure data sharing and preventing data breaches. The following figure illustrates this scenario.
Choose an edition
The Confidential Engine is available in two editions. Choose based on your performance and toolchain requirements.
Basic Edition transmits and stores sensitive data as ciphertext in EncBlocksSource format. Only key owners can decrypt the data. Encryption and decryption require the client tools provided by Apache Spark.
High-performance Edition (recommended) builds on Basic Edition's encryption capabilities and integrates Apache Gluten and Velox to provide vectorization. It uses Parquet Modular Encryption format, which is compatible with any standard Parquet tool — no additional client dependencies required. At 1.9 times the performance of open source Apache Spark 3.2.0 and 4 times faster than Basic Edition, it is the preferred choice for production workloads.
The following table compares the two editions. Both editions are supported on AnalyticDB for MySQL Enterprise Edition, Basic Edition, and Data Lakehouse Edition.
| Basic Edition | High-performance Edition | |
|---|---|---|
| Confidential data format | EncBlocksSource format | Parquet Modular Encryption format |
| Performance (vs. open source Apache Spark) | 0.5x | 1.9x |
| SQL compatibility | Compatible | Compatible |
| Data format compatibility | Incompatible | Compatible |
| Tool dependency | Requires Apache Spark client tools for encryption and decryption | None — any tool supporting Parquet Modular Encryption works |
| Key types | MEK, DEK | MEK, KEK, DEK |
| Supported AnalyticDB editions | Enterprise Edition, Basic Edition, Data Lakehouse Edition | Enterprise Edition, Basic Edition, Data Lakehouse Edition |
Key concepts
Key hierarchy
The Confidential Engine uses a layered key structure to simplify management and improve security. Higher-level keys protect lower-level keys; only the lowest-level key directly encrypts data.
Master encryption key (MEK)
The MEK is the root key in the hierarchy. It protects all other keys (KEKs and DEKs) but is never used to encrypt data directly. MEKs are generated using standard tools such as OpenSSL.
-
Basic Edition supports a 16-byte hex-encoded string.
-
High-performance Edition supports a 16-, 24-, or 32-byte Base64-encoded string.
Generate an MEK with OpenSSL:
# Generate a 16-byte hex-encoded key (Basic Edition)
openssl rand -hex 16
# Generate a 24-byte Base64-encoded key (High-performance Edition)
openssl rand -base64 24
The MEK is the root credential for accessing encrypted data. If the MEK is lost, the data cannot be recovered. Keep your MEK secure.
Key encryption key (KEK) (High-performance Edition only)
The KEK is randomly generated by the system or derived from the MEK. It encrypts and decrypts data encryption keys (DEKs). Each KEK has a unique 16-byte identifier and is stored in the file's metadata after encryption.
Data encryption key (DEK)
The DEK encrypts the actual data in files. It is generated by the system or derived from the MEK and is protected by the MEK (Basic Edition) or the KEK (High-performance Edition).
Bring Your Own Key (BYOK)
The Confidential Engine supports Bring Your Own Key (BYOK), giving you full control over your MEKs. In the High-performance Edition, the Parquet Modular Encryption format lets you supply your own keys to encrypt and decrypt data. During computation, the keys are held in memory by the InMemoryKMS class and destroyed when the computation completes.
How it works
Basic Edition
High-performance Edition
Benefits
Rich SQL compatibility
The Confidential Engine supports all standard SQL operators. Existing applications work with simple configuration changes and no SQL modifications. Usage is consistent with open source Apache Spark.
The High-performance Edition additionally supports hybrid processing across data at different privacy levels, including mixed-join computations on plaintext tables, plaintext and ciphertext tables, and ciphertext tables. Computation results can also be encrypted for output to enhance data security.
Column-level encryption
The High-performance Edition supports encrypting individual columns in data files. This reduces unnecessary data I/O overhead compared to encrypting entire files.
Full data control
BYOK gives you full ownership of your encryption keys. The High-performance Edition uses Parquet Modular Encryption, so any compatible tool can read and write encrypted data without vendor lock-in.
Usage notes
-
When using BYOK, keep your MEKs secure. If a key is lost, the encrypted data cannot be recovered.
-
Different compute engines may process data with different precision. If you encounter issues, submit a ticket.