lockEncryption

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.

circle-info

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.

chevron-rightPrerequisiteshashtag

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:

  1. During Write Operations: Content and metadata fields specified in the encryption configuration are encrypted before being stored.

  2. During Read Operations: Encrypted fields are automatically decrypted when chunks are retrieved.

  3. 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:

  1. Content field: Encrypt the chunk content using "content".

  2. Metadata fields: Encrypt specific metadata fields using dot notation, e.g., "metadata.secret_key", "metadata.secret_value".

  3. 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:

circle-exclamation

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 id in filters

  • Using 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?