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.0rc3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.7 MB view details)

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

es2-1.1.0rc3-cp313-cp313-macosx_11_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

es2-1.1.0rc3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.7 MB view details)

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

es2-1.1.0rc3-cp312-cp312-macosx_11_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

es2-1.1.0rc3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.7 MB view details)

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

es2-1.1.0rc3-cp311-cp311-macosx_11_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

es2-1.1.0rc3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.7 MB view details)

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

es2-1.1.0rc3-cp310-cp310-macosx_11_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

es2-1.1.0rc3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.7 MB view details)

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

es2-1.1.0rc3-cp39-cp39-macosx_11_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8e778ed4fdb7fae93ce6afdca9a171d7a8d7a0dd230042febd669a3d6e3e04d3
MD5 1cdc53ca8d435a99f318eeba77d9ec9f
BLAKE2b-256 582e2b77d380180a571e89f2d98f9277b9ecafbe7efbb2292b64c28e947b1e25

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 be2cdf4150b4ae98a1da21bda88457805f7a059cd167e99ffba68a4d501f720f
MD5 ff48ae667a566c2949bb97a6d53be914
BLAKE2b-256 a9fbd82fcca9bdb90850ab98b267541e264160b22a54db12ad8a870daf8363e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c5132cca500a23dd121ea1ddc0d7cf6fe655b3603920bf4a59ec2b164778a3a8
MD5 5189e5757be25885b29b8bef8469b53c
BLAKE2b-256 3fa82a505cc0dab62f388e3bf5a0edb7ef7b65168115a617e17781d8842e5280

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9cf37426b2cd08aec8c6717f8a355579bcd467b39757e97ceeace3638651ca59
MD5 c66c4eb388972fc1e508cd96403e570f
BLAKE2b-256 b3c76f29b6394714179d696a3a3ed6732d03aef8dcffea9ceb1d8b0f5dace8e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a7ffcf86ff9534cb9421c938b8327a293ac4e8d2b924bf608ed807b3b09c7e8a
MD5 e813716b10d42ece97a3fbbce462215c
BLAKE2b-256 33505ff4b3165187ad610e5f9799e3e50a3163195c9773e61b63c867b762307b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d828c45f701af66a73f764e56a2d738c9150bca7fa2f224417e2ca26b0ee4b3
MD5 2937ef72155799b903d1530c948ac41f
BLAKE2b-256 887dc135436af138d9712d9aaee606276cdba14289de2318d831732b93c86158

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d2e425a482d5d22152dfcd30d169482608bdb8c7976a38cb38e25a29bb784c84
MD5 fc20ebbec5091101750e6a029638a8bd
BLAKE2b-256 706c59a7a6d00d795b7882605880e29eaacc8d03cd54a6c49a61ca4265cb05d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b93a439463db7b4f1893ae860b6f839428a2c064c77a7ad6402d8714c91f9588
MD5 f21e5948a03b4179bee1433765d28318
BLAKE2b-256 f0d5676d8aa53d32ff1efa1b5021c006f31a50d62a1a6c700003fd02017cf059

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d9ab596ddc0411b776b51747280d59da53c4caf02f0515f07081c33a4ae0be84
MD5 f60f9ccd53f3c7e90a6c01621dd24bc4
BLAKE2b-256 9c698cc668a596a6822cca17ebcb46c11090a77281551ba0a3e2cf69e5ea4a62

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57ca43f442adade57c8d158ecafcc6a164c52bcd1cd56b408f753184648c7da8
MD5 2ec05bc7f80ba496679c688d40035eba
BLAKE2b-256 bb5698cb977591f4991714f422a6dd232f6f876e1e5e0572e4befd5bf36b2a62

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