xtrace_sdk.x_vec.crypto.goldwasser_micali_client¶
Classes¶
Goldwasser-Micali homomorphic encryption client optimised for computing |
Module Contents¶
- class xtrace_sdk.x_vec.crypto.goldwasser_micali_client.GoldwasserMicaliClient(chunk_num=2, embd_len=512, key_len=1024)¶
Goldwasser-Micali homomorphic encryption client optimised for computing encrypted Hamming distances between binary embedding vectors.
- keys¶
- embd_len = 512¶
- chunk_num = 2¶
- chunk_len = 512¶
- serial_pk()¶
Serialize the public key to a JSON string for networking or storage.
- Returns:
JSON-encoded public key.
- Return type:
- serial_sk()¶
Serialize the secret key to a JSON string for networking or storage.
- Returns:
JSON-encoded secret key.
- Return type:
- dump_pk(file_path)¶
Save the public key to disk using pickle.
- Parameters:
file_path (str) – Destination file path.
- Return type:
None
- dump_sk(file_path)¶
Save the secret key to disk using pickle.
- Parameters:
file_path (str) – Destination file path.
- Return type:
None
- id2power(id_)¶
Return the chunk index and bit position for a given embedding entry index.
- encrypt(embd)¶
Encrypt a binary embedding vector using the Goldwasser-Micali scheme.