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.0-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.0-cp313-cp313-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

es2-1.1.0-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.0-cp312-cp312-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

es2-1.1.0-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.0-cp311-cp311-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

es2-1.1.0-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.0-cp310-cp310-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

es2-1.1.0-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.0-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.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6d4adc0f4f2d9be0c6197ee1013d7b371c0690516828c3795a5b2d6f5daf757b
MD5 d504506957c8a5a7fb0bdff92e73a424
BLAKE2b-256 968cf0e05e58f4d30ad2fa31c4746ecdccbfe2c346c1f9b92e272b1a2339ec2c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: es2-1.1.0-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.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ad96973010e82254c4322ca152128d5bf02170a6b1c8457123c5c383c919e5d9
MD5 8d898418eb627032f1e7b92b79e73776
BLAKE2b-256 e01eee42653d37d254c087c512bf9fa028549699527252615f0fb6cb510a6e38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 61482eee33469e9ec5a83cf71ee1aaa8c845eeb823357ec0b9aa660c0d0ec313
MD5 cf5d448d8893cd82722f16d0900271e3
BLAKE2b-256 523ded077dbf9224016c170b81afd44f41051af71a8ab53164ac7be35a93de5c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: es2-1.1.0-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.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 60969bf57e952c52ac59d28ce82ade9a4b7fb9540fddf645807c2338905936dd
MD5 c88d1d2e213c97cad46c46e535f33189
BLAKE2b-256 84904797fd041af284930023558b0618a2923cad119be70b6dd87c308ba548ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2c07077afe9381d7c0d561e3a4e66693d38e82fd574d4924f8f3051436081a0a
MD5 015c74f60bcfcd33ed04a6ea18564c59
BLAKE2b-256 cf83f490c324ecdae4bd90dab09241cec30efb564a054a1ca854c6be61d796e9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: es2-1.1.0-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.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ad272f992b6bffb3f7c71db6b6de6ded45916f112e808d4f1616f6bbc3fa999
MD5 f3b267018b27a17f2e516b48179edf23
BLAKE2b-256 dbd6154742b1894ab5aed2a676c96d6ab3fb8af14e98bf5268b3811ad0e67b84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2544e9e0e30cd5ee80f0777b269152936fb648461c2054aec0e87e6cf65d2cdd
MD5 39c3c60bb254feea0574ad3c3d6543b9
BLAKE2b-256 d651a96fc49fe2ad1173d8372118e0c1aa6dfe9ad69ec1204a6b56f48fc7d496

See more details on using hashes here.

File details

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

File metadata

  • Download URL: es2-1.1.0-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.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 814130a01ea11ace694864410d2ec209cd2bfb110ab7c924048fb111441f44b2
MD5 c7593ff471218ee0a5ea1929e4ff6fea
BLAKE2b-256 7d68e07ed3fe012cb50c2bb33640d2dd455713779d881be9655ae840dd829297

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6563d3063d09d53580cc34b448a48db5ea582ab7159394102e6061c9772a8113
MD5 85c6323c7780d6304fdf61373366de37
BLAKE2b-256 8b4ca003fce4010d28daa452aa31556fa93383086575cfeee83b6ce5d915a2ec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: es2-1.1.0-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.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8a5b899708b9558d25d4d08a4ebd8604b3a7bdc9dad40d0b276535c42bcb3366
MD5 beaad09d7d02d0731233e78cfb053179
BLAKE2b-256 32745fa0d32839cc201751ff4546b645787b9ffa484e05e5f3b3f5f21d7ef144

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