Manuscript Offprint

arXiv:2610.34248

HNSecW: A Logarithmic-Time MPC Protocol for Approximate Nearest Neighbor Search

Fahong Zhang, Weijie Jin, Lixu Wang, Ning Luo, Xiao Wang, Wei Dong

Fahong Zhang

Nanyang Technological University

Singapore, Singapore

fahong001@e.ntu.edu.sg

Ning Luo

University of Illinois

Urbana-Champaign

Urbana, USA

nl27@illinois.edu

Weijie Jin

Beijing University of Aeronautics and Astronautics

Beijing, China

jinweijie@buaa.edu.cn

Xiao Wang

Northwestern University

Evanston, USA

wangxiao@northwestern.edu

Lixu Wang

Nanyang Technological University

Singapore, Singapore

lixu.wang@ntu.edu.sg

Wei Dong ∗^{*}

Nanyang Technological University

Singapore, Singapore

wei_dong@ntu.edu.sg

ABSTRACT

As a core component of modern RAG systems, approximate nearest neighbor (ANN) search has been extensively studied for decades. In practice, deploying ANN often requires symmetric privacy, where the querier's query and the database owner's data must remain hidden from each other, necessitating a secure multi-party computation (MPC) solution. So far, most MPC-based ANN protocols follow a cluster-based approach: they evaluate distances for the query over a large candidate set and rely on heavyweight primitives such as distributed ORAM to hide access patterns. As a result, each search typically requires O(N)O(\sqrt{N}) time. We propose HNSecW, a novel MPC protocol for ANN search that achieves the O(log⁡N)O(\log N) search time for the first time. We first study the single-query setting. Starting from HNSW, the state-of-the-art ANN algorithm, we redesign its control flow and data structures to achieve fully data-independent execution. To further achieve logarithmic search time, we employ offline reshuffling and partial database duplication. Furthermore, we extend our protocol to support multiple sequential queries by introducing a “double visited” caching structure that eliminates redundant cross-query memory accesses, thereby avoiding per-query online shuffling. In addition, we develop a batch-query protocol that exploits higher parallelism to reduce both round complexity and the circuit’s critical path. Our experiments show that HNSecW preserves the high accuracy of plaintext HNSW ( ≥90%\geq 90\% recall) and delivers over a 20×20\times efficiency improvement over prior work on million-scale datasets.

PVLDB Reference Format:

Fahong Zhang, Weijie Jin, Lixu Wang, Ning Luo, Xiao Wang, and Wei Dong. HNSecW: A Logarithmic-Time MPC Protocol for Approximate Nearest Neighbor Search. PVLDB, 20(2): 284 - 297, 2026. doi:10.14778/3849423.3849440

PVLDB Artifact Availability:

The source code, data, and/or other artifacts have been made available at https://github.com/Kleenex-ultrasoft/Secure_ANN.

1 INTRODUCTION

Efficient approximate nearest neighbor (ANN) search [22] over vector databases is a basic data analytical primitive and becomes a cornerstone of modern AI applications such as Retrieval-Augmented Generation (RAG) [27], which enhances Large Language Models (LLMs) by incorporating external knowledge at inference time. So far, designing an efficient ANN algorithm for a large-sized high-dimensional database has been well studied for decades [29, 30, 43].

However, in real-world ANN applications, security and privacy concerns arise [6, 31, 48]. Without a protective protocol, either the querier submits the query in plaintext to the database owner, who executes the ANN algorithm, or the computation is delegated to the querier, which typically requires the database owner to reveal (at least part of) its data to enable search. The former violates query privacy, whereas the latter compromises database privacy. This motivates a symmetric private ANN model that simultaneously protects both the query and the database. We illustrate the need for symmetric privacy through two representative scenarios:

Example 1.1. In a joint healthcare study, a research institute (querier) prepares a drug trial by querying a hospital's (database owner) private gene-expression database for similar patient profiles. The hospital returns only the top records allowed by the data-use agreement, and the institute uses them as LLM context to generate a trial plan. During the collaboration, disclosing the query may reveal the institute's research details; disclosing the hospital's database and patient data would violate regulations such as HIPAA.

Example 1.2. During a cyber incident, a security team (querier) queries a vendor's (database owner) private threat intelligence database for the closest matching attack reports and indicators, and uses the results to identify the threat and respond promptly. Disclosing the query can reveal what systems were hit; if the database is disclosed, it can expose sensitive intelligence sources and customer incidents.

A naive approach to achieving symmetric privacy is to introduce a trusted third party, such as a cloud provider: both the database owner and the querier submit their plaintext vector database and queries to the third party, which then performs the ANN search.

∗^{*}Corresponding author.

This work is licensed under the Creative Commons BY-NC-ND 4.0 International License. Visit https://creativecommons.org/licenses/by-nc-nd/4.0/ to view a copy of this license. For any use beyond those covered by this license, obtain permission by emailing info@vldb.org. Copyright is held by the owner/author(s). Publication rights licensed to the VLDB Endowment.

Proceedings of the VLDB Endowment, Vol. 20, No. 2 ISSN 2150-8097. doi:10.14778/3849423.3849440 and returns only the results to the querier. However, delegating all sensitive information in plaintext to a single, fully trusted entity may violate privacy regulations like GDPR and introduce severe risks of data breaches or misuse.

This motivates people to seek cryptographic solutions that can remove the need for trusted third parties. One natural solution is to implement ANN search in the secure multi-party computation (MPC) model [47]. In these solutions, the database owner and the querier secret-share the vector database and queries across multiple servers. The servers then jointly execute the ANN search protocol on these shares. The security of MPC ensures that no single server can reconstruct any input. Several recent efforts pursue this direction. However, most existing solutions either relax privacy guarantees by assuming a public database [50], or incur high computational overhead [11, 28]. Specifically, the two closest MPC solutions to our setting [11, 28] rely on cluster-based ANN pipelines: the database of size NN is partitioned into clusters, and the protocol identifies and searches the clusters most relevant to a query. Their efficiency depends heavily on the number of clusters, which is typically set to N\sqrt{N} to balance cluster selection and in-cluster search costs. As a result, their search time becomes O(N)O(\sqrt{N}) for each query. This quickly becomes impractical at modern database scales, because under MPC, each additional vector access incurs heavy communication, particularly for high-dimensional vectors. Earlier secure kNN works [34, 36, 38, 53] target smaller-scale or specialized two-party settings rather than scalable secret-shared ANN.

This motivates us to develop a more efficient MPC ANN protocol. The natural idea is to deploy a state-of-the-art hierarchical graph-based ANN algorithm, such as HNSW [32], under the MPC setting. By building a multi-layer graph index over the database, such algorithms enable efficient search: the query starts at the top layer, takes only a few steps per layer, and then moves to lower layers. It is widely accepted that, in practice, these indexes visit only O(log⁡N)O(\log N) out of NN vectors per query in expectation, where NN is the database size.

However, implementing this hierarchical graph-based search in MPC is very challenging. At a high level, we must make two parts of the algorithm oblivious: (i) the search logic, e.g., when to stop the search, and (ii) the access pattern. The stopping condition in HNSW is highly data- and query-dependent and replacing it with data-independent predicates without careful consideration totally compromises efficiency. For the access pattern, the search process may revisit the same node or vector multiple times, creating highly non-uniform and query-dependent memory accesses. Some naive approaches to hide such redundant access patterns, such as ORAM [18], would incur prohibitive communication overhead. Therefore, this naturally raises a fundamental research question:

References (31)