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

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

es2-1.1.0rc4-cp313-cp313-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

es2-1.1.0rc4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

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

es2-1.1.0rc4-cp312-cp312-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

es2-1.1.0rc4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

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

es2-1.1.0rc4-cp311-cp311-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

es2-1.1.0rc4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

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

es2-1.1.0rc4-cp310-cp310-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

es2-1.1.0rc4-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (8.4 MB view details)

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

es2-1.1.0rc4-cp39-cp39-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fb5a21935b1d27673b52de4cfffdb82fea9703305d595bb31fb49fe1b0ee3cc6
MD5 806815f95a93fec1995171ed1c978125
BLAKE2b-256 5e563cf5d6f9c7da328c39e09179e0df60091c633cce977a32767f0568389658

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 141e767be0e47bdc88b1a3ac2f78586cc415ea7f04a974ab4f97fa298157bc26
MD5 769a970f370b95c2a11c24a5dc804d5f
BLAKE2b-256 274807298f726b92e99d49069dc35235cec42b8ca9908307400d5c557694e823

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9657e30716868ecd2b3954561ff9c5e4036793036b07c9ff54b560943917ae6d
MD5 cff76cace849bae739bcfee9d191396a
BLAKE2b-256 a1f2d1b89094dd4f45439f4f02ee594acbef90076d6d466c9f90d4d90706a3c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1dbe7f012217f7e54bfaec72960c2e1fbc6b8785c8260af7735e49cb2e5e2f75
MD5 fcb709c77f55dbb829d7631ed285b2a9
BLAKE2b-256 51a9ce57499322557f9cc64292bd0ed1fdeb69e2f14ff93e02603aa4ac54cb04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ce85a0faa8bd2d6201a7afdab78f7f7fbd79a0bc16d21a5eaeb92244326f0f4a
MD5 eec724ef1f22e23b9898f06759e22293
BLAKE2b-256 c88263a3adec8841989b4bab5d48f238ae5f851f49f6a7d71c266f2da4f46907

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2a24f358d6ce8f62ce807116bc7d4fa9ae1f6d6f3bbe1d96a631ac07d2aa1174
MD5 f17f49265b5208a5d41a2c8368bc01b0
BLAKE2b-256 86275146c84fa4e1039ef819f97f29b71e8d60e272046c883ba6d4baae6d7e86

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4630bb2a86f1a1648be3123c62099573e70c44d8ec1ff10cbfb08877408048a0
MD5 6334457021d9ba2da993ec514a1dea47
BLAKE2b-256 4ba85b10484ddffbc318a6cc6b4ecee41d3414fcda04e6c8f9d06d267258c6ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6bde268bb56c46cca72534bab04a5d886854f35cc85a23939246053289104a81
MD5 361524a7b5d4459cd0c90b3177c1c97c
BLAKE2b-256 b1bf220c3aed48178f86942ba1afb0f327a5c816bbe352efbc2ba5bc200af0d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc4-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cb8f398d436c6ef0dc0c381519f47bc0f22fea5b3b85aff805d440732aae64ce
MD5 d8f80cdad27b57fbd200b1d723604807
BLAKE2b-256 ee1bf9853779cf518ecf7f30a4ee3aaf34792000fd759ae007c60ea29b9bca2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for es2-1.1.0rc4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d551fa98b4516be3ff1a9134f9c8e5e5a2d99e18c6ded0862030897909d109c0
MD5 73b6766f7586635771b6e28205a9d0c8
BLAKE2b-256 86de8c513e620a2b0d5cf59cb27e688c0fb5c7c1a50441ef27808e59f446b6f5

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