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.3-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.3-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (5.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

es2-1.1.3-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.3-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (5.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

es2-1.1.3-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.3-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (5.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

es2-1.1.3-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.3-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (5.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

es2-1.1.3-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.3-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (5.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

es2-1.1.3-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.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.1.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0069b366180c3d290e6ec59f039ef6cf4beb09deed7eaa3dc774232c5e89b3f4
MD5 1d6d05c4e394e1fb8e1049a1b260774d
BLAKE2b-256 2266a8c2c5a901697bb25ad9ce1e01eb1866642b1794571fbb38e8335a9bdac6

See more details on using hashes here.

File details

Details for the file es2-1.1.3-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for es2-1.1.3-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bb428869709593b1beded54023ffbaf35181e716cc50693c95ceee1d24ee0fbd
MD5 bf8e27789c8c21ff3e132ff1bc23cab2
BLAKE2b-256 77e258b82aeb0f0aaeecbdedf28bba43a55fb755b3665d8df2c29da784eaa9b2

See more details on using hashes here.

File details

Details for the file es2-1.1.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

  • Download URL: es2-1.1.3-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for es2-1.1.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ac9a0378ddc790885212d613a671c19cf04352a6b96d074c46e3e5aae60f6eaa
MD5 a851cdc663cae549f86093d9dfd2f67d
BLAKE2b-256 be9119865222582f75ccea6c436a4e1bd1f64978aa724f30b27c5640e160856d

See more details on using hashes here.

File details

Details for the file es2-1.1.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.1.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 462d72eb68dd2f8b7ac502b52f6528e7cfa33c5097a0d18d62bd09190eb39fff
MD5 ddc850742b56307f49502d23eeb435e7
BLAKE2b-256 89cc27d8b1d839350e51787a36d203e3c76724ac587aa3ea9935f232ad70a743

See more details on using hashes here.

File details

Details for the file es2-1.1.3-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for es2-1.1.3-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 47a39f1eb597c3ec203b3df1886e4f217844fc3cc198eb518337b47c034e1d3a
MD5 7eb271ddf1813e2bfaf83cf9d6fe1154
BLAKE2b-256 389364fd8f9d59523ab952d2ae5838ae51fe81c9d51f853bc732443ff56dc1a9

See more details on using hashes here.

File details

Details for the file es2-1.1.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

  • Download URL: es2-1.1.3-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for es2-1.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8893f985b94b97541dc0fc8145eed68c078820ec47b5850ce0a2c585c3662fdb
MD5 b38cf237cef5b666ef7438f3857d2694
BLAKE2b-256 24ce12b1a890c6f50044c71c718409c87109968834ee26221e9a74bd8084c206

See more details on using hashes here.

File details

Details for the file es2-1.1.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.1.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b304c56735570910fa33af077c3166cab1e7061fa727ce2fd3b394234fef0393
MD5 a62f6966da594af87d186f0b3709f6f9
BLAKE2b-256 93c05b223c8cc77a3806db7e3bb392699b81dde30554796360b7ba7c025e4791

See more details on using hashes here.

File details

Details for the file es2-1.1.3-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for es2-1.1.3-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5a3037140ee1343b8eb45a448f07b59bf66d7ddd2b1d7d76d05c1b84b9ed0712
MD5 8451a80a6cdb7a51d43a9ac94962904f
BLAKE2b-256 1a711e690f45c9fdd5eb60a472de171fed7b07bb38319e46a520223f6492056e

See more details on using hashes here.

File details

Details for the file es2-1.1.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

  • Download URL: es2-1.1.3-cp311-cp311-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.11, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for es2-1.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8fa4530a27eb6cdad426d6162ff5a3574150b0cefedf57be4d3cbe5b0e54902b
MD5 13397bbd28f7459376f85701d7be182e
BLAKE2b-256 7acdb397278a79a06b2e46563e908dcd56e0263f33306482bf2268174cd19bb2

See more details on using hashes here.

File details

Details for the file es2-1.1.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.1.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 490c79dfca03e7e8a0127bf9f07b4a517b106e8145f4388eddb381da7d88549a
MD5 9f6b31838b7b1d06c1bd10c70624c1ad
BLAKE2b-256 18859e2c88dec03c0d37983a35535e13b38b39d592365ea31261e6d97f896bfa

See more details on using hashes here.

File details

Details for the file es2-1.1.3-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for es2-1.1.3-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0585f25386120c85ca16d8eb3b4dd6757a10354ebab5e192861f40f124cf24e8
MD5 842e33b7d154f9cf40b1c8de2526bd72
BLAKE2b-256 ad4c37898f700e9b9aacc3a644d3365e6fae5c6cb7faa27ce1f106614061356d

See more details on using hashes here.

File details

Details for the file es2-1.1.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

  • Download URL: es2-1.1.3-cp310-cp310-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.10, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for es2-1.1.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 27f0ee874bc77c06963b8ce99a63c1ab9ae2a63282b64785784e066b70465116
MD5 5b5d5da83e10415501c04ef80ca29d95
BLAKE2b-256 ddcf141a5064b42d86ced02c4a2bca5a1dba26cdd11b0a04af80a205f78102d4

See more details on using hashes here.

File details

Details for the file es2-1.1.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.1.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dd119c1f48fbd4b4d156aa2e19e9d45e653c5ca7156bfdc2520e6cdbb4fa9935
MD5 e4e8e2834ba5b6240acc58a28f00fbde
BLAKE2b-256 5e880becb1c5a5a8a829543b19d9ff433f0196d01346a7e67caba06173c8cab2

See more details on using hashes here.

File details

Details for the file es2-1.1.3-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for es2-1.1.3-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d0bbf710c077f1e61ceebc75e9f21693e2218dd588e359425b2cc44875d72429
MD5 42b0bf270e6d2b58efda8c52b16a6c82
BLAKE2b-256 2872ec8f9652bebf0b9bae09221248562b2e490fe01fc0697f23cf2f203cc802

See more details on using hashes here.

File details

Details for the file es2-1.1.3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

  • Download URL: es2-1.1.3-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for es2-1.1.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7655275d0f96adce00fabad210e0b124a5d4c0f4d636a5b23928b69b7388c23a
MD5 9a6ee601c4dd18f401ed89e6cf8fe470
BLAKE2b-256 9b5fead7428f93f7f06b2db6de25639fdaf09e40a2974143eda016e6b1cc57dc

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