API Reference
AlloyError documentation is not correctly generated. Its definition is included here manually:
class AlloyError(Exception):
"""
Errors related to IronCore Alloy SDK
"""
class InvalidConfiguration(AlloyError):
"""
Error while loading configuration.
"""
class InvalidKey(AlloyError):
"""
Error with user key used
"""
class InvalidInput(AlloyError):
"""
Error with user input
"""
class EncryptError(AlloyError):
"""
Errors while encrypting
"""
class DecryptError(AlloyError):
"""
Errors while decrypting
"""
class DocumentError(AlloyError):
"""
Error when encrypting or decrypting documents
"""
class ProtobufError(AlloyError):
"""
Error when parsing encryption headers/metadata
"""
class TenantSecurityError(AlloyError):
"""
Error with requests to TSC
"""
class IronCoreDocumentsError(AlloyError):
"""
Error with IronCore Documents
"""
Keep in mind that this manual definition may get out of step with the actual source so refer to the source if there is any ambiguity.
ironcore_alloy.ironcore_alloy
Attributes
AlloyError = _UniffiTempAlloyError
module-attribute
Errors related to IronCore Alloy SDK
DerivationPath = str
module-attribute
DocumentId = str
module-attribute
EdekWithKeyIdHeader = EncryptedBytes
module-attribute
EncryptedAttachedDocument = EncryptedBytes
module-attribute
EncryptedAttachedDocuments = dict[DocumentId, EncryptedAttachedDocument]
module-attribute
EncryptedBytes = bytes
module-attribute
EncryptedDocuments = dict[DocumentId, EncryptedDocument]
module-attribute
EncryptedFields = dict[FieldId, EncryptedField]
module-attribute
EncryptedVectors = dict[VectorId, EncryptedVector]
module-attribute
FieldId = str
module-attribute
GenerateFieldQueryResult = dict[FieldId, typing.List[EncryptedField]]
module-attribute
GenerateVectorQueryResult = dict[VectorId, typing.List[EncryptedVector]]
module-attribute
KeyId = int
module-attribute
PlaintextAttachedDocument = PlaintextBytes
module-attribute
PlaintextAttachedDocuments = dict[DocumentId, PlaintextAttachedDocument]
module-attribute
PlaintextBytes = bytes
module-attribute
PlaintextDocument = dict[FieldId, PlaintextBytes]
module-attribute
PlaintextDocuments = dict[DocumentId, PlaintextDocument]
module-attribute
PlaintextDocumentsWithEdeks = dict[DocumentId, PlaintextDocumentWithEdek]
module-attribute
PlaintextFields = dict[FieldId, PlaintextField]
module-attribute
PlaintextVectors = dict[VectorId, PlaintextVector]
module-attribute
SecretPath = str
module-attribute
TenantId = str
module-attribute
VectorId = str
module-attribute
Classes
AdminEvent
Bases: Enum
Attributes
ADD = 0
class-attribute
instance-attribute
CHANGE_PERMISSIONS = 1
class-attribute
instance-attribute
CHANGE_SETTING = 2
class-attribute
instance-attribute
REMOVE = 3
class-attribute
instance-attribute
AlloyHttpClientHeaders(*, content_type, authorization)
dataclass
AlloyHttpClientResponse(*, json_body, status_code)
dataclass
AlloyMetadata(tenant_id, requesting_user_or_service_id, data_label, source_ip, object_id, request_id, other_data)
Bases: AlloyMetadataProtocol
Holds metadata fields as part of an SDK call. Each encrypted value will have metadata that associates
it to a tenant ID as well as optional fields for other arbitrary key/value pairs and a request ID to send to the Tenant Security Proxy.
Only the tenant ID will be used in Standalone SDKs, which can be created easily with new_simple().
Constructor for AlloyMetadata which contains the tenant's ID and other metadata to send to the Tenant Security Proxy.
Arguments
tenant_id- Unique ID of tenant that is performing the operation.requesting_user_or_service_id- Unique ID of user/service that is processing data. Must be non-empty.data_label- Classification of data being processed.source_ip- IP address of the initiator of this document request.object_id- ID of the object/document being acted on in the host system.request_id- Unique ID that ties host application request ID to tenant.other_data- Additional String key/value pairs to add to metadata.
Source code in ironcore_alloy/ironcore_alloy.py
Functions
new_simple(tenant_id)
classmethod
Simplified constructor for AlloyMetadata that only takes the tenant's ID and the ID of the user/service that is processing data.
Arguments
tenant_id- Unique ID of tenant that is performing the operation.
Source code in ironcore_alloy/ironcore_alloy.py
AlloyMetadataProtocol
Bases: Protocol
Holds metadata fields as part of an SDK call. Each encrypted value will have metadata that associates
it to a tenant ID as well as optional fields for other arbitrary key/value pairs and a request ID to send to the Tenant Security Proxy.
Only the tenant ID will be used in Standalone SDKs, which can be created easily with new_simple().
CustomEvent(*, event_name)
dataclass
DataEvent
Bases: Enum
Attributes
CHANGE_PERMISSIONS = 7
class-attribute
instance-attribute
CREATE = 4
class-attribute
instance-attribute
DECRYPT = 3
class-attribute
instance-attribute
DELETE = 5
class-attribute
instance-attribute
DENY_ACCESS = 6
class-attribute
instance-attribute
ENCRYPT = 2
class-attribute
instance-attribute
EXPORT = 1
class-attribute
instance-attribute
IMPORT = 0
class-attribute
instance-attribute
DecomposedHeader(*, key_id, remaining_bytes)
dataclass
DeterministicDecryptBatchResult(*, successes, failures)
dataclass
DeterministicEncryptBatchResult(*, successes, failures)
dataclass
DeterministicFieldOps(*args, **kwargs)
Bases: DeterministicFieldOpsProtocol
Source code in ironcore_alloy/ironcore_alloy.py
Functions
decrypt(encrypted_field, metadata)
async
Decrypt a field that was deterministically encrypted with the provided metadata.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_fields, metadata)
async
Decrypt each of the fields that were deterministically encrypted with the provided metadata. Note that because the metadata is shared between the fields, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_field, metadata)
async
Encrypt a field with the provided metadata.
Because the field is encrypted deterministically with each call, the result will be the same for repeated calls.
This allows for exact matches and indexing of the encrypted field, but comes with some security considerations.
If you don't need to support these use cases, we recommend using standard encryption instead.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(fields, metadata)
async
Deterministically encrypt the provided fields with the provided metadata.
Because the fields are encrypted deterministically with each call, the result will be the same for repeated calls.
This allows for exact matches and indexing of the encrypted field, but comes with some security considerations.
If you don't need to support these use cases, we recommend using standard encryption instead.
Source code in ironcore_alloy/ironcore_alloy.py
generate_query_field_values(fields_to_query, metadata)
async
Encrypt each plaintext field with any Current and InRotation keys for the provided secret path. The resulting encrypted fields should be used in tandem when querying the data store.
Source code in ironcore_alloy/ironcore_alloy.py
get_in_rotation_prefix(secret_path, derivation_path, metadata)
async
Generate a prefix that could used to search a data store for fields encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Source code in ironcore_alloy/ironcore_alloy.py
rotate_fields(encrypted_fields, metadata, new_tenant_id)
async
Re-encrypt already encrypted fields with the Current key for the provided tenant. The metadata passed
must contain the tenant ID that the fields were originally encrypted to. If new_tenant_id is empty,
the fields will simply be encrypted with the same tenant's current secret.
Source code in ironcore_alloy/ironcore_alloy.py
DeterministicFieldOpsProtocol
Bases: Protocol
Functions
decrypt(encrypted_field, metadata)
async
Decrypt a field that was deterministically encrypted with the provided metadata.
decrypt_batch(encrypted_fields, metadata)
async
Decrypt each of the fields that were deterministically encrypted with the provided metadata. Note that because the metadata is shared between the fields, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_field, metadata)
async
Encrypt a field with the provided metadata.
Because the field is encrypted deterministically with each call, the result will be the same for repeated calls.
This allows for exact matches and indexing of the encrypted field, but comes with some security considerations.
If you don't need to support these use cases, we recommend using standard encryption instead.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(fields, metadata)
async
Deterministically encrypt the provided fields with the provided metadata.
Because the fields are encrypted deterministically with each call, the result will be the same for repeated calls.
This allows for exact matches and indexing of the encrypted field, but comes with some security considerations.
If you don't need to support these use cases, we recommend using standard encryption instead.
Source code in ironcore_alloy/ironcore_alloy.py
generate_query_field_values(fields_to_query, metadata)
async
Encrypt each plaintext field with any Current and InRotation keys for the provided secret path. The resulting encrypted fields should be used in tandem when querying the data store.
Source code in ironcore_alloy/ironcore_alloy.py
get_in_rotation_prefix(secret_path, derivation_path, metadata)
async
Generate a prefix that could used to search a data store for fields encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Source code in ironcore_alloy/ironcore_alloy.py
rotate_fields(encrypted_fields, metadata, new_tenant_id)
async
Re-encrypt already encrypted fields with the Current key for the provided tenant. The metadata passed
must contain the tenant ID that the fields were originally encrypted to. If new_tenant_id is empty,
the fields will simply be encrypted with the same tenant's current secret.
Source code in ironcore_alloy/ironcore_alloy.py
DeterministicRotateResult(*, successes, failures)
dataclass
Source code in ironcore_alloy/ironcore_alloy.py
Attributes
failures = failures
instance-attribute
successes = successes
instance-attribute
EdekType
Bases: Enum
Attributes
DATA_CONTROL_PLATFORM = 2
class-attribute
instance-attribute
SAAS_SHIELD = 1
class-attribute
instance-attribute
STANDALONE = 0
class-attribute
instance-attribute
EncryptedDocument(*, edek, document)
dataclass
Document and EDEK (encrypted document encryption key) generated by document_encrypt/documentEncrypt.
Note that document_encrypt_deterministic/documentEncryptDeterministic doesn't use this type
as it prefixes an encryption header to the encrypted document map instead of using a separate EDEK.
Source code in ironcore_alloy/ironcore_alloy.py
Attributes
document = document
instance-attribute
edek = edek
instance-attribute
EncryptedField(*, encrypted_field, secret_path, derivation_path)
dataclass
Source code in ironcore_alloy/ironcore_alloy.py
Attributes
derivation_path = derivation_path
instance-attribute
encrypted_field = encrypted_field
instance-attribute
secret_path = secret_path
instance-attribute
EncryptedVector(*, encrypted_vector, secret_path, derivation_path, paired_icl_info)
dataclass
Source code in ironcore_alloy/ironcore_alloy.py
Attributes
derivation_path = derivation_path
instance-attribute
encrypted_vector = encrypted_vector
instance-attribute
paired_icl_info = paired_icl_info
instance-attribute
secret_path = secret_path
instance-attribute
HttpClient
Trait describing the functionality ironcore-alloy needs from a client to make SaaS Shield requests.
Functions
post_json(url, json_body, headers)
async
Makes a call with a JSON body and returns a string of the JSON result. Only JSON requests and responses are supported, the provided headers will include a correct content type.
Source code in ironcore_alloy/ironcore_alloy.py
HttpClientImpl(*args, **kwargs)
Bases: HttpClient
Trait describing the functionality ironcore-alloy needs from a client to make SaaS Shield requests.
Source code in ironcore_alloy/ironcore_alloy.py
Functions
post_json(url, json_body, headers)
async
Makes a call with a JSON body and returns a string of the JSON result. Only JSON requests and responses are supported, the provided headers will include a correct content type.
Source code in ironcore_alloy/ironcore_alloy.py
InternalError
Bases: Exception
KeyIdHeader(*, key_id, edek_type, payload_type)
dataclass
Source code in ironcore_alloy/ironcore_alloy.py
Attributes
edek_type = edek_type
instance-attribute
key_id = key_id
instance-attribute
payload_type = payload_type
instance-attribute
KmsError
Bases: Enum
Errors originating from or relating to the tenant's KMS
Attributes
INVALID_PROVIDED_EDEK = 3
class-attribute
instance-attribute
KMS_ACCOUNT_ISSUE = 10
class-attribute
instance-attribute
KMS_AUTHORIZATION_FAILED = 6
class-attribute
instance-attribute
KMS_CONFIGURATION_DISABLED = 2
class-attribute
instance-attribute
KMS_CONFIGURATION_INVALID = 7
class-attribute
instance-attribute
KMS_THROTTLED = 9
class-attribute
instance-attribute
KMS_UNREACHABLE = 8
class-attribute
instance-attribute
KMS_UNWRAP_FAILED = 5
class-attribute
instance-attribute
KMS_WRAP_FAILED = 4
class-attribute
instance-attribute
NO_PRIMARY_KMS_CONFIGURATION = 0
class-attribute
instance-attribute
UNKNOWN_TENANT_OR_NO_ACTIVE_KMS_CONFIGURATIONS = 1
class-attribute
instance-attribute
PayloadType
Bases: Enum
Attributes
DETERMINISTIC_FIELD = 0
class-attribute
instance-attribute
STANDARD_EDEK = 2
class-attribute
instance-attribute
VECTOR_METADATA = 1
class-attribute
instance-attribute
PeriodicEvent
Bases: Enum
Attributes
CREATE_BACKUP = 1
class-attribute
instance-attribute
ENFORCE_RETENTION_POLICY = 0
class-attribute
instance-attribute
PlaintextDocumentWithEdek(*, edek, document)
dataclass
PlaintextField(*, plaintext_field, secret_path, derivation_path)
dataclass
Source code in ironcore_alloy/ironcore_alloy.py
Attributes
derivation_path = derivation_path
instance-attribute
plaintext_field = plaintext_field
instance-attribute
secret_path = secret_path
instance-attribute
PlaintextVector(*, plaintext_vector, secret_path, derivation_path)
dataclass
Source code in ironcore_alloy/ironcore_alloy.py
Attributes
derivation_path = derivation_path
instance-attribute
plaintext_vector = plaintext_vector
instance-attribute
secret_path = secret_path
instance-attribute
RekeyAttachedDocumentsBatchResult(*, successes, failures)
dataclass
Source code in ironcore_alloy/ironcore_alloy.py
Attributes
failures = failures
instance-attribute
successes = successes
instance-attribute
RekeyEdeksBatchResult(*, successes, failures)
dataclass
Source code in ironcore_alloy/ironcore_alloy.py
Attributes
failures = failures
instance-attribute
successes = successes
instance-attribute
RotatableSecret(current_secret, in_rotation_secret)
Bases: RotatableSecretProtocol
A single secret that allows for rotation within a secret path. Used for Deterministic and Vector operations.
Create a rotating secret. This will error if both secrets are unset. If no secret for a path is desired, leave that path out of the configuration entirely instead.
Source code in ironcore_alloy/ironcore_alloy.py
RotatableSecretProtocol
Bases: Protocol
A single secret that allows for rotation within a secret path. Used for Deterministic and Vector operations.
SaasShield(config)
Bases: SaasShieldProtocol
Source code in ironcore_alloy/ironcore_alloy.py
Functions
deterministic()
Source code in ironcore_alloy/ironcore_alloy.py
standard()
Source code in ironcore_alloy/ironcore_alloy.py
standard_attached()
Source code in ironcore_alloy/ironcore_alloy.py
vector()
Source code in ironcore_alloy/ironcore_alloy.py
SaasShieldConfiguration(tsp_uri, api_key, approximation_factor, http_client, legacy_tsc_write_format=False, allow_insecure_http=False)
Bases: SaasShieldConfigurationProtocol
Configuration for the SaaS Shield SDKs. Sets the TSP domain/URI and API key to be used for SaaS Shield operations.
Source code in ironcore_alloy/ironcore_alloy.py
Functions
new_with_scaling_factor(tsp_uri, api_key, approximation_factor, http_client, legacy_tsc_write_format=False, allow_insecure_http=False)
classmethod
Source code in ironcore_alloy/ironcore_alloy.py
SaasShieldConfigurationProtocol
Bases: Protocol
Configuration for the SaaS Shield SDKs. Sets the TSP domain/URI and API key to be used for SaaS Shield operations.
SaasShieldDeterministicClient(*args, **kwargs)
Bases: SaasShieldDeterministicClientProtocol, DeterministicFieldOpsProtocol, SaasShieldSecurityEventOpsProtocol
Source code in ironcore_alloy/ironcore_alloy.py
Functions
decrypt(encrypted_field, metadata)
async
Decrypt a field that was deterministically encrypted with the provided metadata.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_fields, metadata)
async
Decrypt each of the fields that were deterministically encrypted with the provided metadata. Note that because the metadata is shared between the fields, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_field, metadata)
async
Encrypt a field with the provided metadata.
Because the field is encrypted deterministically with each call, the result will be the same for repeated calls.
This allows for exact matches and indexing of the encrypted field, but comes with some security considerations.
If you don't need to support these use cases, we recommend using standard encryption instead.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_fields, metadata)
async
Deterministically encrypt the provided fields with the provided metadata.
Because the fields are encrypted deterministically with each call, the result will be the same for repeated calls.
This allows for exact matches and indexing of the encrypted field, but comes with some security considerations.
If you don't need to support these use cases, we recommend using standard encryption instead.
Source code in ironcore_alloy/ironcore_alloy.py
generate_query_field_values(fields_to_query, metadata)
async
Encrypt each plaintext field with any Current and InRotation keys for the provided secret path. The resulting encrypted fields should be used in tandem when querying the data store.
Source code in ironcore_alloy/ironcore_alloy.py
get_in_rotation_prefix(secret_path, derivation_path, metadata)
async
Generate a prefix that could used to search a data store for fields encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Source code in ironcore_alloy/ironcore_alloy.py
log_security_event(event, metadata, event_time_millis)
async
Log the security event event to the tenant's log sink.
If the event time is unspecified the current time will be used.
Source code in ironcore_alloy/ironcore_alloy.py
rotate_fields(encrypted_fields, metadata, new_tenant_id)
async
Re-encrypt already encrypted fields with the Current key for the provided tenant. The metadata passed
must contain the tenant ID that the fields were originally encrypted to. If new_tenant_id is empty,
the fields will simply be encrypted with the same tenant's current secret.
Source code in ironcore_alloy/ironcore_alloy.py
SaasShieldDeterministicClientProtocol
Bases: Protocol
Functions
decrypt(encrypted_field, metadata)
async
Decrypt a field that was deterministically encrypted with the provided metadata.
decrypt_batch(encrypted_fields, metadata)
async
Decrypt each of the fields that were deterministically encrypted with the provided metadata. Note that because the metadata is shared between the fields, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_field, metadata)
async
Encrypt a field with the provided metadata.
Because the field is encrypted deterministically with each call, the result will be the same for repeated calls.
This allows for exact matches and indexing of the encrypted field, but comes with some security considerations.
If you don't need to support these use cases, we recommend using standard encryption instead.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_fields, metadata)
async
Deterministically encrypt the provided fields with the provided metadata.
Because the fields are encrypted deterministically with each call, the result will be the same for repeated calls.
This allows for exact matches and indexing of the encrypted field, but comes with some security considerations.
If you don't need to support these use cases, we recommend using standard encryption instead.
Source code in ironcore_alloy/ironcore_alloy.py
generate_query_field_values(fields_to_query, metadata)
async
Encrypt each plaintext field with any Current and InRotation keys for the provided secret path. The resulting encrypted fields should be used in tandem when querying the data store.
Source code in ironcore_alloy/ironcore_alloy.py
get_in_rotation_prefix(secret_path, derivation_path, metadata)
async
Generate a prefix that could used to search a data store for fields encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Source code in ironcore_alloy/ironcore_alloy.py
log_security_event(event, metadata, event_time_millis)
async
Log the security event event to the tenant's log sink.
If the event time is unspecified the current time will be used.
Source code in ironcore_alloy/ironcore_alloy.py
rotate_fields(encrypted_fields, metadata, new_tenant_id)
async
Re-encrypt already encrypted fields with the Current key for the provided tenant. The metadata passed
must contain the tenant ID that the fields were originally encrypted to. If new_tenant_id is empty,
the fields will simply be encrypted with the same tenant's current secret.
Source code in ironcore_alloy/ironcore_alloy.py
SaasShieldProtocol
Bases: Protocol
Functions
deterministic()
standard()
standard_attached()
SaasShieldSecurityEventOps(*args, **kwargs)
Bases: SaasShieldSecurityEventOpsProtocol
Source code in ironcore_alloy/ironcore_alloy.py
Functions
log_security_event(event, metadata, event_time_millis)
async
Log the security event event to the tenant's log sink.
If the event time is unspecified the current time will be used.
Source code in ironcore_alloy/ironcore_alloy.py
SaasShieldSecurityEventOpsProtocol
Bases: Protocol
Functions
log_security_event(event, metadata, event_time_millis)
async
Log the security event event to the tenant's log sink.
If the event time is unspecified the current time will be used.
Source code in ironcore_alloy/ironcore_alloy.py
SaasShieldStandardAttachedClient(*args, **kwargs)
Bases: SaasShieldStandardAttachedClientProtocol, SaasShieldSecurityEventOpsProtocol, StandardAttachedDocumentOpsProtocol
Source code in ironcore_alloy/ironcore_alloy.py
Functions
decrypt(attached_document, metadata)
async
Decrypt a document that was encrypted with the provided metadata. The document must have been encrypted using attached encryption and not deterministic or standard encryption.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_documents, metadata)
async
Decrypt multiple documents that were encrypted with the provided metadata. The documents must have been encrypted using attached encryption and not deterministic or standard encryption.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. A DEK (document encryption key) will be generated and encrypted using a derived key. The result is a single blob of bytes with the edek put on the front of it.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_documents, metadata)
async
Encrypt multiple documents with the provided metadata. A DEK (document encryption key) will be generated for each document and encrypted using a derived key.
Source code in ironcore_alloy/ironcore_alloy.py
get_searchable_edek_prefix(id)
Generate a prefix that could used to search a data store for documents encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Note that this will not work for matching values that don't use our key_id_header format, such as cloaked search.
Source code in ironcore_alloy/ironcore_alloy.py
log_security_event(event, metadata, event_time_millis)
async
Log the security event event to the tenant's log sink.
If the event time is unspecified the current time will be used.
Source code in ironcore_alloy/ironcore_alloy.py
rekey_documents(encrypted_documents, metadata, new_tenant_id)
async
Decrypt the provided documents and re-encrypt them using the tenant's current key. If new_tenant_id is None,
the documents will be encrypted to the original tenant.
Source code in ironcore_alloy/ironcore_alloy.py
SaasShieldStandardAttachedClientProtocol
Bases: Protocol
Functions
decrypt(attached_document, metadata)
async
Decrypt a document that was encrypted with the provided metadata. The document must have been encrypted using attached encryption and not deterministic or standard encryption.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_documents, metadata)
async
Decrypt multiple documents that were encrypted with the provided metadata. The documents must have been encrypted using attached encryption and not deterministic or standard encryption.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. A DEK (document encryption key) will be generated and encrypted using a derived key. The result is a single blob of bytes with the edek put on the front of it.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_documents, metadata)
async
Encrypt multiple documents with the provided metadata. A DEK (document encryption key) will be generated for each document and encrypted using a derived key.
Source code in ironcore_alloy/ironcore_alloy.py
get_searchable_edek_prefix(id)
Generate a prefix that could used to search a data store for documents encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Note that this will not work for matching values that don't use our key_id_header format, such as cloaked search.
Source code in ironcore_alloy/ironcore_alloy.py
log_security_event(event, metadata, event_time_millis)
async
Log the security event event to the tenant's log sink.
If the event time is unspecified the current time will be used.
Source code in ironcore_alloy/ironcore_alloy.py
rekey_documents(encrypted_documents, metadata, new_tenant_id)
async
Decrypt the provided documents and re-encrypt them using the tenant's current key. If new_tenant_id is None,
the documents will be encrypted to the original tenant.
Source code in ironcore_alloy/ironcore_alloy.py
SaasShieldStandardClient(*args, **kwargs)
Bases: SaasShieldStandardClientProtocol, SaasShieldSecurityEventOpsProtocol, StandardDocumentOpsProtocol
Source code in ironcore_alloy/ironcore_alloy.py
Functions
decrypt(encrypted_document, metadata)
async
Decrypt a document that was encrypted with the provided metadata. The document must have been encrypted with one
of the StandardDocumentOps.encrypt functions. The result contains a map from field identifiers to decrypted
bytes.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_documents, metadata)
async
Decrypt each of the provided documents with the provided metadata. Note that because the metadata is shared between the documents, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. The document must be a map from field identifiers to plaintext
bytes, and the same metadata must be provided when decrypting the document.
A DEK (document encryption key) will be generated and encrypted using a derived key, then each field of the
document will be encrypted separately using a random IV and this single generated DEK.
The result contains a map from field identifiers to encrypted bytes as well as the EDEK (encrypted document
encryption key) used for encryption.
The document is encrypted differently with each call, so the result is not suited for exact matches or indexing.
For the same reason however the strongest protection of the document is provided by this method.
To support these uses, see the DeterministicFieldOps.encrypt function.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_documents, metadata)
async
Encrypt each of the provided documents with the provided metadata. Note that because only a single metadata value is passed, each document will be encrypted to the same tenant.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_with_existing_edek(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. The document must be a map from field identifiers to plaintext
bytes, and the same metadata must be provided when decrypting the document.
The provided EDEK will be decrypted and used to encrypt each field. This is useful when updating some fields
of the document.
The provided EDEK's format will determine the output document format, not the legacy_tsc_write_format setting.
A legacy EDEK will produce legacy document, a non-legacy EDEK will produce a current document. Rekey EDEKs per
TSC_ALLOY_MIGRATION_GUIDE.md if this is undesired.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_with_existing_edek_batch(plaintext_documents, metadata)
async
Encrypt multiple documents with the provided metadata.
The provided EDEKs will be decrypted and used to encrypt each corresponding document's fields.
This is useful when updating some fields of the document.
The provided EDEK's format will determine the output documents format, not the legacy_tsc_write_format setting.
A legacy EDEK will produce legacy document, a non-legacy EDEK will produce a current document. Rekey EDEKs per
TSC_ALLOY_MIGRATION_GUIDE.md if this is undesired.
Source code in ironcore_alloy/ironcore_alloy.py
get_searchable_edek_prefix(id)
Generate a prefix that could be used to search a data store for documents encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Warning: this will never match a SaaS Shield Standard EDEK created legacy_tsc_write_format (or the
legacy TSCs). Upgrade to the V5 data format via the TSC_ALLOY_MIGRATION_GUIDE.md to take advantage of this
functionality.
Source code in ironcore_alloy/ironcore_alloy.py
log_security_event(event, metadata, event_time_millis)
async
Log the security event event to the tenant's log sink.
If the event time is unspecified the current time will be used.
Source code in ironcore_alloy/ironcore_alloy.py
rekey_edeks(edeks, metadata, new_tenant_id)
async
Decrypt the provided EDEKs and re-encrypt them using the tenant's current key. If new_tenant_id is None,
the EDEK will be encrypted to the original tenant. Because the underlying DEK does not change, a document
associated with the old EDEK can be decrypted with the new EDEK without changing its document data.
Source code in ironcore_alloy/ironcore_alloy.py
SaasShieldStandardClientProtocol
Bases: Protocol
Functions
decrypt(encrypted_document, metadata)
async
Decrypt a document that was encrypted with the provided metadata. The document must have been encrypted with one
of the StandardDocumentOps.encrypt functions. The result contains a map from field identifiers to decrypted
bytes.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_documents, metadata)
async
Decrypt each of the provided documents with the provided metadata. Note that because the metadata is shared between the documents, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. The document must be a map from field identifiers to plaintext
bytes, and the same metadata must be provided when decrypting the document.
A DEK (document encryption key) will be generated and encrypted using a derived key, then each field of the
document will be encrypted separately using a random IV and this single generated DEK.
The result contains a map from field identifiers to encrypted bytes as well as the EDEK (encrypted document
encryption key) used for encryption.
The document is encrypted differently with each call, so the result is not suited for exact matches or indexing.
For the same reason however the strongest protection of the document is provided by this method.
To support these uses, see the DeterministicFieldOps.encrypt function.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_documents, metadata)
async
Encrypt each of the provided documents with the provided metadata. Note that because only a single metadata value is passed, each document will be encrypted to the same tenant.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_with_existing_edek(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. The document must be a map from field identifiers to plaintext
bytes, and the same metadata must be provided when decrypting the document.
The provided EDEK will be decrypted and used to encrypt each field. This is useful when updating some fields
of the document.
The provided EDEK's format will determine the output document format, not the legacy_tsc_write_format setting.
A legacy EDEK will produce legacy document, a non-legacy EDEK will produce a current document. Rekey EDEKs per
TSC_ALLOY_MIGRATION_GUIDE.md if this is undesired.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_with_existing_edek_batch(plaintext_documents, metadata)
async
Encrypt multiple documents with the provided metadata.
The provided EDEKs will be decrypted and used to encrypt each corresponding document's fields.
This is useful when updating some fields of the document.
The provided EDEK's format will determine the output documents format, not the legacy_tsc_write_format setting.
A legacy EDEK will produce legacy document, a non-legacy EDEK will produce a current document. Rekey EDEKs per
TSC_ALLOY_MIGRATION_GUIDE.md if this is undesired.
Source code in ironcore_alloy/ironcore_alloy.py
get_searchable_edek_prefix(id)
Generate a prefix that could be used to search a data store for documents encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Warning: this will never match a SaaS Shield Standard EDEK created legacy_tsc_write_format (or the
legacy TSCs). Upgrade to the V5 data format via the TSC_ALLOY_MIGRATION_GUIDE.md to take advantage of this
functionality.
Source code in ironcore_alloy/ironcore_alloy.py
log_security_event(event, metadata, event_time_millis)
async
Log the security event event to the tenant's log sink.
If the event time is unspecified the current time will be used.
Source code in ironcore_alloy/ironcore_alloy.py
rekey_edeks(edeks, metadata, new_tenant_id)
async
Decrypt the provided EDEKs and re-encrypt them using the tenant's current key. If new_tenant_id is None,
the EDEK will be encrypted to the original tenant. Because the underlying DEK does not change, a document
associated with the old EDEK can be decrypted with the new EDEK without changing its document data.
Source code in ironcore_alloy/ironcore_alloy.py
SaasShieldVectorClient(*args, **kwargs)
Bases: SaasShieldVectorClientProtocol, SaasShieldSecurityEventOpsProtocol, VectorOpsProtocol
Source code in ironcore_alloy/ironcore_alloy.py
Functions
decrypt(encrypted_vector, metadata)
async
Decrypt a vector embedding that was encrypted with the provided metadata. The values of the embedding will be unshuffled to their original positions during decryption.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_vectors, metadata)
async
Decrypt multiple vector embeddings that were encrypted with the provided metadata. The values of the embeddings will be unshuffled to their original positions during decryption. Note that because the metadata is shared between the vectors, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_vector, metadata)
async
Encrypt a vector embedding with the provided metadata. The provided embedding is assumed to be normalized and its values will be shuffled as part of the encryption. The same tenant ID must be provided in the metadata when decrypting the embedding.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_vectors, metadata)
async
Encrypt multiple vector embeddings with the provided metadata. The provided embeddings are assumed to be normalized and their values will be shuffled as part of the encryption. The same tenant ID must be provided in the metadata when decrypting the embeddings.
Source code in ironcore_alloy/ironcore_alloy.py
generate_query_vectors(vectors_to_query, metadata)
async
Encrypt each plaintext vector with any Current and InRotation keys for the provided secret path. The resulting encrypted vectors should be used in tandem when querying the vector database.
Source code in ironcore_alloy/ironcore_alloy.py
get_in_rotation_prefix(secret_path, derivation_path, metadata)
async
Get the byte prefix for the InRotation secret corresponding to this secret_path/derivation_path.
Note that if you use z85 or ascii85 encoding, the result of this function should be passed to base85_compat_prefix_bytes
before searching your datastore.
Source code in ironcore_alloy/ironcore_alloy.py
log_security_event(event, metadata, event_time_millis)
async
Log the security event event to the tenant's log sink.
If the event time is unspecified the current time will be used.
Source code in ironcore_alloy/ironcore_alloy.py
rotate_vectors(encrypted_vectors, metadata, new_tenant_id)
async
Source code in ironcore_alloy/ironcore_alloy.py
SaasShieldVectorClientProtocol
Bases: Protocol
Functions
decrypt(encrypted_vector, metadata)
async
Decrypt a vector embedding that was encrypted with the provided metadata. The values of the embedding will be unshuffled to their original positions during decryption.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_vectors, metadata)
async
Decrypt multiple vector embeddings that were encrypted with the provided metadata. The values of the embeddings will be unshuffled to their original positions during decryption. Note that because the metadata is shared between the vectors, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_vector, metadata)
async
Encrypt a vector embedding with the provided metadata. The provided embedding is assumed to be normalized and its values will be shuffled as part of the encryption. The same tenant ID must be provided in the metadata when decrypting the embedding.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_vectors, metadata)
async
Encrypt multiple vector embeddings with the provided metadata. The provided embeddings are assumed to be normalized and their values will be shuffled as part of the encryption. The same tenant ID must be provided in the metadata when decrypting the embeddings.
Source code in ironcore_alloy/ironcore_alloy.py
generate_query_vectors(vectors_to_query, metadata)
async
Encrypt each plaintext vector with any Current and InRotation keys for the provided secret path. The resulting encrypted vectors should be used in tandem when querying the vector database.
Source code in ironcore_alloy/ironcore_alloy.py
get_in_rotation_prefix(secret_path, derivation_path, metadata)
async
Get the byte prefix for the InRotation secret corresponding to this secret_path/derivation_path.
Note that if you use z85 or ascii85 encoding, the result of this function should be passed to base85_compat_prefix_bytes
before searching your datastore.
Source code in ironcore_alloy/ironcore_alloy.py
log_security_event(event, metadata, event_time_millis)
async
Log the security event event to the tenant's log sink.
If the event time is unspecified the current time will be used.
Source code in ironcore_alloy/ironcore_alloy.py
rotate_vectors(encrypted_vectors, metadata, new_tenant_id)
async
Secret(secret)
Bases: SecretProtocol
Source code in ironcore_alloy/ironcore_alloy.py
SecretProtocol
Bases: Protocol
SecurityEvent()
Source code in ironcore_alloy/ironcore_alloy.py
Classes
ADMIN(event)
dataclass
CUSTOM(event)
dataclass
DATA(event)
dataclass
PERIODIC(event)
dataclass
USER(event)
dataclass
Functions
is_ADMIN()
is_CUSTOM()
is_DATA()
is_PERIODIC()
is_USER()
is_admin()
is_custom()
is_data()
is_periodic()
SecurityEventError
Bases: Enum
Errors related to security events
Attributes
SECURITY_EVENT_REJECTED = 0
class-attribute
instance-attribute
ServiceError
Bases: Enum
Errors communicating with the TSP
Attributes
INVALID_REQUEST_BODY = 2
class-attribute
instance-attribute
UNAUTHORIZED_REQUEST = 1
class-attribute
instance-attribute
UNKNOWN_ERROR = 0
class-attribute
instance-attribute
Standalone(config)
Bases: StandaloneProtocol
Source code in ironcore_alloy/ironcore_alloy.py
Functions
deterministic()
Source code in ironcore_alloy/ironcore_alloy.py
standard()
Source code in ironcore_alloy/ironcore_alloy.py
standard_attached()
Source code in ironcore_alloy/ironcore_alloy.py
vector()
Source code in ironcore_alloy/ironcore_alloy.py
StandaloneConfiguration(standard, deterministic, vector)
Bases: StandaloneConfigurationProtocol
Configuration for the standalone SDKs. Sets secrets and secret paths for the different SDK operations. If usage of only one set of SDK operations is desired the others can be left as empty objects, and will error if called in that state. If you want to share a secret between multiple SDK modes, you'll need to create secrets in each mode that share the same secret bytes.
Source code in ironcore_alloy/ironcore_alloy.py
Functions
new_seeded_for_testing(standard, deterministic, vector, test_rng_seed)
classmethod
Source code in ironcore_alloy/ironcore_alloy.py
StandaloneConfigurationProtocol
Bases: Protocol
Configuration for the standalone SDKs. Sets secrets and secret paths for the different SDK operations. If usage of only one set of SDK operations is desired the others can be left as empty objects, and will error if called in that state. If you want to share a secret between multiple SDK modes, you'll need to create secrets in each mode that share the same secret bytes.
StandaloneDeterministicClient(*args, **kwargs)
Bases: StandaloneDeterministicClientProtocol, DeterministicFieldOpsProtocol
Source code in ironcore_alloy/ironcore_alloy.py
Functions
decrypt(encrypted_field, metadata)
async
Decrypt a field that was deterministically encrypted with the provided metadata.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_fields, metadata)
async
Decrypt each of the fields that were deterministically encrypted with the provided metadata. Note that because the metadata is shared between the fields, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_field, metadata)
async
Encrypt a field with the provided metadata.
Because the field is encrypted deterministically with each call, the result will be the same for repeated calls.
This allows for exact matches and indexing of the encrypted field, but comes with some security considerations.
If you don't need to support these use cases, we recommend using standard encryption instead.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_fields, metadata)
async
Deterministically encrypt the provided fields with the provided metadata.
Because the fields are encrypted deterministically with each call, the result will be the same for repeated calls.
This allows for exact matches and indexing of the encrypted field, but comes with some security considerations.
If you don't need to support these use cases, we recommend using standard encryption instead.
Source code in ironcore_alloy/ironcore_alloy.py
generate_query_field_values(fields_to_query, metadata)
async
Encrypt each plaintext field with any Current and InRotation keys for the provided secret path. The resulting encrypted fields should be used in tandem when querying the data store.
Source code in ironcore_alloy/ironcore_alloy.py
get_in_rotation_prefix(secret_path, derivation_path, metadata)
async
Generate a prefix that could used to search a data store for fields encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Source code in ironcore_alloy/ironcore_alloy.py
rotate_fields(encrypted_fields, metadata, new_tenant_id)
async
Re-encrypt already encrypted fields with the Current key for the provided tenant. The metadata passed
must contain the tenant ID that the fields were originally encrypted to. If new_tenant_id is empty,
the fields will simply be encrypted with the same tenant's current secret.
Source code in ironcore_alloy/ironcore_alloy.py
StandaloneDeterministicClientProtocol
Bases: Protocol
Functions
decrypt(encrypted_field, metadata)
async
Decrypt a field that was deterministically encrypted with the provided metadata.
decrypt_batch(encrypted_fields, metadata)
async
Decrypt each of the fields that were deterministically encrypted with the provided metadata. Note that because the metadata is shared between the fields, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_field, metadata)
async
Encrypt a field with the provided metadata.
Because the field is encrypted deterministically with each call, the result will be the same for repeated calls.
This allows for exact matches and indexing of the encrypted field, but comes with some security considerations.
If you don't need to support these use cases, we recommend using standard encryption instead.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_fields, metadata)
async
Deterministically encrypt the provided fields with the provided metadata.
Because the fields are encrypted deterministically with each call, the result will be the same for repeated calls.
This allows for exact matches and indexing of the encrypted field, but comes with some security considerations.
If you don't need to support these use cases, we recommend using standard encryption instead.
Source code in ironcore_alloy/ironcore_alloy.py
generate_query_field_values(fields_to_query, metadata)
async
Encrypt each plaintext field with any Current and InRotation keys for the provided secret path. The resulting encrypted fields should be used in tandem when querying the data store.
Source code in ironcore_alloy/ironcore_alloy.py
get_in_rotation_prefix(secret_path, derivation_path, metadata)
async
Generate a prefix that could used to search a data store for fields encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Source code in ironcore_alloy/ironcore_alloy.py
rotate_fields(encrypted_fields, metadata, new_tenant_id)
async
Re-encrypt already encrypted fields with the Current key for the provided tenant. The metadata passed
must contain the tenant ID that the fields were originally encrypted to. If new_tenant_id is empty,
the fields will simply be encrypted with the same tenant's current secret.
Source code in ironcore_alloy/ironcore_alloy.py
StandaloneProtocol
Bases: Protocol
Functions
deterministic()
standard()
standard_attached()
StandaloneSecret(id, secret)
Bases: StandaloneSecretProtocol
A secret used by standalone mode to derive encryption keys.
Create a standalone secret. The secret needs to be cryptographically random bytes.
Source code in ironcore_alloy/ironcore_alloy.py
StandaloneSecretProtocol
Bases: Protocol
A secret used by standalone mode to derive encryption keys.
StandaloneStandardAttachedClient(*args, **kwargs)
Bases: StandaloneStandardAttachedClientProtocol, StandardAttachedDocumentOpsProtocol
Source code in ironcore_alloy/ironcore_alloy.py
Functions
decrypt(encrypted_document, metadata)
async
Decrypt a document that was encrypted with the provided metadata. The document must have been encrypted using attached encryption and not deterministic or standard encryption.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_documents, metadata)
async
Decrypt multiple documents that were encrypted with the provided metadata. The documents must have been encrypted using attached encryption and not deterministic or standard encryption.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. A DEK (document encryption key) will be generated and encrypted using a derived key. The result is a single blob of bytes with the edek put on the front of it.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_documents, metadata)
async
Encrypt multiple documents with the provided metadata. A DEK (document encryption key) will be generated for each document and encrypted using a derived key.
Source code in ironcore_alloy/ironcore_alloy.py
get_searchable_edek_prefix(id)
Generate a prefix that could used to search a data store for documents encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Note that this will not work for matching values that don't use our key_id_header format, such as cloaked search.
Source code in ironcore_alloy/ironcore_alloy.py
rekey_documents(encrypted_documents, metadata, new_tenant_id)
async
Decrypt the provided documents and re-encrypt them using the tenant's current key. If new_tenant_id is None,
the documents will be encrypted to the original tenant.
Source code in ironcore_alloy/ironcore_alloy.py
StandaloneStandardAttachedClientProtocol
Bases: Protocol
Functions
decrypt(encrypted_document, metadata)
async
Decrypt a document that was encrypted with the provided metadata. The document must have been encrypted using attached encryption and not deterministic or standard encryption.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_documents, metadata)
async
Decrypt multiple documents that were encrypted with the provided metadata. The documents must have been encrypted using attached encryption and not deterministic or standard encryption.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. A DEK (document encryption key) will be generated and encrypted using a derived key. The result is a single blob of bytes with the edek put on the front of it.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_documents, metadata)
async
Encrypt multiple documents with the provided metadata. A DEK (document encryption key) will be generated for each document and encrypted using a derived key.
Source code in ironcore_alloy/ironcore_alloy.py
get_searchable_edek_prefix(id)
Generate a prefix that could used to search a data store for documents encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Note that this will not work for matching values that don't use our key_id_header format, such as cloaked search.
Source code in ironcore_alloy/ironcore_alloy.py
rekey_documents(encrypted_documents, metadata, new_tenant_id)
async
Decrypt the provided documents and re-encrypt them using the tenant's current key. If new_tenant_id is None,
the documents will be encrypted to the original tenant.
Source code in ironcore_alloy/ironcore_alloy.py
StandaloneStandardClient(*args, **kwargs)
Bases: StandaloneStandardClientProtocol, StandardDocumentOpsProtocol
Source code in ironcore_alloy/ironcore_alloy.py
Functions
decrypt(encrypted_document, metadata)
async
Decrypt a document that was encrypted with the provided metadata. The document must have been encrypted with one
of the StandardDocumentOps.encrypt functions. The result contains a map from field identifiers to decrypted
bytes.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_documents, metadata)
async
Decrypt each of the provided documents with the provided metadata. Note that because the metadata is shared between the documents, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. The document must be a map from field identifiers to plaintext
bytes, and the same metadata must be provided when decrypting the document.
A DEK (document encryption key) will be generated and encrypted using a derived key, then each field of the
document will be encrypted separately using a random IV and this single generated DEK.
The result contains a map from field identifiers to encrypted bytes as well as the EDEK (encrypted document
encryption key) used for encryption.
The document is encrypted differently with each call, so the result is not suited for exact matches or indexing.
For the same reason however the strongest protection of the document is provided by this method.
To support these uses, see the DeterministicFieldOps.encrypt function.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_documents, metadata)
async
Encrypt each of the provided documents with the provided metadata. Note that because only a single metadata value is passed, each document will be encrypted to the same tenant.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_with_existing_edek(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. The document must be a map from field identifiers to plaintext bytes, and the same metadata must be provided when decrypting the document. The provided EDEK will be decrypted and used to encrypt each field. This is useful when updating some fields of the document.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_with_existing_edek_batch(plaintext_documents, metadata)
async
Encrypt multiple documents with the provided metadata. The provided EDEKs will be decrypted and used to encrypt each corresponding document's fields. This is useful when updating some fields of the document.
Source code in ironcore_alloy/ironcore_alloy.py
get_searchable_edek_prefix(id)
Generate a prefix that could used to search a data store for documents encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Source code in ironcore_alloy/ironcore_alloy.py
rekey_edeks(edeks, metadata, new_tenant_id)
async
Decrypt the provided EDEKs and re-encrypt them using the tenant's current key. If new_tenant_id is None,
the EDEK will be encrypted to the original tenant. Because the underlying DEK does not change, a document
associated with the old EDEK can be decrypted with the new EDEK without changing its document data.
Source code in ironcore_alloy/ironcore_alloy.py
StandaloneStandardClientProtocol
Bases: Protocol
Functions
decrypt(encrypted_document, metadata)
async
Decrypt a document that was encrypted with the provided metadata. The document must have been encrypted with one
of the StandardDocumentOps.encrypt functions. The result contains a map from field identifiers to decrypted
bytes.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_documents, metadata)
async
Decrypt each of the provided documents with the provided metadata. Note that because the metadata is shared between the documents, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. The document must be a map from field identifiers to plaintext
bytes, and the same metadata must be provided when decrypting the document.
A DEK (document encryption key) will be generated and encrypted using a derived key, then each field of the
document will be encrypted separately using a random IV and this single generated DEK.
The result contains a map from field identifiers to encrypted bytes as well as the EDEK (encrypted document
encryption key) used for encryption.
The document is encrypted differently with each call, so the result is not suited for exact matches or indexing.
For the same reason however the strongest protection of the document is provided by this method.
To support these uses, see the DeterministicFieldOps.encrypt function.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_documents, metadata)
async
Encrypt each of the provided documents with the provided metadata. Note that because only a single metadata value is passed, each document will be encrypted to the same tenant.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_with_existing_edek(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. The document must be a map from field identifiers to plaintext bytes, and the same metadata must be provided when decrypting the document. The provided EDEK will be decrypted and used to encrypt each field. This is useful when updating some fields of the document.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_with_existing_edek_batch(plaintext_documents, metadata)
async
Encrypt multiple documents with the provided metadata. The provided EDEKs will be decrypted and used to encrypt each corresponding document's fields. This is useful when updating some fields of the document.
Source code in ironcore_alloy/ironcore_alloy.py
get_searchable_edek_prefix(id)
Generate a prefix that could used to search a data store for documents encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Source code in ironcore_alloy/ironcore_alloy.py
rekey_edeks(edeks, metadata, new_tenant_id)
async
Decrypt the provided EDEKs and re-encrypt them using the tenant's current key. If new_tenant_id is None,
the EDEK will be encrypted to the original tenant. Because the underlying DEK does not change, a document
associated with the old EDEK can be decrypted with the new EDEK without changing its document data.
Source code in ironcore_alloy/ironcore_alloy.py
StandaloneVectorClient(*args, **kwargs)
Bases: StandaloneVectorClientProtocol, VectorOpsProtocol
Source code in ironcore_alloy/ironcore_alloy.py
Functions
decrypt(encrypted_vector, metadata)
async
Decrypt a vector embedding that was encrypted with the provided metadata. The values of the embedding will be unshuffled to their original positions during decryption.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_vectors, metadata)
async
Decrypt multiple vector embeddings that were encrypted with the provided metadata. The values of the embeddings will be unshuffled to their original positions during decryption. Note that because the metadata is shared between the vectors, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_vector, metadata)
async
Encrypt a vector embedding with the provided metadata. The provided embedding is assumed to be normalized and its values will be shuffled as part of the encryption. The same tenant ID must be provided in the metadata when decrypting the embedding.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_vectors, metadata)
async
Encrypt multiple vector embeddings with the provided metadata. The provided embeddings are assumed to be normalized and their values will be shuffled as part of the encryption. The same tenant ID must be provided in the metadata when decrypting the embeddings.
Source code in ironcore_alloy/ironcore_alloy.py
generate_query_vectors(vectors_to_query, metadata)
async
Encrypt each plaintext vector with any Current and InRotation keys for the provided secret path. The resulting encrypted vectors should be used in tandem when querying the vector database.
Source code in ironcore_alloy/ironcore_alloy.py
get_in_rotation_prefix(secret_path, derivation_path, metadata)
async
Get the byte prefix for the InRotation secret corresponding to this secret_path.
Note that if you use z85 or ascii85 encoding, the result of this function should be passed to base85_compat_prefix_bytes
before searching your datastore.
Note: The derivation_path and metadata are not actually required for this function and can be passed any value.
Source code in ironcore_alloy/ironcore_alloy.py
rotate_vectors(encrypted_vectors, metadata, new_tenant_id)
async
Rotates vectors from the in-rotation secret for their secret path to the current secret. This can also be used to rotate data from one tenant ID to a new one, which most useful when a tenant is internally migrated.
WARNINGS:
* this involves decrypting then encrypting vectors. Since the vectors are full of floating point numbers,
this process is lossy, which will cause some drift over time. If you need perfectly preserved accuracy
store the source vector encrypted with standard next to the encrypted vector. standard decrypt
that, vector encrypt it again, and replace the encrypted vector with the result.
* only one metadata and new tenant ID argument means each call to this needs to have one tenant's vectors.
Source code in ironcore_alloy/ironcore_alloy.py
StandaloneVectorClientProtocol
Bases: Protocol
Functions
decrypt(encrypted_vector, metadata)
async
Decrypt a vector embedding that was encrypted with the provided metadata. The values of the embedding will be unshuffled to their original positions during decryption.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_vectors, metadata)
async
Decrypt multiple vector embeddings that were encrypted with the provided metadata. The values of the embeddings will be unshuffled to their original positions during decryption. Note that because the metadata is shared between the vectors, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_vector, metadata)
async
Encrypt a vector embedding with the provided metadata. The provided embedding is assumed to be normalized and its values will be shuffled as part of the encryption. The same tenant ID must be provided in the metadata when decrypting the embedding.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_vectors, metadata)
async
Encrypt multiple vector embeddings with the provided metadata. The provided embeddings are assumed to be normalized and their values will be shuffled as part of the encryption. The same tenant ID must be provided in the metadata when decrypting the embeddings.
Source code in ironcore_alloy/ironcore_alloy.py
generate_query_vectors(vectors_to_query, metadata)
async
Encrypt each plaintext vector with any Current and InRotation keys for the provided secret path. The resulting encrypted vectors should be used in tandem when querying the vector database.
Source code in ironcore_alloy/ironcore_alloy.py
get_in_rotation_prefix(secret_path, derivation_path, metadata)
async
Get the byte prefix for the InRotation secret corresponding to this secret_path.
Note that if you use z85 or ascii85 encoding, the result of this function should be passed to base85_compat_prefix_bytes
before searching your datastore.
Note: The derivation_path and metadata are not actually required for this function and can be passed any value.
Source code in ironcore_alloy/ironcore_alloy.py
rotate_vectors(encrypted_vectors, metadata, new_tenant_id)
async
Rotates vectors from the in-rotation secret for their secret path to the current secret. This can also be used to rotate data from one tenant ID to a new one, which most useful when a tenant is internally migrated.
WARNINGS:
* this involves decrypting then encrypting vectors. Since the vectors are full of floating point numbers,
this process is lossy, which will cause some drift over time. If you need perfectly preserved accuracy
store the source vector encrypted with standard next to the encrypted vector. standard decrypt
that, vector encrypt it again, and replace the encrypted vector with the result.
* only one metadata and new tenant ID argument means each call to this needs to have one tenant's vectors.
Source code in ironcore_alloy/ironcore_alloy.py
StandardAttachedDecryptBatchResult(*, successes, failures)
dataclass
Source code in ironcore_alloy/ironcore_alloy.py
Attributes
failures = failures
instance-attribute
successes = successes
instance-attribute
StandardAttachedDocumentOps(*args, **kwargs)
Bases: StandardAttachedDocumentOpsProtocol
API for encrypting and decrypting documents using our standard encryption.
Source code in ironcore_alloy/ironcore_alloy.py
Functions
decrypt(attached_document, metadata)
async
Decrypt a document that was encrypted with the provided metadata. The document must have been encrypted using attached encryption and not deterministic or standard encryption.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_documents, metadata)
async
Decrypt multiple documents that were encrypted with the provided metadata. The documents must have been encrypted using attached encryption and not deterministic or standard encryption.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. A DEK (document encryption key) will be generated and encrypted using a derived key. The result is a single blob of bytes with the edek put on the front of it.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_documents, metadata)
async
Encrypt multiple documents with the provided metadata. A DEK (document encryption key) will be generated for each document and encrypted using a derived key.
Source code in ironcore_alloy/ironcore_alloy.py
get_searchable_edek_prefix(id)
Generate a prefix that could used to search a data store for documents encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Note that this will not work for matching values that don't use our key_id_header format, such as Cloaked Search
or legacy TSC data.
Source code in ironcore_alloy/ironcore_alloy.py
rekey_documents(encrypted_documents, metadata, new_tenant_id)
async
Decrypt the provided documents and re-encrypt them using the tenant's current key. If new_tenant_id is None,
the documents will be encrypted to the original tenant.
Source code in ironcore_alloy/ironcore_alloy.py
StandardAttachedDocumentOpsProtocol
Bases: Protocol
API for encrypting and decrypting documents using our standard encryption.
Functions
decrypt(attached_document, metadata)
async
Decrypt a document that was encrypted with the provided metadata. The document must have been encrypted using attached encryption and not deterministic or standard encryption.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_documents, metadata)
async
Decrypt multiple documents that were encrypted with the provided metadata. The documents must have been encrypted using attached encryption and not deterministic or standard encryption.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. A DEK (document encryption key) will be generated and encrypted using a derived key. The result is a single blob of bytes with the edek put on the front of it.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_documents, metadata)
async
Encrypt multiple documents with the provided metadata. A DEK (document encryption key) will be generated for each document and encrypted using a derived key.
Source code in ironcore_alloy/ironcore_alloy.py
get_searchable_edek_prefix(id)
Generate a prefix that could used to search a data store for documents encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Note that this will not work for matching values that don't use our key_id_header format, such as Cloaked Search
or legacy TSC data.
Source code in ironcore_alloy/ironcore_alloy.py
rekey_documents(encrypted_documents, metadata, new_tenant_id)
async
Decrypt the provided documents and re-encrypt them using the tenant's current key. If new_tenant_id is None,
the documents will be encrypted to the original tenant.
Source code in ironcore_alloy/ironcore_alloy.py
StandardAttachedEncryptBatchResult(*, successes, failures)
dataclass
Source code in ironcore_alloy/ironcore_alloy.py
Attributes
failures = failures
instance-attribute
successes = successes
instance-attribute
StandardDecryptBatchResult(*, successes, failures)
dataclass
StandardDocumentOps(*args, **kwargs)
Bases: StandardDocumentOpsProtocol
API for encrypting and decrypting documents using our standard encryption. This class of encryption is the most broadly useful and secure. If you don't have a need to match on or preserve the distance properties of the encrypted value, this is likely the API you should use. Our standard encryption is fully random (or probabilistic) AES 256.
Source code in ironcore_alloy/ironcore_alloy.py
Functions
decrypt(encrypted_document, metadata)
async
Decrypt a document that was encrypted with the provided metadata. The document must have been encrypted with one
of the StandardDocumentOps.encrypt functions. The result contains a map from field identifiers to decrypted
bytes.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_documents, metadata)
async
Decrypt each of the provided documents with the provided metadata. Note that because the metadata is shared between the documents, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. The document must be a map from field identifiers to plaintext
bytes, and the same metadata must be provided when decrypting the document.
A DEK (document encryption key) will be generated and encrypted using a derived key, then each field of the
document will be encrypted separately using a random IV and this single generated DEK.
The result contains a map from field identifiers to encrypted bytes as well as the EDEK (encrypted document
encryption key) used for encryption.
The document is encrypted differently with each call, so the result is not suited for exact matches or indexing.
For the same reason however the strongest protection of the document is provided by this method.
To support these uses, see the DeterministicFieldOps.encrypt function.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_documents, metadata)
async
Encrypt each of the provided documents with the provided metadata. Note that because only a single metadata value is passed, each document will be encrypted to the same tenant.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_with_existing_edek(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. The document must be a map from field identifiers to plaintext bytes, and the same metadata must be provided when decrypting the document. The provided EDEK will be decrypted and used to encrypt each field. This is useful when updating some fields of the document.
Note: this method matches the field format to the provided EDEK's format, ignoring the
legacy_tsc_write_format setting. A V3 EDEK produces V3 fields, a V5 EDEK produces V5 fields.
To upgrade a document from V3 to V5, first rekey the EDEK via rekey_edeks.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_with_existing_edek_batch(plaintext_documents, metadata)
async
Encrypt multiple documents with the provided metadata. The provided EDEKs will be decrypted and used to encrypt each corresponding document's fields. This is useful when updating some fields of the document.
Source code in ironcore_alloy/ironcore_alloy.py
get_searchable_edek_prefix(id)
Generate a prefix that could used to search a data store for documents encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Source code in ironcore_alloy/ironcore_alloy.py
rekey_edeks(edeks, metadata, new_tenant_id)
async
Decrypt the provided EDEKs and re-encrypt them using the tenant's current key. If new_tenant_id is None,
the EDEK will be encrypted to the original tenant. Because the underlying DEK does not change, a document
associated with the old EDEK can be decrypted with the new EDEK without changing its document data.
Source code in ironcore_alloy/ironcore_alloy.py
StandardDocumentOpsProtocol
Bases: Protocol
API for encrypting and decrypting documents using our standard encryption. This class of encryption is the most broadly useful and secure. If you don't have a need to match on or preserve the distance properties of the encrypted value, this is likely the API you should use. Our standard encryption is fully random (or probabilistic) AES 256.
Functions
decrypt(encrypted_document, metadata)
async
Decrypt a document that was encrypted with the provided metadata. The document must have been encrypted with one
of the StandardDocumentOps.encrypt functions. The result contains a map from field identifiers to decrypted
bytes.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_documents, metadata)
async
Decrypt each of the provided documents with the provided metadata. Note that because the metadata is shared between the documents, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. The document must be a map from field identifiers to plaintext
bytes, and the same metadata must be provided when decrypting the document.
A DEK (document encryption key) will be generated and encrypted using a derived key, then each field of the
document will be encrypted separately using a random IV and this single generated DEK.
The result contains a map from field identifiers to encrypted bytes as well as the EDEK (encrypted document
encryption key) used for encryption.
The document is encrypted differently with each call, so the result is not suited for exact matches or indexing.
For the same reason however the strongest protection of the document is provided by this method.
To support these uses, see the DeterministicFieldOps.encrypt function.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_documents, metadata)
async
Encrypt each of the provided documents with the provided metadata. Note that because only a single metadata value is passed, each document will be encrypted to the same tenant.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_with_existing_edek(plaintext_document, metadata)
async
Encrypt a document with the provided metadata. The document must be a map from field identifiers to plaintext bytes, and the same metadata must be provided when decrypting the document. The provided EDEK will be decrypted and used to encrypt each field. This is useful when updating some fields of the document.
Note: this method matches the field format to the provided EDEK's format, ignoring the
legacy_tsc_write_format setting. A V3 EDEK produces V3 fields, a V5 EDEK produces V5 fields.
To upgrade a document from V3 to V5, first rekey the EDEK via rekey_edeks.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_with_existing_edek_batch(plaintext_documents, metadata)
async
Encrypt multiple documents with the provided metadata. The provided EDEKs will be decrypted and used to encrypt each corresponding document's fields. This is useful when updating some fields of the document.
Source code in ironcore_alloy/ironcore_alloy.py
get_searchable_edek_prefix(id)
Generate a prefix that could used to search a data store for documents encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Source code in ironcore_alloy/ironcore_alloy.py
rekey_edeks(edeks, metadata, new_tenant_id)
async
Decrypt the provided EDEKs and re-encrypt them using the tenant's current key. If new_tenant_id is None,
the EDEK will be encrypted to the original tenant. Because the underlying DEK does not change, a document
associated with the old EDEK can be decrypted with the new EDEK without changing its document data.
Source code in ironcore_alloy/ironcore_alloy.py
StandardEncryptBatchResult(*, successes, failures)
dataclass
StandardSecrets(primary_secret_id, secrets)
Bases: StandardSecretsProtocol
A collection of secrets for standalone standard mode used to derive encryption keys. The primary secret id is used to look up the primary secret, which will be used for encrypting new documents. The rest of the secrets will only be used to decrypt existing documents when encountered.
Create a collection of standard secrets. This will error if secret ids aren't unique or the primary secret id isn't in the secrets list.
Source code in ironcore_alloy/ironcore_alloy.py
StandardSecretsProtocol
Bases: Protocol
A collection of secrets for standalone standard mode used to derive encryption keys. The primary secret id is used to look up the primary secret, which will be used for encrypting new documents. The rest of the secrets will only be used to decrypt existing documents when encountered.
TenantSecretError
Bases: Enum
Errors related to tenant secrets
Attributes
SECRET_CREATION_FAILED = 0
class-attribute
instance-attribute
TenantSecurityProxyError()
Errors originating from the Tenant Security Proxy. These errors are broken into 4 types: service errors, KMS errors, security event errors, and tenant secret errors.
Source code in ironcore_alloy/ironcore_alloy.py
Classes
KMS(error)
dataclass
SECURITY_EVENT(error)
dataclass
SERVICE(error)
dataclass
TENANT_SECRET(error)
dataclass
Functions
is_KMS()
is_SECURITY_EVENT()
is_SERVICE()
is_TENANT_SECRET()
is_kms()
is_security_event()
is_service()
UserEvent
Bases: Enum
Attributes
ADD = 0
class-attribute
instance-attribute
CHANGE_EMAIL = 14
class-attribute
instance-attribute
CHANGE_PASSWORD = 10
class-attribute
instance-attribute
CHANGE_PERMISSIONS = 7
class-attribute
instance-attribute
DISABLE_TWO_FACTOR = 13
class-attribute
instance-attribute
ENABLE_TWO_FACTOR = 12
class-attribute
instance-attribute
EXPIRE_PASSWORD = 8
class-attribute
instance-attribute
LOCKOUT = 5
class-attribute
instance-attribute
LOGIN = 3
class-attribute
instance-attribute
LOGOUT = 6
class-attribute
instance-attribute
REJECT_LOGIN = 11
class-attribute
instance-attribute
REMOVE = 2
class-attribute
instance-attribute
REQUEST_EMAIL_VERIFICATION = 15
class-attribute
instance-attribute
RESET_PASSWORD = 9
class-attribute
instance-attribute
SUSPEND = 1
class-attribute
instance-attribute
TIMEOUT_SESSION = 4
class-attribute
instance-attribute
VERIFY_EMAIL = 16
class-attribute
instance-attribute
VectorDecryptBatchResult(*, successes, failures)
dataclass
VectorEncryptBatchResult(*, successes, failures)
dataclass
VectorOps(*args, **kwargs)
Bases: VectorOpsProtocol
Source code in ironcore_alloy/ironcore_alloy.py
Functions
decrypt(encrypted_vector, metadata)
async
Decrypt a vector embedding that was encrypted with the provided metadata. The values of the embedding will be unshuffled to their original positions during decryption.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_vectors, metadata)
async
Decrypt multiple vector embeddings that were encrypted with the provided metadata. The values of the embeddings will be unshuffled to their original positions during decryption. Note that because the metadata is shared between the vectors, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_vector, metadata)
async
Encrypt a vector embedding with the provided metadata. The provided embedding is assumed to be normalized and its values will be shuffled as part of the encryption. The same tenant ID must be provided in the metadata when decrypting the embedding.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_vectors, metadata)
async
Encrypt multiple vector embeddings with the provided metadata. The provided embeddings are assumed to be normalized and their values will be shuffled as part of the encryption. The same tenant ID must be provided in the metadata when decrypting the embeddings.
Source code in ironcore_alloy/ironcore_alloy.py
generate_query_vectors(vectors_to_query, metadata)
async
Encrypt each plaintext vector with any Current and InRotation keys for the provided secret path. The resulting encrypted vectors should be used in tandem when querying the vector database.
Source code in ironcore_alloy/ironcore_alloy.py
get_in_rotation_prefix(secret_path, derivation_path, metadata)
async
Generate a prefix that could used to search a data store for documents encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Source code in ironcore_alloy/ironcore_alloy.py
rotate_vectors(encrypted_vectors, metadata, new_tenant_id)
async
Rotates vectors from the in-rotation secret for their secret path to the current secret. This can also be used to rotate data from one tenant ID to a new one, which most useful when a tenant is internally migrated.
WARNINGS:
* this involves decrypting then encrypting vectors. Since the vectors are full of floating point numbers,
this process is lossy, which will cause some drift over time. If you need perfectly preserved accuracy,
store the source vector encrypted with standard next to the encrypted vector. standard decrypt
that, vector encrypt it again, and replace the encrypted vector with the result.
* only one metadata and new tenant ID argument means each call to this needs to have one tenant's vectors.
Source code in ironcore_alloy/ironcore_alloy.py
VectorOpsProtocol
Bases: Protocol
Functions
decrypt(encrypted_vector, metadata)
async
Decrypt a vector embedding that was encrypted with the provided metadata. The values of the embedding will be unshuffled to their original positions during decryption.
Source code in ironcore_alloy/ironcore_alloy.py
decrypt_batch(encrypted_vectors, metadata)
async
Decrypt multiple vector embeddings that were encrypted with the provided metadata. The values of the embeddings will be unshuffled to their original positions during decryption. Note that because the metadata is shared between the vectors, they all must correspond to the same tenant ID.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt(plaintext_vector, metadata)
async
Encrypt a vector embedding with the provided metadata. The provided embedding is assumed to be normalized and its values will be shuffled as part of the encryption. The same tenant ID must be provided in the metadata when decrypting the embedding.
Source code in ironcore_alloy/ironcore_alloy.py
encrypt_batch(plaintext_vectors, metadata)
async
Encrypt multiple vector embeddings with the provided metadata. The provided embeddings are assumed to be normalized and their values will be shuffled as part of the encryption. The same tenant ID must be provided in the metadata when decrypting the embeddings.
Source code in ironcore_alloy/ironcore_alloy.py
generate_query_vectors(vectors_to_query, metadata)
async
Encrypt each plaintext vector with any Current and InRotation keys for the provided secret path. The resulting encrypted vectors should be used in tandem when querying the vector database.
Source code in ironcore_alloy/ironcore_alloy.py
get_in_rotation_prefix(secret_path, derivation_path, metadata)
async
Generate a prefix that could used to search a data store for documents encrypted using an identifier (KMS
config id for SaaS Shield, secret id for Standalone). These bytes should be encoded into
a format matching the encoding in the data store. z85/ascii85 users should first pass these bytes through
encode_prefix_z85 or base85_prefix_padding. Make sure you've read the documentation of those functions to
avoid pitfalls when encoding across byte boundaries.
Source code in ironcore_alloy/ironcore_alloy.py
rotate_vectors(encrypted_vectors, metadata, new_tenant_id)
async
Rotates vectors from the in-rotation secret for their secret path to the current secret. This can also be used to rotate data from one tenant ID to a new one, which most useful when a tenant is internally migrated.
WARNINGS:
* this involves decrypting then encrypting vectors. Since the vectors are full of floating point numbers,
this process is lossy, which will cause some drift over time. If you need perfectly preserved accuracy,
store the source vector encrypted with standard next to the encrypted vector. standard decrypt
that, vector encrypt it again, and replace the encrypted vector with the result.
* only one metadata and new tenant ID argument means each call to this needs to have one tenant's vectors.
Source code in ironcore_alloy/ironcore_alloy.py
VectorRotateResult(*, successes, failures)
dataclass
Source code in ironcore_alloy/ironcore_alloy.py
Attributes
failures = failures
instance-attribute
successes = successes
instance-attribute
VectorSecret(approximation_factor, secret)
Bases: VectorSecretProtocol
The approximation factor should be chosen in a way that balances security with search performance.
A higher approximation factor is more secure, but introduces more variance into encrypted embeddings,
possibly leading to degraded performance. A lower bound for the approximation factor to start with is sqrt(M),
where M is the absolute value of the largest data point in the input embeddings.
Source code in ironcore_alloy/ironcore_alloy.py
Functions
new_with_scaling_factor(approximation_factor, secret)
classmethod
Source code in ironcore_alloy/ironcore_alloy.py
VectorSecretProtocol
Bases: Protocol