Skip to main content

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 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 < 32 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.delete_key("quickstart_key")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

es2-1.1.0rc5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

es2-1.1.0rc5-cp313-cp313-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

es2-1.1.0rc5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

es2-1.1.0rc5-cp312-cp312-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

es2-1.1.0rc5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

es2-1.1.0rc5-cp311-cp311-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

es2-1.1.0rc5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

es2-1.1.0rc5-cp310-cp310-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

es2-1.1.0rc5-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

es2-1.1.0rc5-cp39-cp39-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file es2-1.1.0rc5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.1.0rc5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 83def01bcc0760d208a1f350be824727b4566bfc7e5056b32328e2a2c2583edf
MD5 2558f4bdb67d4530495d53950213f15a
BLAKE2b-256 7d8a9657725a5b50c8686b98b8bbd1be7371a20d35bd7bbd5770338a066fd32c

See more details on using hashes here.

File details

Details for the file es2-1.1.0rc5-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for es2-1.1.0rc5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 18fe05b2a14a86e51dd36a8e67e9df2aebd3dfecfd9deeaf28c18a5c8269542b
MD5 f7ceacc10ba2404c4030b3e1ae35672f
BLAKE2b-256 7359dbd82d65a26e4619692c47a43dbdd07bc4ac90ee73988ca561becd13231d

See more details on using hashes here.

File details

Details for the file es2-1.1.0rc5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.1.0rc5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0a0eabc9ff3ab04b715ad8dd8548b5a70ae47cc43d3daea8dc998255d22c0025
MD5 98287221058d1cee5ecf059897307014
BLAKE2b-256 95eb19a741cc3d01e9c1d8afbf9274af9bf8ddfbba3ae8eca4b37997a65fb5ae

See more details on using hashes here.

File details

Details for the file es2-1.1.0rc5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for es2-1.1.0rc5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c34068987907a5885ef432428d44f44fe687efdbd4fc24b505a990d6aae4bca5
MD5 e498914bd66c4f62b8eefd7fcb5abe09
BLAKE2b-256 adfe0f3923514c96c11f37e5c5988e668e1de2fc466307e0ec340de05d695dfb

See more details on using hashes here.

File details

Details for the file es2-1.1.0rc5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.1.0rc5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 37a2ce2e33d336d2e8e409544e0733b2f2fafbbf973d4c8478d7a3102390f1d9
MD5 e5a09b8e4a0eae38028f1e3a763cbe71
BLAKE2b-256 a419e3436c96e88df700c45b60dfd76b9ad065b06a2db464fc16ab2da375d7c5

See more details on using hashes here.

File details

Details for the file es2-1.1.0rc5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for es2-1.1.0rc5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b6818480b1f67464b093f076350eb1461eaab843deeac623a6c5b1357bff6141
MD5 9675d78034c3f25bc6a3e122fc7bf41a
BLAKE2b-256 78616ae3f93fcd7b84d79c74031ed15d8f2edd9aaac2e9ce25bc1c3b25b6f5af

See more details on using hashes here.

File details

Details for the file es2-1.1.0rc5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.1.0rc5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 47e4a869753e31648b7b7171a59d73312434d0ab49dafeff8d791a8488575ff5
MD5 4d46f99071fb5c6649b6e3cd629bcc82
BLAKE2b-256 2cf4cbe2d11d7b15c740151d8404a3edb41721bd3daff20e0fa55a0f0517222e

See more details on using hashes here.

File details

Details for the file es2-1.1.0rc5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for es2-1.1.0rc5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e12669637b624c60b6f86190ee1e00ad6908b3fe6f3368eb64c8eee030005339
MD5 79b1dad5f6492f38777112adfd4791e3
BLAKE2b-256 5c629a79df597af61d365b60e00062e0bd07b020562aa53fdcfd7baef897e973

See more details on using hashes here.

File details

Details for the file es2-1.1.0rc5-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.1.0rc5-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 362770c86120b25364b6b4a01861fe052ae336d48ce2e101f8defbf45abe884d
MD5 8816765f8520b4acd4a9ca493708fc70
BLAKE2b-256 33a77f3a7516096930124163e3692f6f0f54f98f8ca1714d0d942332da09fab1

See more details on using hashes here.

File details

Details for the file es2-1.1.0rc5-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for es2-1.1.0rc5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab9f0cea870075b8dfb8d2771c69c28229ad7f77f0ca0c24129d896a85911d97
MD5 30d02a48cf71fe673e1cc6f4236891fb
BLAKE2b-256 ae684768c446768ddab43b3f2bc367ee0abf194a84a2d77a9bb1d5c6c815f1ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page