Show HN: Vector Similarity Computation with Partially Homomorphic Encryption

sefiks.com

1 points by serengil 7 hours ago

Excited to share an update to LightPHE, a lightweight partially homomorphic encryption library for Python. This update enables the encryption and decryption of multi-dimensional vector embeddings and the computation of encrypted cosine similarity between an encrypted vector and a plain vector when using an additively homomorphic encryption.

This relies on a two-tower architecture, where one branch processes a pre-encrypted vector database and the other generates real-time plain embeddings. With LightPHE, encrypted cosine similarity can now be computed with a single line of code with matrix multiplication operator (@). This allows privacy-preserving vector search in cloud environments, ensuring that sensitive data remains encrypted while computations take place. Only the secret key holder can decrypt the results and make decisions.

While fully homomorphic encryption (FHE) enables computations on encrypted data, it is often impractical due to its computational overhead. Partially homomorphic encryption (PHE) provides a more efficient alternative, offering significantly faster computation, smaller ciphertexts, shorter secret and public keys, and reduced resource requirements, making it a practical solution for cloud and memory-constrained environments.

LightPHE supports a range of additively homomorphic encryption schemes, including Paillier, Damgård-Jurik, and Okamoto-Uchiyama, which are practical for real-world applications. It also includes experimental support for Exponential ElGamal and Elliptic Curve ElGamal in various forms, along with Benaloh and Naccache-Stern.

This update makes LightPHE well-suited for any vector models such as privacy-preserving recommendation systems, biometric authentication, reverse image search, secure vector-based retrieval, LLMs and more. I’d love to hear feedback from those working on vector similarity search.