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 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


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.0.3rc5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

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

es2-1.0.3rc5-cp313-cp313-macosx_11_0_arm64.whl (611.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

es2-1.0.3rc5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

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

es2-1.0.3rc5-cp312-cp312-macosx_11_0_arm64.whl (611.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

es2-1.0.3rc5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

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

es2-1.0.3rc5-cp311-cp311-macosx_11_0_arm64.whl (609.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

es2-1.0.3rc5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

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

es2-1.0.3rc5-cp310-cp310-macosx_11_0_arm64.whl (608.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

es2-1.0.3rc5-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

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

es2-1.0.3rc5-cp39-cp39-macosx_11_0_arm64.whl (608.3 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 52d4554a1bf79aeebdedd73fc90e6270ba9a3c8953ca0b3387345633a1df7407
MD5 b290f364dba5bd9ef170781512e4d283
BLAKE2b-256 5e37378e0de52c75e4948e2b37f3da8662431629adf100f29800b21420bd6227

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 72c49c785d0b129c0fd39e74d078ca4738a9b921b1b8cee46104371ef3a2bff9
MD5 d2ca207ffa99e93487122d8d45f33132
BLAKE2b-256 0c911864e9acc3fe813e371b45ee2aeca2e9e00323c81ea8b62c4c722217de30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4f608d2239198564e9d8f8606eeff56a3ab03e9b927d20dc58cf7e5f128f429e
MD5 05da96de804606a8167d7bc49155e62d
BLAKE2b-256 3b684d1e5c156f933679100a1aa2b275d2bb8d90c75d4553cca430060f310b19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 22381b74f3451f032f2c418867798c00972d0eaabdbb439c0c6b635dcbce42af
MD5 ea849132f4914511602d8ea0fc5fdf7c
BLAKE2b-256 f8f81aa017d8ae1db140eb830483b5b8727f7e3e75e77f348840d16d382addea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0d388100732d85905477010283cf90ac669ab0efb3fdcc789c2af5c915ae5b04
MD5 9378c56d5ce08779b6c1d0ba7ed233b9
BLAKE2b-256 ff22c36784deb01240612e26ed6fba9a3142e0214345e330e4fc9af3da326fb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e83ac54c4d6b096b69e2d111eaf820c298c880bc25e05278bf6515dc27eb5823
MD5 cbfec850df970fd6a20681df288adfa9
BLAKE2b-256 0723279370418d1a02015607145a025079310ab3b90d4eb8fd960458fa84a587

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f841c20e2580cfe760850a548c825f72c58e2026565c09aee4ec03e76d71065e
MD5 2393cf469373d9f655e1e6ed135f6d7e
BLAKE2b-256 2279015121667b272c13de732494cb8d5bb7ae149a3c9827f748ebfb184934e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 04a634a316a466485ad10fd253fc0ce1ee651418ad312d254fada478dc92bff7
MD5 cbb9c61eeda969ac2390e6bb92b00587
BLAKE2b-256 f76032c2e7ab85d35343c97d249596e192ffea249bc7c427be8ce69658d23887

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc5-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8b3683b7d80aae3cf55f039b568933afa221493267ce533447ccefeeae438a91
MD5 faba1b78ead41bf56b1c6c5b670b36df
BLAKE2b-256 ef60f43226140be07179d13560d0c9bf455530d30659c026c6ea6eae4053d60f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 88386864f45b4dc382639db2ad7d38aa9fe8e07e3729ee4d911f4da9741d37ab
MD5 9b5bfc04bb52d324ba8c91bb6973a8e3
BLAKE2b-256 9e67cbdc2b34702d764a08523b3595886eb8f0b9ca0faf04fec36e9a4b0007ed

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