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.0.3rc6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

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

es2-1.0.3rc6-cp313-cp313-macosx_11_0_arm64.whl (613.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

es2-1.0.3rc6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

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

es2-1.0.3rc6-cp312-cp312-macosx_11_0_arm64.whl (613.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

es2-1.0.3rc6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

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

es2-1.0.3rc6-cp311-cp311-macosx_11_0_arm64.whl (611.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

es2-1.0.3rc6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

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

es2-1.0.3rc6-cp310-cp310-macosx_11_0_arm64.whl (610.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

es2-1.0.3rc6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

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

es2-1.0.3rc6-cp39-cp39-macosx_11_0_arm64.whl (610.6 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file es2-1.0.3rc6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.0.3rc6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6bf940c64c9232156fb0b5f735bbed6152be1912d27afc13c44cd952c3f732e9
MD5 fdfaaf853ea3cc9775b266c4eb79e0d6
BLAKE2b-256 716b7889bcfcec0cbe30d7a133f9d35cf976836200baf856998e1d0557bdc634

See more details on using hashes here.

File details

Details for the file es2-1.0.3rc6-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for es2-1.0.3rc6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 678c6974c04cd6dcd36e63a7b56485a2a4af53829b8f5eb53649ae6b0bce9a39
MD5 843612350f1b5b253a5a7befe095d5ea
BLAKE2b-256 da2a203815a20da29a1ccf7bedcee713426c3d0d75e9daeab83086b37ca5e189

See more details on using hashes here.

File details

Details for the file es2-1.0.3rc6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.0.3rc6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9e15be7d9a1a83d5eda18f74018d086fe9c522639d30eb9bf29eba3c2942da40
MD5 7b85bdb057676b851879073ae23edd15
BLAKE2b-256 9e5aa19f8c250ec7826c3b66be4308c004a309d14e126d82dc27f6795b0bfc01

See more details on using hashes here.

File details

Details for the file es2-1.0.3rc6-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for es2-1.0.3rc6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 37b6ebd221c0155ae9ef0f5cb21934235a5d5dad99ee4c2110dc40e7dccfef8b
MD5 cce6c20815bec72dbe4d0184dc07e115
BLAKE2b-256 284c221ca20d1ce4e0d20e65ff1b9765e4b443ae6cfa2c46e81ce60d11a8c928

See more details on using hashes here.

File details

Details for the file es2-1.0.3rc6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.0.3rc6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 119f2b98b8c433f4236e3fc47550da283bfac78bd1e1f3a0006ae5d9d3ea4074
MD5 ea47c35606aa48f871cf563966ea5243
BLAKE2b-256 973bea33564b783ed998354c62ecf1e14a672ca09366ca3db3eccf0787b8dce8

See more details on using hashes here.

File details

Details for the file es2-1.0.3rc6-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for es2-1.0.3rc6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e8cd9c093e0f14cbf98be4b8022d5dea569f37e9f479a6e9c0baf1d6b8cbc4e
MD5 beff85d9bb96ac715427f2f83d310b99
BLAKE2b-256 686cb303c2f828342734a6817d73c42a5b899ea33d01336cbdb1e2d21118a15f

See more details on using hashes here.

File details

Details for the file es2-1.0.3rc6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.0.3rc6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c15752196b365c4d6216db207ca3bfd1bf4ee225b7f67c5fb65b46e999bf4d35
MD5 a190f37e3c0fa953bab374744312c2d5
BLAKE2b-256 9b0a42944040f30bd4489f9e985f7a2c601b0fa4775f1c49cf78dcea5f8a78bd

See more details on using hashes here.

File details

Details for the file es2-1.0.3rc6-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for es2-1.0.3rc6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 438dfe4e77b7cb5cade497a32aede1e90dfa834e296dd2255ed6c8d89fdb7891
MD5 8dd9d92f6b081df27ffeef5ffbf15898
BLAKE2b-256 bb05ff56de61ea9ac0056d5fd04c960b1cf5df6cfb9b23c226850d891fe8e56e

See more details on using hashes here.

File details

Details for the file es2-1.0.3rc6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for es2-1.0.3rc6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 15051017f8d49a195113c42f3d8e17a019e1a6310249de64a6afa18d1fa2d9df
MD5 33795e7ffee8f735726512addcf91270
BLAKE2b-256 56e58e9bff26e4379d8a6a390dab3753dd07b939330ca0e2a485b24ada07286b

See more details on using hashes here.

File details

Details for the file es2-1.0.3rc6-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for es2-1.0.3rc6-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7e995a5fd6325de3fffb341ba1e420e44c2dac2d7305b62674de1a5d8b1a83b8
MD5 b1bd17ff71797f4c5228ae2b3d8b9d4d
BLAKE2b-256 8f146afc7dbec23bbefd5ffc4cd5ae0cde9c0dd1cca8d5694f01bc724a97706d

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