A client application for performing encrypted vector search using homomorphic encryption.
Project description
What is ES2?
ES2 (Encrypted Similarity Search) is a high-performance encrypted vector search engine designed to protect data privacy during similarity search. It enables users to search over encrypted vectors without ever exposing the raw data or query.
By leveraging advanced encryption techniques such as homomorphic encryption and secure computation, ES2 ensures that both the vector data and similarity scores remain confidential — even during computation.
ES2 is provided as a Python client package. For more details, visit https://heaan.com/.
ES2 Example
This example demonstrates the complete workflow of the ES2 Self-Hosted Python SDK, showcasing its capabilities for encrypted similarity search and vector database operations.
Import ES2
At the very first time, you should install and import the es2 package to use Python APIs.
pip install es2
import es2
🔍 Vector Search
1. Initialize ES2
To use the ES2 service, initialization is required. This includes establishing a connection to the ES2 server and configuring settings necessary for vector search.
es2.init(
host="localhost",
port=50050,
key_path="./keys",
key_id="quickstart_key",
)
2. Create Index
You need to create an index before inserting data. The index is defined by its name and vector dimensionality.
index = es2.create_index("quickstart_index", dim=512)
3. Insert Data
You can insert random or real vectors into the created index. Below is an example using random 512-dimensional vectors with normalization and metadata.
import numpy as np
# Function to generate normalized random vectors
def generate_random_vector(dim):
if dim <= 16 or dim > 4096:
raise ValueError(f"Invalid dimension: {dim}.")
vec = np.random.uniform(-1.0, 1.0, dim)
norm = np.linalg.norm(vec)
if norm > 0:
vec = vec / norm
return vec
# Prepare sample data
num_data = 10
db_vectors = [generate_random_vector(512) for _ in range(num_data)]
db_metadata = [f"data_{i+1}" for i in range(num_data)]
# Insert into index
index.insert(db_vectors, metadata=db_metadata)
4. Encrypted Similarity Search
Use a query vector to find similar vectors. The index object enables encrypted search and decryption of scores on the client side.
query = db_vectors[1]
top_k = 2
result = index.search(query, top_k=top_k, output_fields=["metadata"])
print(result)
🧹 Clean Up
To remove test data and release keys, you can call:
es2.drop_index("quickstart_index")
es2.release_key("quickstart_key")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file es2-1.0.3rc3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: es2-1.0.3rc3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee19f8f4fb5f8f088e5f680edddc9b56132cd288427e0e78f36267b950b7c7a2
|
|
| MD5 |
4e1760a1af236854610956af174f9f15
|
|
| BLAKE2b-256 |
9122acaa520c9359d92177fe8f553d85fb29d7e0189676daf1c67a0a544b85b7
|
File details
Details for the file es2-1.0.3rc3-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: es2-1.0.3rc3-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 608.2 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
398eb45981a987733967659e614beee62988a0ee5e4773aacdbe91e65e614b37
|
|
| MD5 |
b4640fae5ccf9086fefa9d6bde7ff1e8
|
|
| BLAKE2b-256 |
92aa1274eb6dab9bc800e762ebad175dfa5f06d709051e0d16e781afc563fa0b
|
File details
Details for the file es2-1.0.3rc3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: es2-1.0.3rc3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27307153874f7106cfb71f4d4ce59815e1fa62b7cef7a219c4ebe741956d830b
|
|
| MD5 |
6c5eb378a0e5ef8f952f0f2fea6a58e1
|
|
| BLAKE2b-256 |
7d559ace36c64cc5fffe72a705f8395a206c0add8df467790e3b75c1a34a816b
|
File details
Details for the file es2-1.0.3rc3-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: es2-1.0.3rc3-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 608.1 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cda8d88ee7c46e5c473af9c4c5fb24d673be2c6ba0da786c9fa5d3997c441c3a
|
|
| MD5 |
ea82ff0978e6d428d968a42ccd20be84
|
|
| BLAKE2b-256 |
f88f8fd16bd8af3015b61a13038df5957c3a2320f266cb4938c7d1b5f580609e
|
File details
Details for the file es2-1.0.3rc3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: es2-1.0.3rc3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c08c79f2e38131da221f67c5dca62ecb93c1f76b390ae378c007dc2890e51fb
|
|
| MD5 |
6c69d0356223c0b9ff4aba169e5a4bb3
|
|
| BLAKE2b-256 |
42981d0f9aacd66daf301d2f62779ac0f423bb181909edf93f2560f701be34c6
|
File details
Details for the file es2-1.0.3rc3-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: es2-1.0.3rc3-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 606.6 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cc97a842dc36d3435a8d2fc952b325207f0ab5d3b2d19db51b2d49e508c8d80
|
|
| MD5 |
58ad4fe4147b030da82ca48086c3ee98
|
|
| BLAKE2b-256 |
5a6fe6e3bd2377b46d154e1f99ccc33c3a714e1b2511f131012887b2f7c59a62
|
File details
Details for the file es2-1.0.3rc3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: es2-1.0.3rc3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6aa19079e640cc285a515e54339f719ef6c21dc8e55e511f2b788cb62b58a92f
|
|
| MD5 |
44bd57f1ae45c79fefa8a8c13458d017
|
|
| BLAKE2b-256 |
0ba197d3237adab0c8c8c8fcb8c95c515fcbcfa9c69f36007de5c4a87b0bdd49
|
File details
Details for the file es2-1.0.3rc3-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: es2-1.0.3rc3-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 605.4 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
342cfdbf2a6889f3edb98d8a30491b13302dd759c398565a7a704721a5c6b262
|
|
| MD5 |
c0ec15d21150b761b2906d1bccdb0e81
|
|
| BLAKE2b-256 |
ed503652434f0c231d3917e6351ea787583859867242ee265ef11fb194d7c7b1
|
File details
Details for the file es2-1.0.3rc3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: es2-1.0.3rc3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.9, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a81918cdde606781f307277ac688bf3aac2777117cd3a308d3e3cf10b1da6a0
|
|
| MD5 |
091187008e492d5c1b8ed65e96fa4e24
|
|
| BLAKE2b-256 |
1faa021ba661a36f1a9309a1b913bfa709d4405528e3dd6e10dcf8ce232161ca
|
File details
Details for the file es2-1.0.3rc3-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: es2-1.0.3rc3-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 605.4 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0286587925b4713be0b23588c8f274971dedf3c8368135c76af1553f0cf5e589
|
|
| MD5 |
8afc8c1afe5ba2a9e0b6bb150d9afb8d
|
|
| BLAKE2b-256 |
79ef241c2682ba462d0c4c827dbf804360cdf48f192a5c7435ac65cf019a252b
|