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.1.0rc1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.5 MB view details)

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

es2-1.1.0rc1-cp313-cp313-macosx_11_0_arm64.whl (570.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

es2-1.1.0rc1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.5 MB view details)

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

es2-1.1.0rc1-cp312-cp312-macosx_11_0_arm64.whl (570.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

es2-1.1.0rc1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.5 MB view details)

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

es2-1.1.0rc1-cp311-cp311-macosx_11_0_arm64.whl (569.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

es2-1.1.0rc1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.5 MB view details)

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

es2-1.1.0rc1-cp310-cp310-macosx_11_0_arm64.whl (567.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

es2-1.1.0rc1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.5 MB view details)

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

es2-1.1.0rc1-cp39-cp39-macosx_11_0_arm64.whl (567.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9ccbc55f383840873ce91093bd3a00d48f44ee975ddb11002e4403db375340f8
MD5 32f489d44d18746cff0b80281502dc02
BLAKE2b-256 c27a1e000c7cc151d42618a0455243302a6f6c4f1c88ef2e8a640e055d0f584c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1d56c71a0cab13e5c76e21aded0a939c5d6aa6ec4226164fe8c0763e8a96b975
MD5 19b091e0dbaafffd384e407e7010deba
BLAKE2b-256 180978ce0f95574c88f9d3ab70ee8258f7e66294f7380727f467e8a85ed3cb28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 812c7ef6c6afc37a39472e9388f984a1797dfe79eea358e90358eb50da722a1b
MD5 d49d994b5f178f6c0e96ef2dd3d1039d
BLAKE2b-256 750d403cc8928f0ce9bd7cff5fc6f06118238f5d4be0f8df342c22fb8deba5fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8846c82c7205dc26c0f9f85feedada068af1ba4797da03f07fc4cd007d2084c2
MD5 4cbba1cf8d5c2007b4060ca70e3d0981
BLAKE2b-256 2b4bdf075dbae695fb3fddc191a451076d7a6cbf4bc8bbc575f3919a0770bde8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3165fd80f7465290e7f74fb768642412958325dd51670863155f35a25212e288
MD5 f8b8fc234eb9a758ccfa25c6a2511dd9
BLAKE2b-256 68b4f5ce8c4bf04eaf4dfc82502e04f5a2c1b0dd7e387344461533f47f8042bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a9c63fddcde348ae3509d61601a87931ed99ec74f094991f7799fc84fa3de104
MD5 08b4125c8009642b9bf83e13990490aa
BLAKE2b-256 5aabb810d7b45237b3ed6eac86395678ce5d0f872ac02d626143cdba9380418d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ec1f0672e9b6722dc83f5278daaf129fc1ce96498ee2bec6b5d81195a92ee89a
MD5 b2faebdddc89e83b17c29602dd681db4
BLAKE2b-256 570b013d3b0780b2f53828aaf029f068e9d2003faf9a22bbe679798519baf908

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2a38b57f15248f4f7fc8cb18bf717fba1f001c24082320a08b96e27302521371
MD5 2b05eb7353581c92e557be7d39d4176e
BLAKE2b-256 bfe3b76a6ce286a43e4d0788571ca3aa961c32e6f4e94df8f2b544688466d815

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3595eb845fd0eae643339b83dbb48f32f62b655fbe38ec3ee021f9e1f12c6656
MD5 d0e923398e0c8c82ed049fc1b75e5b5a
BLAKE2b-256 3f3736b5d26a4ac25e0fcd4301e7ee974b8803f61ce0751adf7dd8a73fbae27b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9cd17187ec17f388c14f60be8b11ed8739bbad3e70a2484029e6b55477fb9809
MD5 c301b602e8f610180fb8b2a2812c263e
BLAKE2b-256 b4363a30715691118df9611c774154555314acf2cdc5a0149d5abe2bd9567597

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