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.3rc7-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.3rc7-cp313-cp313-macosx_11_0_arm64.whl (613.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

es2-1.0.3rc7-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.3rc7-cp312-cp312-macosx_11_0_arm64.whl (613.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

es2-1.0.3rc7-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.3rc7-cp311-cp311-macosx_11_0_arm64.whl (611.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

es2-1.0.3rc7-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.3rc7-cp310-cp310-macosx_11_0_arm64.whl (610.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

es2-1.0.3rc7-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.3rc7-cp39-cp39-macosx_11_0_arm64.whl (610.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc7-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 806f5f36f4615929697db0584be1b067e863c11689abb45277abe13d43e1cffe
MD5 d6aa03689a8c7b3dafd90efdb389f8b6
BLAKE2b-256 c81820aeb3919ef0eba3692644a88e33c9a0ba57bcae48cdefa0449e3deb6b6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5d23a9337a1652604d924d12b7eb6348dfb7d17945b29c936c9ed7d12cf463c1
MD5 ef1f44527df3b9f90e56e0e9abd9272c
BLAKE2b-256 1638ecf87066f02025e16f95bb6accf9f0b3571c5d164c57d1ee2caff8c73c20

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7333c181ae67cad475f85e9580e7c2069fa4a6644a0e628946b3db6ea91f4525
MD5 1b8f8372c7df5640af95d0d6713da3b7
BLAKE2b-256 d1b0f3f838f582e81e32123b030d0e2f760fe90abf8f28b926ae2882f4743376

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9d1ff59a195fe4aa94e286705330f76496f64047e9d411fe81d3c65c48868861
MD5 ba57d892ff30b7006c3438b345aff1ec
BLAKE2b-256 d372fe3911eb88e6634308051d3bb673ce8c91e61ec8d13c9c751f4cc1c3280b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d21f3c0cd451260d2d5f9a64fc17f37b71d059e542366e6579fbca2a11ad2e65
MD5 5ab197abf0552f504dae53d918b21fa4
BLAKE2b-256 8fef29a96cc71a30eabac9fc59b4a75e01f98d82956af0705074679de836dd24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 66cccd9af8ecc8d0b088c4a94a761d3b0837cea3e38a624b994fbc50787fa75d
MD5 adfd090e601efa95e3740ef5e6978141
BLAKE2b-256 62a2aedcfdd9f07e78257a4a520504302095a47b10681808bcb64eebd6fde390

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ca1715be3efe5dde8a64e9f7873ebcc99968276972064b0e40b22d11c2143d58
MD5 07fd3c19f5dc30a6f8a365ff6ec49b27
BLAKE2b-256 1de5bbc7cd12117d4d4e1330eb30b43fe9ebaa50deb471014a689bcb103aefc4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d29db75c71f74ecd71679c25c83da21613a786093116efff63fd3d84926ce2e1
MD5 a5ca80f7ef5cded7da8b1c6b6d45ba35
BLAKE2b-256 bb66027e929d95c86defd28b69867ccf0e726597b209e06eac751d17145ebd7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc7-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f6f10a1db9b8162bc7e41761bec4e42c1659f3a2ab6b1bb7d9287c88f7e6be06
MD5 3576744b06d25b855f5dd5555d58631f
BLAKE2b-256 6ebd71b3e7357d4f36ed633370ba6c89c44bdab7249a539a04352d0b495c385c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.0.3rc7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fecb45c4e7f358a5b125a19dd6f95ee17c2bcf6753dcf0845e6a17228f3c5f15
MD5 a1e28c85b02ece29f4504dda4bb8af58
BLAKE2b-256 ea914ca74c87ff38086ee41e2c4170a6b86037c657c4c17ae5fec360540e3d06

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