Skip to main content
Loads an existing encrypted index and returns an instance of EncryptedIndex.
def load_index(self,
               index_name: str,
               index_key: bytes,
               logger: Logger | None = None,
               *,
               user_id: bytes | None = None) -> EncryptedIndex

Parameters

ParameterTypeDefaultDescription
index_namestr-Name of the index to load.
index_keybytes-32-byte encryption key. For a normal load this is the index KEK used during create_index(). For an RBAC user-scoped load (user_id set), this is that user’s 32-byte KEK.
loggerLoggerNone(Optional) Logger instance for capturing operation logs.
user_idbytes | NoneNone(Optional, keyword-only) 16-byte RBAC user identifier. When set, the index is loaded scoped to that user and index_key is interpreted as the user’s KEK; per-operation permissions are enforced.
RBAC user keys are minted by the root KEK holder via create_user_keys. A user then loads with load_index(name, their_user_kek, user_id=their_id). See access control.

Returns

EncryptedIndex: An instance of the loaded encrypted index.

Exceptions

  • Throws if the index name does not exist.
  • Throws if the index could not be loaded or decrypted.

Example Usage

import cyborgdb_core as cyborgdb

api_key = "your_api_key_here"  # Replace with your CyborgDB API key

client = cyborgdb.Client(api_key, cyborgdb.StorageConfig.disk("/tmp/cyborgdb"))

index_name = "my_index"
index_key = my_index_key  # Same 32-byte KEK used during index creation

# Optional: Set up logging
logger = cyborgdb.Logger.instance()
logger.configure(level="debug", to_file=True, file_path="index_loading.log")

# Load the existing index with logging enabled
index = client.load_index(index_name, index_key, logger=logger)

RBAC user-scoped load

# Load the index scoped to an RBAC user, passing that user's KEK as index_key
index = client.load_index(
    index_name,
    user_kek,            # the user's 32-byte KEK
    user_id=user_id,     # the user's 16-byte identifier
)