Encryption
Encryption in Data Store
The Encryption Capability provides transparent field-level encryption for data store chunks. It encrypts chunk content and metadata fields automatically during write operations and decrypts them during read operations, working seamlessly with fulltext and vector capabilities.
Encryption operates transparently—you don't need to access it directly. Once configured, it's automatically used by fulltext and vector capabilities whenever you create, update, or retrieve chunks.
Key Feature: When encryption is enabled, embeddings are generated from plaintext content before encryption. This ensures that semantic search works correctly with encrypted data, as embeddings represent the original content rather than encrypted ciphertext.
Prerequisites
This example specifically requires completion of all setup steps listed on the Prerequisites page.
You should be familiar with these concepts and components:
How Encryption Works
Transparent Operation
Encryption integrates directly with fulltext and vector capabilities. When you enable encryption on a data store:
During Write Operations: Content and metadata fields specified in the encryption configuration are encrypted before being stored.
During Read Operations: Encrypted fields are automatically decrypted when chunks are retrieved.
Embedding Generation: For vector capability, embeddings are generated from plaintext content before encryption, ensuring semantic search accuracy.
Field-Level Configuration
You can encrypt specific fields:
Content field: Encrypt the chunk content using
"content".Metadata fields: Encrypt specific metadata fields using dot notation, e.g.,
"metadata.secret_key","metadata.secret_value".Nested metadata: Support for nested metadata fields, e.g.,
"metadata.nested.secret".
Choose an Encryptor
The data store supports multiple encryptor types:
AES-GCM Encryptor
Use AESGCMEncryptor for simple encryption with a direct key:
Key Management: Store your encryption key securely. If you lose the key, you cannot decrypt your data. Consider using a key management service for production applications.
Key Rotating Encryptor
Use KeyRotatingEncryptor for scenarios requiring key rotation:
Enable Encryption
Enable encryption using the with_encryption() method. This method can be chained with other capability registration methods.
Example: Chroma Data Store
Using Encrypted Data Store
Once encryption is enabled, use the data store normally. Encryption and decryption happen automatically:
Limitations
Filter Restrictions
Encrypted fields cannot be used in filters for update or delete operations. The filter values you provide are not encrypted, so they won't match the encrypted data stored in the database.
What works:
Using non-encrypted fields like
idin filtersUsing non-encrypted metadata fields in filters
Retrieving all chunks and filtering in application code
What doesn't work:
Filtering by encrypted content:
F.eq("content", "encrypted_value")Filtering by encrypted metadata:
F.eq("metadata.secret_key", "value")
Example:
Field Type Requirements
Encrypted fields must be serializable to strings. Non-string values are automatically converted to strings before encryption.
Last updated
Was this helpful?