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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

es2-1.1.1-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.1-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.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ed7fa017f32ad35f32537f47b275180406e56bf21719ca275e298fe13f043cd3
MD5 8910aad8e0094cbfe10ff85980b5c721
BLAKE2b-256 f828cee2210c44fbb2eed724357817694d8f06c80028e1d81198bdcf0b621a34

See more details on using hashes here.

File details

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

File metadata

  • Download URL: es2-1.1.1-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.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2d060276a4c44b943c28cd7b9b38c33aad7cc533b8c195cd7286c86c88241503
MD5 e5f70c674ee2f06b8fd8369a1d8d2615
BLAKE2b-256 9e02ca7a88ba6228ed92fc2d562d22e17c37c0f35838fae74608d3f540349ddc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ac981ffacb5fc4f4e35547f85d6daa2df78735388be8829508d5f138fc604a41
MD5 6f2758466454101f30d27555bc0fb5fb
BLAKE2b-256 f532175171a79d78306f4547dd53396cf4fad0d3b6871dbac727b0a5a438ece0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: es2-1.1.1-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.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 330e87c1ce6bba00894d41e52ade5d64a119eb2cdaae644f40c896b45def4c3a
MD5 5c2a2b69fe904e566a4d9f3d3fa59921
BLAKE2b-256 c330e74170e94b1a8b95e55a36ac64aa1adad61bcb077afd17c9357e20f958e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 09983c7ce033b4850a2f4cf090bdf9ebf33f05ee0dff6ea23cafbf6f6659d5da
MD5 71dee91017d07528999aafb0583a0adb
BLAKE2b-256 ed6511da90d2cc8b69c332135a563fa37a6f738b8227aa038b5d36a9f6e0b8e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: es2-1.1.1-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.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c0f759a2ed19357d747f367ebbd90c78a60d13fe7b4913df22eb7814ade407b1
MD5 2a0b6da965bac9dfcc9c75b9e52cf2df
BLAKE2b-256 ef73bd905ae3013abc30e536ef2bb32338ec1b731a72cb6ed742457fd0014b42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 43121f873ab9542911af2bf3230a616ae7378b8bf4f010459ab3a3eacda86e3e
MD5 5cc18d5daed95d8511c3499ea21c9da3
BLAKE2b-256 436e97f6376bc1599f027584b9a32c02ed9404c12fa4ebc0636ec999742de24d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: es2-1.1.1-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.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 79f82caadc03a89ca70fbf7fd2f8ea45d86ac76b64301881bab7536595d4d010
MD5 ec17dff25065026695627f4b9743aa1b
BLAKE2b-256 878b6ca0d746a14b0affc1c4d0ab499daa05be2f21c4ec1e474e65279a6105db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2180c5f8fc7f479bfcddccfd2ac8c89a5f9359006cff53d493e2881d5cc28462
MD5 bb34579beeb31b58513542f037eca90c
BLAKE2b-256 3ea295365f7cb831a3a241a04fb756fefcfcd950ffb08d03ea5febd811f361da

See more details on using hashes here.

File details

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

File metadata

  • Download URL: es2-1.1.1-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.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 68c1c3bddb3b5710444678be90ee6c5b3c29512c82900408a4b5d5867b782e19
MD5 4d41a7d6569bc9aaf0c77ac627296c2c
BLAKE2b-256 69b7ac7f7265617497740ca32221f877c229b7bf9d61419ab8ecf3034940572c

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