Manuscript Offprint
arXiv:2610.34248HNSecW: A Logarithmic-Time MPC Protocol for Approximate Nearest Neighbor Search
Fahong Zhang
Nanyang Technological University
Singapore, Singapore
Ning Luo
University of Illinois
Urbana-Champaign
Urbana, USA
Weijie Jin
Beijing University of Aeronautics and Astronautics
Beijing, China
Xiao Wang
Northwestern University
Evanston, USA
Lixu Wang
Nanyang Technological University
Singapore, Singapore
Wei Dong
Nanyang Technological University
Singapore, Singapore
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 time. We propose HNSecW, a novel MPC protocol for ANN search that achieves the 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 ( recall) and delivers over a 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 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 to balance cluster selection and in-cluster search costs. As a result, their search time becomes 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 out of vectors per query in expectation, where 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:
Table 1: Online costs for top-k ANN. Communication and round complexity for one query and sequential queries over vectors of dimension , with . hides polylogarithmic factors in and .
| Scheme | Single Query | Multiple Queries | ||
|---|---|---|---|---|
| Communication | Round | Communication | Round | |
| SANNS [11] | ||||
| PANTHER [28] | ||||
| HNSecW (Ours) | ||||
To achieve an oblivious access pattern, we combine offline random reshuffling with a duplicated vector database, yielding online overhead for each graph-index and vector access. Overall, our single-query MPC protocol achieves logarithmic online search complexity with at most a increase in vector storage. Moreover, we extend this design to support multiple queries. To handle repeated accesses across queries while avoiding additional online reshuffling, we introduce cross-query “double visited” structures that cache the graph nodes and vectors accessed by earlier queries, enabling later queries to reuse the cached information without revisiting the graph index and vector database. In summary, our results are as follows:
(1) Single query. For a single query, HNSecW achieves online searching complexity over a database of size . As Table 1 shows, HNSecW substantially outperforms state-of-the-art secure ANN baselines (SANNS [11], PANTHER [28]), whose clustering-based pipelines have online communication that scales as .
(2) Multiple queries. For sequential queries, we propose a multi-query protocol with an amortized cost of . Unlike schemes requiring reshuffling per query (e.g., PANTHER [28]), our protocol allows queries to share a single offline reshuffle, avoiding additional online overhead.
(3) Parallelism and batch queries. Additionally, we design parallel implementations of the above protocols: for the single-query protocol, the critical-path length is , and for the multiple-query protocol, it is . We also propose a batch-query protocol with higher parallelism that processes a batch of queries simultaneously with a much lower critical-path length of .
(4) Empirical evaluation. We conduct a comprehensive experiment on large-scale ANN benchmarks. HNSecW reaches recall over 0.9, matching the state-of-the-art plaintext ANN algorithm. At the same target recall, HNSecW achieves up to WAN speedup and less communication versus 2PC PANTHER; against the exact-top- 3PC SORT baseline, it achieves up to WAN speedup and less communication. All code is now available .
2 PRELIMINARIES
We introduce notation and background on ANN search, HNSW algorithm, secure multi-party computation, and oblivious RAM.
https://github.com/Kleenex-ultrasoft/Secure_ANN. Accessed: 2026-09-23.
Algorithm 1 SEARCHLAYER: Greedy search in HNSW layer
Input: Query , enter point ep, search width ef, layer
Output: Set W of ef closest neighbors to in layer
1: 2: 3: 4: while do 5: extract nearest element from C to 6: furthest element from W to 7: if then 8: break 9: for each do 10: if then 11: 12: furthest element from W to 13: if or then 14: 15: 16: if then 17: remove furthest element from W to 18: return W
2.1 Notation
Let be a dataset of vectors in , where is the dimension. We use to denote the -th coordinate of vector . Let denote a vector distance function. The index set is . For any set , is its cardinality. A graph has vertices and undirected edges . For any , denotes its neighbor set.
2.2 k-Nearest Neighbor Search
For the k-nearest neighbor (k-NN) problem, we have a dataset of vectors in and a query vector . The goal is to find the subset such that , and for any and any , it holds that . A straightforward approach is the linear scan, which computes the distance from to all vectors and maintains the smallest distances found so far, typically using a priority queue of size . The computational cost is , prohibitive for large-scale datasets (large ) or high-dimensional data (large ).
To address the cost, graph-based k-NN approaches have been proposed. These methods operate on a graph over the dataset , where each vector in is represented as a vertex, and edges connect pairs of sufficiently “close” vectors. Given a query , the search greedily traverses the graph from an initial node toward nodes closer to . A representative example is the Delaunay graph [13]. In the two-dimensional case, each node in the Delaunay graph has an expected degree of , and it guarantees that for any query , the exact nearest neighbor can be found in expected time [32]. However, moving towards the general case, the average node degree in the Delaunay graph grows exponentially in vector dimension with [13], making search impractical.
2.3 Approximate k-NN and Hierarchical Navigable Small World
Given that existing k-NN search algorithms are infeasible for large-scale, high-dimensional data, where both linear scan and ideal graph-based methods are prohibitively expensive, a practical trade-off between accuracy and efficiency is necessary. Consequently, people have proposed the Approximate k-NN (ANN). In ANN, instead of returning the exact nearest set , the goal is to find an approximate set that meets a target Recall , defined as Recall( ) = . Over the years, various families of ANN methods have been developed, including hashing-based, tree-based, and quantization-based approaches. Among them, Hierarchical Navigable Small World (HNSW) [32], achieves state-of-the-art query performance for high-dimensional data [32].
The core of HNSW is a multi-layered graph structure , where each layer denotes a graph whose nodes correspond to vectors in the dataset . The layers form a sequence of nested subsets of : . The number of nodes decreases geometrically from bottom to top, resulting in layers. The edges are constructed from the nodes' underlying vector representations, and each serves as an out-degree bound approximation of a Delaunay graph. This hierarchical graph is an efficient index for the vector database . Its design enables a two-phase search strategy: upper, sparser layers support coarse-grained navigation, ensuring high search efficiency, while lower, denser layers provide fine-grained refinement, ensuring high search accuracy.
For query , HNSW starts at a random entry point in the top layer . Each layer search locates the locally closest node to , which becomes the entry point for the next lower layer. After searching the base layer , the algorithm returns the nearest neighbors of from all visited nodes. To implement this idea, at each layer the search maintains three data structures: a candidate set , which stores potential nodes for further exploration; a result set , which stores the closest nodes found so far, where with for non-base layers and for the base layer; and a visited set , which records all visited nodes to prevent revisits.
All these data structures are initialized with the entry point ep, and the search then proceeds iteratively. At each iteration, we extract the nearest candidate c from C, explore each unvisited neighbor e of c, and add them to V. If e is closer to than the farthest node in W, it is inserted into both C and W, and W is kept at size at most ef. The search terminates when no candidate in C is closer to than the farthest node in W, or when C becomes empty. Algorithm 1 gives the detailed procedure.
We abstract HNSW into three key components: the search logic flow, the data structures, and the graph and vector access. The logic flow specifies how the search proceeds within each layer. In each step, it moves to the nearest candidate node and then explores all its neighbors. The search stops when no candidate is closer to the query than the current results. The data structures support this process. At each layer, the algorithm maintains three sets: a candidate set C, a result set W, and a visited set V. Finally, the logic flow interacts with the underlying graph index and vector database. For each candidate c, the search first accesses the graph index to retrieve its neighbor list, then accesses the vector database to obtain these neighbors' vectors for distance computation.
2.4 Secure Multi-Party Computation
Secure multi-party computation (MPC) enables multiple parties to jointly compute a function over their private inputs while only revealing the output to designated parties [47]. We use secret-sharing MPC protocols where, for each intermediate value x, all parties hold its secret sharing denoted as . The security ensures that the adversary cannot learn the value even when corrupting some number of parties as allowed by the threat model. Our system treats MPC protocols as black boxes; thus, we describe computation directly over secret shares. In particular, we use and to denote addition and multiplication in MPC over secret-shared values. Typically, given network bandwidth BW and round-trip time RTT, MPC protocols follow this online latency model:
Here, Computation is each party’s local, non-interactive work and is often almost free. Communication is the total data exchanged and scales linearly with the multiplication gate count. Round is the number of sequential interaction steps, determined by the circuit’s multiplicative depth.
Making Algorithms Oblivious. Under MPC, oblivious execution has three requirements:
(1) Logic flow. For fixed public parameters, the algorithm follows the same sequence of operations. For example, each loop runs for a fixed number of iterations.
(2) Data structures. For fixed public parameters, intermediate data structures have the same sizes and update schedule.
(3) Data access pattern. For fixed public parameters, physical-address sequences are indistinguishable across private inputs.
Oblivious Access in MPC. Among these requirements, oblivious data access has been widely studied as a general primitive. MPC protocols based on secret-sharing can typically support any circuit, but random accesses are expensive to represent as circuits. To support private accesses on large arrays without incurring a cost linear to the array, one would need to use an Oblivious RAM (ORAM) [18] by executing the ORAM client in MPC [19]. This protocol is also called Distributed ORAM (DORAM). Given a secret-shared array and secret-shared index , DORAM enables parties to jointly compute (the secret-shared value at secret-shared position) without revealing the index or the value to any party. DORAM has been optimized in different ways, including circuit-based minimization (e.g., [44]) and protocol-level adaptation (e.g., [14]). Although the most efficient construction can achieve communication overhead [39], DORAM still incurs an computational cost. Moreover, DORAM accesses are stateful and often sequential, making batched accesses difficult to parallelize. Therefore, rather than directly adopting generic DORAM in our MPC protocol, we propose a specialized algorithm to implement an oblivious access pattern.
Security Models. Beyond these requirements, oblivious algorithm design also depends on the security model. For secure ANN, we distinguish four models based on who has plaintext access to each input and who performs the search, from general to specific:

Figure 1: System overview of Oblivious HNSW
(1) Symmetric MPC. The computation parties have no access to the database, index, or query in plaintext. They perform the search over secret values. This is also the standard setting in the MPC literature. Our paper targets this model for data collaboration between untrusted organizations and computation outsourcing by a single data owner.
(2) Client-server search. The client has plaintext access to the query, while the server has plaintext access to the database and index. They jointly perform the search without learning the other's input beyond the result. SANNS and PANTHER follow this model [11, 28].
(3) Storage outsourcing. The client has plaintext access to the database, index, and query. It encrypts the database and index and then outsources them to an untrusted server. During search, the client retrieves data from the server and performs the search locally. Compass follows this model [51].
(4) Query-private search. The client has plaintext access to the query. The database and index are public and stored on the server, so both the client and server have plaintext access to them. During search, the client retrieves database and index entries from the server and searches locally. Thus, only the query is hidden from the server. Pacmann follows this model [50].
3 SYSTEM OVERVIEW
We consider a private HNSW search involving two input-holding parties and a set of MPC servers; Figure 1 gives the high-level architecture. The two input parties are: (1) the database owner (DO), who holds a private vector dataset together with an HNSW graph index built over , and (2) the Querier, who holds the private query vector . DO and Querier are two logical parties who do not need to trust each other, but they could be instantiated as the same physical party, in which case the protocol reduces to the standard outsourced computation model. The functionality of the protocol is shown in Figure 2.
3.1 Threat Model
We assume a semi-honest, probabilistic polynomial-time (PPT) adversary who may corrupt at most t MPC servers and one or both input parties. Our protocol achieves standard simulation-based security [7]. For any PPT adversary corrupting at most t MPC servers and one or both input parties, there exists a PPT simulator whose output is computationally indistinguishable from the adversary's output, using only the corrupted parties' inputs, their outputs under
| Functionality |
|---|
| Public Input: .Inputs: , and Compute: Upon receiving (dataset, ) from DO, and (query, ) from Querier, where is an HNSW graph, compute Outputs: Upon receiving (continue) from all servers, send to Querier. |
Figure 2: Ideal functionality for securely computing HNSW.
Table 2: Public parameters of the system.
| Category | Public Parameters |
|---|---|
| Data characteristics | Vector dimension ; Dataset size ; Number of layers ; Degree bound ; Per-layer sizes |
| Search hyperparameters | Result set size ; Nearest neighbor output size |
| Multi/Batch-query setting | Number of queries |
, and the public parameters. We provide the full proofs in the extended version [49]. Table 2 summarizes the public parameters.
The ideal functionality and the threat model imply symmetric privacy and correctness. For query privacy, the database owner and all MPC servers learn nothing about beyond what is implied by the public parameters. For database privacy, the querier and all MPC servers learn nothing about or beyond the top- result vectors output by and what is implied by the public parameters. For correctness, for any inputs , the Querier reconstructs the output of the ideal functionality .
3.2 Single-Query
Even when all vectors and their distance to the query are kept secret, a single HNSW query is not oblivious in its control flow, data structures, or graph and vector access patterns, all depending on the underlying graph and query. Achieving obliviousness to prevent leakage requires a dedicated analysis of the performance features that HNSW presents, since a generic method that follows only worst-case conditions would introduce prohibitive overhead. In our protocol, we design customized optimizations to make each part oblivious by taking advantage of its unique features. For a single query, we traverse each layer without revealing the access pattern. At every layer, we use our oblivious data structure to maintain the search state, and we terminate the traversal using a tailored termination condition that prevents information leakage. We outline the key ideas here, with full details in Section 4.
-
Control flow. We eliminate data-dependent stopping conditions by replacing them with a fixed iteration bound derived from a detailed analysis of HNSW's stopping behavior, ensuring obliviousness with only negligible recall loss (Section 4.1). Although there is no theoretical bound on the iterations, we found that in the specific context of RAG, we could set a tight upper bound on the number of iterations without degrading the end-to-end performance.
-
Data structure. We observe that both the candidate set and the result set exhibit a monotonic exclusion property: once a node is excluded, it will not be included in these sets again. Using this monotonicity, we design an oblivious data structure for both sets that keeps them at a fixed size and removes farther nodes through fixed-size tail truncation after oblivious sorting (Section 4.2).
-
Graph and vector access pattern. We use the fact that HNSW naturally avoids revisiting a node more than once per layer. To further reduce redundant access across the layers, we assign each layer an independently shuffled graph and vector tables so every address is accessed at most once, yielding fully oblivious access patterns.
3.3 Multiple-Query
Extending the single-query protocol to multiple queries introduces a fundamentally new challenge: different queries may revisit the same graph node and its associated vector. Hiding these repeated visits would require reshuffling the graph and vector tables after every query. However, such per-query reshuffling is impractical in an online setting due to the significant latency it entails. To address this, we rely on the insight that once data has been accessed, it can be cached and reused across queries rather than accessed repeatedly. We propose to use two global cross-query visited structures, one for graph neighbor lists and one for vector contents. These structures serve as a secure shared cache: once any query retrieves a node or vector, it is stored in the global visited array. Subsequent queries check this array first and reuse the cached data. As a result, each graph or vector access first scans the cache and then performs a real or dummy data-access step. Under this design, every node and vector is accessed at most once from the underlying shuffled tables globally, while subsequent revisits are served through oblivious cache scans. Combined with one-time random pre-shuffling, this keeps the overall access pattern oblivious; see Section 5.
3.4 Parallel-Enhanced Batch Model
Furthermore, we consider how the oblivious HNSW search can be executed in parallel. The single-query protocol already exhibits high parallelism, but its multiple-query extension is designed to process the queries sequentially, giving a linear circuit depth of . In a batch setting where many queries are available simultaneously, it is natural to ask whether the computation can be reorganized to reduce this depth to better exploit parallel execution. As in the multiple-query setting, the fundamental challenge is to avoid accesses to the same nodes and vectors across queries. A naive approach is to cache every accessed element (neighbor lists and vectors), as in the sequential protocol. But in the batch setting, such a large cache is unnecessary. Our key insight is that, because all queries proceed in synchronized iterations, we do not passively wait for cache hits and reuse; instead, we force accessed vectors to be evaluated against queries: if a query later needs that vector, it can skip the inner path; if not, the extra evaluation does not affect correctness. This eliminates the need for a massive cache and naturally prevents redundant accesses. As a result, the batch-query protocol achieves a depth of , coming from the oblivious duplicate removal of the neighbors per iteration plus the HNSW layers.
3.5 Implementation & Experiment Summary
We implement HNSecW in two MPC configurations: 2PC in ABY [12] and 3PC in MP-SPDZ [25]. We evaluate on 10 ANN benchmarks at M=128 (SIFT-1M, GIST-1M, DEEP-100M, BIGANN-1B, DEEP-1M, DEEP-image, MNIST-60K, Fashion-60K, SPACEV-1B, SSNPP-1B) [4, 23, 26, 37, 45], spanning N from 60K to 1B and . Experiments are conducted under LAN (4000 Mbps, 1 ms RTT) and WAN (320 Mbps, 50 ms RTT). On accuracy, HNSecW delivers Recall@k 0.9 for at least 95% of queries across the full evaluated range of . On performance, HNSecW outperforms existing work on WAN 2PC by up to 22× in end-to-end latency and 46× in communication.
4 SINGLE QUERY PROTOCOL
As discussed in Section 2, we decompose HNSW search into three components: the search logic flow, the data structures, and the graph/vector access patterns. In this section, we briefly outline how to make each component oblivious. Section 4.1 makes the control flow data-independent by replacing the original data-dependent stopping conditions with a fixed iteration bound. Section 4.2 redesigns the visited, candidate, and result structures as fixed-size arrays with uniform update rules. Section 4.3 ensures oblivious graph and vector access by avoiding repeated retrievals through per-layer reshuffled tables. Finally, Section 4.4 assembles these building blocks into the complete oblivious single-query protocol.
4.1 Making Logic Flow Oblivious
We first make HNSW’s search logic flow oblivious. At each layer, original HNSW iteratively finds the nearest candidate node and explores all its neighbors. The logic flow is inherently data-dependent.
The first source of data dependence is varying node degrees: exposing this variation would leak information about the graph and query. Fortunately, this dependency is easy to remove. Since HNSW enforces an out-degree upper bound M per node, we pad each node's neighbor list with randomly selected nodes from the same layer to obtain a fixed length of M. This padding does not reduce search quality: all real neighbors remain available for selection.
The more subtle challenge lies in the termination condition. In HNSW, the search stops when no better candidate remains (line 7-8 in Algorithm 1), or when the candidate set becomes empty (line 4 in Algorithm 1). Both conditions are inherently data-dependent. At first glance, this seems similar to the bounded-degree case, since the original HNSW paper [32] suggests that each layer can be traversed in a constant number of hops. One may use that constant as a fixed upper bound and pad execution with dummy searches. However, unlike node degree, this constant is not a worst-case bound; it arises from an expected-case analysis in [32] that assumes each layer forms a perfect Delaunay graph [13]. Real HNSW layers only approximate such structures, so the constant-hop guarantee does not hold in general. In fact, the best-known asymptotic bound for HNSW on arbitrary data is still . A practical, data-independent iteration bound must therefore be derived from the actual termination behavior.
The first termination condition (lines 7–8 in Algorithm 1) triggers when the closest candidate can no longer improve the current result set. This can only happen after ef search steps. Since every

Figure 3: Base-layer on the 10 datasets (M=128) with 95% recall 0.9 over queries.
node inserted into W is also inserted into C, every node in the final W must have been popped from C and explored (i.e., cannot remain in C); otherwise, it would stay in C and lead to , contradicting the stopping condition. Hence, letting s denote the number of search steps performed by standard HNSW at a given layer, we always have and can write exact search steps as , where residual captures work beyond the ef steps. Therefore, to make the termination condition oblivious, a natural approach is to fix the number of search steps at each layer. Specifically, for each layer , we set the number of search steps to , where is a public upper parameter to bound the residual term and depends only on public quantities such as N, d, and M. Below, we present our strategy for setting and , both bounded by logarithmic terms, and show the resulting procedure performs robustly in practice. However, designing termination strategies for HNSW that balance accuracy and efficiency remains an active research topic even in the non-private setting [8], and is not the main interest of this paper. Future termination strategies can also be integrated into our framework. Moreover, we highlight that, as long as the number of search steps increases by at most a logarithmic factor, our final complexity guarantee remains unchanged.
We begin with the choice of . Standard HNSW [32] sets in all upper (non-base) layers, while treating the base-layer value as an input parameter. We now discuss how to set at the base layer. To this end, we run HNSW with five values of on 10 ANN datasets spanning 60K–1B points and dimensions 96–960, using queries per dataset. For each test, let denote the smallest base-layer value of that achieves recall at least 90%. Figure 3 reports the 95% quantile of over these 50K tests. For all , the offset is at most 10 in at least 95% of the tests. Therefore, we set throughout our experiments, except in the ablation study on .
After fixing , we discuss how to set . One natural idea is to set to one empirical constant across all layers. We validate this strategy in the same 50K experiments by counting the residual steps required by standard HNSW under the above strategy for . Figure 4 shows the results.
The results show that the residual steps are well bounded by a constant in the upper layers, but are substantially larger at the base layer. We therefore use an enhanced strategy. For upper layers, we set to a constant C. For the base layer, we use the observation from recent work on early termination in HNSW [8, 9] that, after the first ef steps, the probability of not having terminated decays geometrically with the number of additional steps. We therefore

Figure 4: Per-layer residual at , , , on the 10 datasets. The bottom row of each panel shows the base-layer step count minus .
add a logarithmic term in , , and at the base layer: . In our experiments, we set , which covers more than 95% of cases across the 50K tests.
We therefore apply this fixed-step rule: search steps at each upper layer and at the base layer. Since may be larger than the actual number of residual steps, and since the second termination condition in line 4 of Algorithm 1 may trigger early termination, the search may otherwise stop before completing steps. In this case, we continue the search using dummy nodes. When dummy nodes are treated as candidates during the search, they are assigned sentinel distances that rank worse than all real candidates, and thus never affect the result set W. Overall, our strategy yields an oblivious search procedure. Here, the number of search steps is at each upper layer and at the base layer. Since HNSW has layers, this gives a total of search steps per query.
4.2 Making Data Structures Oblivious
We next make the data structures of HNSW oblivious. Recall that each layer individually maintains three structures: the visited set V, the candidate set C, and the result set W. However, the sizes and update frequencies of the three sets are inherently data- and query-dependent during search. We therefore redesign them into oblivious counterparts.
4.2.1 Oblivious Result Set W. The result set W is easier to make oblivious than C and V because original HNSW already bounds its size by ef. The only data-dependent behavior is the conditional insertion rule, i.e., inserting a node into W when it improves the current ef results and passes the visited check (line 13 in Algorithm 1). We remove this data-dependent condition by obliviously considering every node for insertion, at a cost of per node. Overall, this naive approach costs in each iteration. For practical efficiency, we instead insert all M elements, apply oblivious sorting, and then reduce the size back to ef, incurring only complexity. Since is much smaller than M in our setting, this approach outperforms the naive alternative in practice.
4.2.2 Oblivious Visited Set V. The visited set V records explored nodes to prevent later revisits. In the original HNSW, V is a dynamic set whose size and insertion pattern are both query- and data-dependent, since nodes are inserted only when first encountered and their growth is unpredictable. To eliminate this dependence, we observe that V can safely contain duplicate nodes. We therefore replace the set, whose size is unpredictable, with a list whose size increases by exactly one after each exploration. More precisely, each iteration appends all M neighbors, regardless of whether they have appeared before, so that V contains exactly entries after T iterations. A full linear scan of this list performs a visited check at a cost of , which is scalable and independent of N.
4.2.3 Oblivious Candidate Set C. The candidate set C stores the nodes awaiting expansion and is also a fully dynamic set. In the original HNSW, its size is inherently data-dependent: each iteration extracts one node from the set but may insert zero, a few, or up to M new nodes. The insertion condition is also data-dependent, since neighbors are added to C only when they pass the visited check and could improve the result set W (line 10, 13 in Algorithm 1). To make C oblivious, we leverage the fixed iteration T established in Section 4.1. Since at most T candidates will be extracted, entries beyond the top-T positions cannot be used and need not be retained. We therefore replace the dynamic set with a fixed-length array of size T. In every iteration, all M neighbors, whether real or dummy after the visited check, are appended to C. We then perform an oblivious sort by distance and retain only the top-T entries. As we discussed earlier, since dummy nodes carry a maximum distance , they always expand to other dummy nodes. They cannot influence the result set W even if they are selected after the real nodes are exhausted in C. This fixed-size and fixed-update design of C eliminates data-dependent behavior while preserving original HNSW's functionality.
4.3 Making Access Patterns Oblivious
The HNSW search process involves two types of data access: vector access and graph access. During the search, a node first incurs a vector access where its distance to the query is evaluated. If the node is later selected for expansion (extracted from the candidate list C), it then incurs a graph access to retrieve its neighbor list. A straightforward way to make both accesses oblivious is to store the graphs and the vector database in DORAM. However, this incurs significant overhead, as each access requires time.
To design a more efficient solution, we recall that achieving oblivious access requires two properties: data anonymization, which can be easily achieved through pre-shuffling, and non-repetitive access, where no address is revisited within a query. In this single-query setting, we assume that both graph and vector data have been anonymized through offline reshuffling. Therefore, if each item is retrieved at most once, the access is oblivious. We now analyze where repeated accesses arise and how to avoid them.
Within a single layer, both graph and vector accesses are non-repetitive. The visited set prevents revisiting any node, so its neighbor list and its vector are retrieved at most once. Across layers, the search may revisit a logical node because each layer builds a separate, increasingly refined neighborhood structure, and the same node provides different information at each layer. So its data
One could reduce this to using more sophisticated oblivious algorithms [1], but these become advantageous only when ef is very large ( ), which is far beyond our setting.
may be reused along the search path. For graph access, this causes no address repetition: each layer stores its own graph with independently reshuffled addresses, so expanding the same logical node in different layers always reads unrelated locations. For vector access, however, standard HNSW implementations keep all vectors in one global table for space and cache efficiency, so re-evaluating a node across layers hits the same physical address. To avoid this, we assign each layer its own independently reshuffled vector table of size . Notably, within a single layer, the graph and vector tables are reshuffled independently, so a node's graph and vector entries occupy unrelated physical addresses, avoiding graph-to-vector transitions by reusing an address. With this per-layer duplication and independent reshuffling, both graph and vector access become fully non-repetitive.
4.4 Put It All Together
We now integrate the oblivious control flow, data structures, and access patterns into a complete single query HNSW protocol under MPC. Here, we first describe how the per-layer data is represented and secret-shared. At each layer , the data owner provides two tables: a graph table containing neighbor lists as the HNSW index and a vector table containing the node vectors. Both tables are padded with dummies, where is for visited check, while is for initialization of and . After padding, MPC parties secret-share and jointly reshuffle the tables offline. Each graph table entry stores neighbors' vector-table addresses, , where would return the -th neighbor's vector and auxiliary information. Each vector table entry is , where is the node's vector; is the graph table address of the nodes; is the address of the same vector in (used during layer transition); and is the dummy entry flag. We collect all dummy vector addresses in a pool .
During the search, MPC parties jointly maintain three fixed-size arrays at each layer: , and . Here stores the vector-table addresses of visited nodes; stores the graph-table addresses and distances of candidate nodes; stores the vector-table address , the lower-layer vector address , and the distance of the current top-ef results nodes.
With the oblivious data structures in place, Algorithm 2 specifies the per-layer search, which runs a fixed number of iterations and updates V, C, and W obliviously. The full single-query protocol (Algorithm 3) applies this layer search from the top layer to the base. At the base layer, stores only vector-table addresses for efficient oblivious sorting; the actual vectors are fetched from an auxiliary reshuffled table . Since the base layer may place dummy addresses among the top-k when k is large, is padded with dummy entries containing application-safe vectors so that dummy outputs remain indistinguishable from real ones.
4.4.1 Security Sketch. Throughout the protocol, the query, the graph and vector tables, and the search state remain secret-shared. For fixed public parameters, each query runs the same number of iterations and updates the fixed-size arrays V, C, and W in the same way. Thus, the logic flow, data-structure sizes, and update schedule do not depend on private inputs. The graph and vector tables are
Algorithm 2 OBLIVIOUSSEARCHLAYER: Oblivious layer search
Input: Query , entry point , search width , slack , degree bound , layer (per-layer tables , DUM accessed implicitly)
Output: Set of closest neighbors to in layer
1:
2: initialize visited array dummy graph address
3: initialize candidate array
4: initialize result array
5:
6:
7:
8:
9:
10: for to do
11:
12: shift left by one position
13:
14:
15: for to do
16:
17: visited LINEARSCAN( )
18: dummy DUM
19: SELECT(visited, dummy, )
20:
21: mask visited
22: SELECT(mask, , dist( ))
23:
24:
25:
26: OBLIVIOUSSORTTRUNCATE( )
27: OBLIVIOUSSORTTRUNCATE( )
28: return the first entries of
padded and randomly reshuffled before the search. Each lookup accesses a distinct physical address. The observed access sequence is therefore a random sequence of distinct addresses. Thus, the protocol securely realizes the ideal functionality in Figure 2. See the extended version for the full proof [49].
4.4.2 Complexity Analysis. We analyze the online complexity of the single-query protocol. At the base layer, we set and run iterations. Each iteration performs: distance evaluations in ; oblivious scans over a list of size ; the oblivious sort network evaluation on and , each of size . Over iterations, both communication and local computation are . For non-base layers, with , the cost becomes . Therefore, a single oblivious HNSW query has communication and local computation costs .
5 MULTIPLE QUERY PROTOCOL
In this section, we extend the single-query protocol to support U queries. Recall that the single-query protocol searches obliviously over tables pre-shuffled offline. A naive approach for U queries is to run the single-query protocol U times, reshuffling the tables after each query, but this incurs prohibitive online costs due to the additional reshuffles. We therefore aim to answer all

(a) Oblivious logical flow: upper-bounded termination
Initial with entry node
Step 1
(b) Oblivious Access Pattern
Step 2

Initial with dummy node
Step 3
Step 4
(c) Oblivious data structures
Figure 5: Overview of Oblivious HNSW. (a) Each layer runs exactly steps for data-independent termination. (b) Per-layer replication and reshuffling hide cross-layer access patterns. (c) Oblivious data structures maintain the HNSW search state.
Algorithm 3 OBLIVIOUS SINGLE QUERY: HNSW single query
Input: Query ; top-layer entry ; tables and ; params ; result count .
Output: Top- nearest neighbor vectors of .
1:
2: for to 1 do
3:
4:
5:
6:
7: Reveal in top- vector addresses in additional table
8: Fetch final top- vectors
9: Reconstruct to Querier
10: return
U queries using a single shuffled HNSW index with no further online reshuffling. To achieve this, we propose using two global cross-query visited structures, one for graph nodes and the other for vectors, so later queries can safely reuse previously accessed information without re-accessing the underlying tables.
5.1 Double Visitor Arrays
The challenge in the multiple-query setting is that later queries may need to access nodes and vectors that earlier queries already accessed. As noted above, the single-query protocol prevents repeated data access with an array V tracking previously accessed nodes. Moving to the multiple-query setting, one straightforward idea is to simply make V global, so that each node can be accessed by only one query. However, queries may have overlapping search paths, so simply globalizing V would make multi-query HNSW search incorrect.
To address this issue, we propose two global cross-query caches recording all nodes and vectors accessed so far. Specifically, we maintain a graph-side visited set and a vector-side visited set , which store the neighbor information of visited nodes and the contents of visited vectors, respectively. When exploring a node v in graph , we first check whether . If so, the neighbor information of v is retrieved from , followed by a dummy graph access. Otherwise, v and all its neighbor information are read from and stored in for future use. After obtaining the neighbor information, we access each neighbor's vector to compute its query distance. Similarly, for each vector access, we first check . If the vector is already present, it is retrieved from , followed by a dummy vector access. Otherwise, it is loaded from and appended to . Moreover, before processing multiple queries, we pre-shuffle both the graphs and the vector databases so that all nodes and vectors, including dummy ones, remain anonymous. More precisely, for each graph access, we first perform a linear scan of . Then, depending on whether the target node is already in the cache, we access either the real node or a dummy node in the graph. Finally, we access again to store the newly retrieved real node or a dummy entry. Notably, we generate dummy nodes so that each graph access can use a different dummy node. Similarly, for each vector access, we first scan , then access either a real or dummy vector, and finally store it in .
5.1.1 Security Sketch. The multi-query protocol extends the single-query protocol with cross-query caches for repeated graph and vector accesses. We explain why this extension remains oblivious. To hide whether a lookup hits a cache, both cases follow the same fixed schedule. With this design, the control flow is identical for every graph access. Regarding the access pattern, all nodes, including dummy nodes, are accessed at most once, thereby guaranteeing non-repetitive access. In addition, the graph is pre-shuffled to ensure data anonymization. By the same argument, these vector accesses are also non-repetitive and data-anonymized, and hence oblivious. Thus, the multi-query protocol securely realizes sequential invocations of the ideal functionality in Figure 2. The full proof is in the extended version [49].
5.1.2 Complexity Analysis. For queries, at the base layer we keep and run iterations per query. Each iteration performs: distance evaluations in ; oblivious scans over and of size ; and two oblivious sort network evaluations over and , each of size . Thus, both communication and local computation costs at the base layer are , and for the non-base layers with they are . Therefore, the multiple-query protocol has total communication and local computation costs .
6 BATCH QUERY PROTOCOL IN PARALLEL
The preceding multiple-query protocol processes queries sequentially. We further consider the batch setting, where queries arrive together. We propose a batch protocol that processes the queries in parallel, reducing the round complexity from to .
The key idea is to share vectors fetched by any query across all queries, so every query steps forward together by updating its own and . Each iteration has two stages. First, the protocol obliviously deduplicates the nearest candidate from each query's , replaces duplicates with dummies, and issues distinct graph accesses. Second, it obliviously deduplicates the returned neighbor IDs and fetches vectors. Each query evaluates its distance to all fetched vectors, regardless of which query requested each vector. The batch therefore performs distance evaluations in parallel. These distances update the query's own candidate set and result set . The protocol records all fetched vectors in one global visited array shared by all queries. Each of the two oblivious deduplication steps sorts elements, requiring an oblivious sort network of depth , which determines the per-iteration round cost. The full algorithm and the round-complexity proof appear in the extended version [49].
7 EVALUATION
In this section, we empirically evaluate HNSecW and aim to answer the following questions:
-
Search quality. What search quality does HNSecW achieve, and how does it perform when integrated into downstream RAG?
-
Overhead. What computation and communication overhead does HNSecW incur, and how does it perform against state-of-the-art secure ANN constructions?
Table 3: ANN datasets used in our evaluation [3, 37].
| Dataset | N | d Metric | Dataset | N | d Metric |
|---|---|---|---|---|---|
| SIFT-1M | 128 | DEEP-image | 96 Cos. | ||
| DEEP-1M | 96 | DEEP-100M | 96 | ||
| GIST-1M | 960 | BIGANN-1B | 128 | ||
| MNIST-60K | 784 | SPACEV-1B | 100 | ||
| Fashion-60K | 784 | SSNPP-1B | 256 |
7.1 Experimental Setup
MPC Backends. HNSecW can be instantiated with any semi-honest MPC protocol tolerating corruptions among servers. We evaluate two common configurations:
-
Semi-honest 2PC (). Our 2PC uses ABY's semi-honest mixed-protocol backend [12]. Arithmetic sharing handles distance computation. Boolean sharing handles visited checks. Yao's garbled circuits handle comparisons, sorting, and candidate updates. ABY provides secure conversions among these representations.
-
Semi-honest 3PC (). Our 3PC uses MP-SPDZ's semi-honest replicated secret-sharing protocol over a 64-bit ring [25].
Hardware and Network Environment. All experiments run on a single server with an AMD EPYC 9554P CPU (64 physical cores, 3.1 GHz) and 565 GB of RAM, where each MPC party runs as a separate single-threaded process. We emulate two networks: a LAN with 4000 Mbps bandwidth and 1 ms RTT (a standard MPC LAN setting [11, 28]), and a WAN with 320 Mbps bandwidth and 50 ms RTT, following typical U.S. East–West latency per cloudping.co .
Datasets. We evaluate on 10 widely-used ANN benchmarks [3, 37] (Table 3), spanning , , and both and cosine metrics. The selected scale range covers the practical RAG deployment regime. Due to space limitations, the main text reports four representative datasets covering both scales (SIFT-1M, GIST-1M, BIGANN-1B, DEEP-100M); results for the remaining six datasets are provided in the extended version [49]. All recall experiments use queries per dataset and report the 95th percentile.
Comparison Baselines. As Section 2.4 explains, existing secure ANN protocols target different security models and thus provide no direct baseline for our symmetric MPC setting. PANTHER [28] is a notable exception: like our protocol, its search algorithm is fully oblivious. However, under its client-server setting, the client accesses the plaintext query and the server stores the plaintext database, enabling lightweight PIR and distance computation between encrypted queries and plaintext vectors by ciphertext–plaintext multiplications. We adapt PANTHER by replacing PIR with DORAM [16] and computing distances by ciphertext–ciphertext multiplications. This adds overhead but preserves its search algorithm. We compare the asymptotic performance of PANTHER's cluster-based search and our graph search under the same security model. Figure 9 reports PANTHER's original cost and the adaptation overhead separately. Pacmann [50] is another related graph-based ANN algorithm for query-private search, but it assumes a public database and graph index, with the client retrieving entries through PIR and searching locally in plaintext. Although PIR can be replaced with DORAM, securely realizing local search would require a complete
https://www.cloudping.co/. Accessed: 2026-09-23.

Figure 6: Deployed recall of HNSecW ( , from Section 4.1). Left: the recall achieved by at least 95% of queries. Right: fraction of database vectors visited at top-10. PANTHER is omitted on BIGANN-1B because current DORAMs [14, 16, 39] cannot fit its cluster in one block.

Figure 7: Per-query Recall@10 distribution at the deployed setting (1000 queries each).

Figure 8: ablation at M=128. Each panel sweeps ; the star marks our setting from Section 4.1. “probe sweep” is PANTHER’s cluster-probe count .
MPC-based ANN protocol. This is precisely the problem we address. Adapting Pacmann to our setting would be essentially equivalent to implementing our MPC algorithm. For this reason, we do not include it as an experimental baseline. For 3PC, we use replicated radix sort [1] as the exact top-k baseline with Recall@k=1.
7.2 Search Accuracy and RAG Quality
Search Recall and Distribution. At the deployed setting (M=128, , with from Section 4.1), HNSecW delivers recall for at least 95% of queries on every dataset and k, with the 95th-percentile climbing from at k=10 to at k=100, as shown in Figure 6. PANTHER, by contrast, holds Recall@k for 95% of queries but its 95th-percentile peaks early near k=20 and drifts back toward 0.80 at k=100: its fixed cluster-probe budget cannot absorb the larger candidate set demanded by larger k,

Figure 9: HNSecW's single-query cost and ablation across the four datasets. In adapted PANTHER, BIGANN-1B exceeds the DORAM [14, 16, 39] block-size limit.

Figure 10: Amortized WAN performance of multiple and batch queries with the offline reshuffle.
while HNSecW's fixed-step rule scales with and pushes the worst-case recall up. HNSecW also visits to fewer database vectors than PANTHER as grows from to (the range where PANTHER runs), reflecting the log vs. scaling of graph-based vs. cluster-based ANN search. Figure 7 shows the per-query distribution at the deployed setting: of HNSecW's queries land at Recall@10 on every dataset, with 45–60% reaching perfect recall, while PANTHER concentrates of mass at but only 30–38% at perfect recall. To verify the robustness of the prescribed step parameter, we ablate for HNSecW in Figure 8. Recall on every dataset saturates near the deployed from Section 4.1: shrinking the offset to drops recall sharply, while doubling it to or buys little extra recall at materially higher WAN latency. PANTHER's recall also rises
Table 4: End-to-end RAG quality on HotpotQA queries. At our setting: , HNSecW matches the HNSW baseline.
| No retrieval | HNSW | HNSecW | ||||||
|---|---|---|---|---|---|---|---|---|
| C=1 | C=3 | C=5 | C=7 | C=9 | C=11 | |||
| EM (%) | 22.4 | 66.2 | 56.8 | 63.5 | 65.2 | 66.0 | 66.1 | 66.2 |
| F1 (%) | 31.5 | 81.5 | 70.2 | 78.5 | 80.6 | 81.3 | 81.4 | 81.5 |
with the cluster-probe count . We further ablate the graph degree across all 10 datasets in the extended version [49]; the WAN advantage holds throughout the sweep. End-to-end RAG Quality. We evaluate end-to-end RAG on 200 multi-hop queries sampled from HotpotQA [46] with retrieval over the 1M-document MS MARCO passage corpus. Queries and documents are embedded with intfloat/e5-large-v2 [41], we retrieve the top-10 passages, and Qwen2.5-7B-Instruct [33] generates answers, with Exact Match and token-level F1 as metrics. We sweep in Table 4 to characterize RAG quality as varies. It shows that HNSecW matches the standard HNSW at and larger gives negligible improvement, so our termination strategy in Section 4.1 achieves similar RAG quality to standard HNSW.
7.3 Efficiency of HNSecW
We next compare HNSecW's efficiency and scaling for single, multiple, and batch queries.
7.3.1 Single-Query Scenario. We first examine single-query cost on the four datasets, shown in Figure 9. In 2PC, HNSecW is faster than PANTHER on WAN and reduces communication by (excluding BIGANN-1B, where existing DORAM cannot fit a PANTHER cluster; see Figure 9 caption). The gap widens against SORT in 3PC, reaching to on WAN and to in communication. The ablation in the bottom row of Figure 9 decomposes WAN time and Communication into Secure distance, Visited check, and Oblivious sort. WAN is round-dominated, since Visited check and Oblivious sort account for to . The Secure distance share rises with , from about at DEEP-100M () to about at GIST-1M () under 2PC. This share is smaller in 3PC because replicated sharing reduces distance-computation overhead. For Communication, distance bytes dominate at high , reaching about on GIST-1M 2PC, while Visited check and Oblivious sort take larger shares at low .
We further check whether HNSecW keeps its WAN advantage across the ablation in Figure 8, which plots WAN 2PC latency against top-10 recall. At the same recall, HNSecW's 2PC WAN curve sits below PANTHER's sweep on every dataset where PANTHER runs across the full sweep, so the WAN advantage is robust to the choice of .
7.3.2 Multiple- and Batch-Query Scenarios. We sweep under WAN and report per-query amortized latency and communication in Figure 10, combining online search with offline reshuffle divided by . At small the reshuffle dominates; as grows its share falls linearly while the online share grows slowly, so the amortized total drops toward the online floor. HNSecW crosses below PANTHER once amortizes the offline cost. The batch variant starts below the multi-query curve at small by sharing one parallel reshuffle. The crossover varies with and , but all four datasets follow the same trend.
8 RELATED WORK
Approximate Nearest Neighbor (ANN). ANN enables scalable similarity search in high-dimensional embedding spaces where exact kNN is often too expensive [29, 30, 43]. Classical methods include tree-based partitioning [5], locality-sensitive hashing [22], and vector quantization [23]. Graph-based indexes, such as HNSW [32] and NSG [17], dominate in practice, building proximity graphs for greedy query traversal. Recent systems extend graph-based ANN with improved indexing and retrieval strategies [24, 42, 52], while vector databases deploy these methods at scale [10, 20, 40].
Secure ANN. Prior work considers secure ANN under several threat models. When the database is public but the query is private, Tiptoe [21] searches a small candidate subset selected via clustering, trading accuracy for sublinear bandwidth and latency. Wally [2] further improves this pipeline's throughput by batching queries, while Preco [35] reduces communication using two non-colluding servers. Pacmann [50] goes beyond clustering-based ANN methods by building a graph-index under query privacy. When both the database and query are private under a single owner (encrypted outsourcing), Compass [51] directly uses ORAM only to hide the server-side data access pattern, while executing the search logic in plaintext on the client. Instead, HERS [15] scans the encrypted database with FHE at high computational cost. SANNS [11] and PANTHER [28] use secure two-party computation between a server owning the database and a client owning the query. SANNS proposes a clustering-based secure ANN with optimized distance computation and top-k selection, while PANTHER further improves end-to-end performance. In contrast, HNSecW secret-shares the query, database, and index among computation servers and achieves the same logarithmic complexity as the non-private setting. Notably, both SANNS [11] and PANTHER [28] can be adapted to secret-shared inputs. However, both approaches have complexity. Moreover, several early works [34, 36, 38, 53] studied secure kNN protocols, but they either target smaller-scale settings or apply only to the specialized secure settings discussed above.
9 CONCLUSION
We present HNSecW, an MPC ANN protocol with online time and symmetric privacy for the query and database. It supports single-query, sequential multi-query, and batch-query settings. Future work includes more efficient secure index construction and dynamic graph updates. Currently, the database owner builds the index locally before queries arrive. For secure offloading, MPC servers can insert the vectors into the graph one by one and reuse our oblivious search to find neighbors. This requires graph searches, time, and space for degree bound [32].
ACKNOWLEDGMENTS
This research is supported by the Singapore Ministry of Education Tier 1 Grant (RG19/25) and the NTU-NAP Startup Grant (024584-00001). We also thank the anonymous reviewers who have made valuable suggestions on improving the presentation of the paper.
REFERENCES
[1] Gilad Asharov, Koki Hamada, Dai Ikarashi, Ryo Kikuchi, Ariel Nof, Benny Pinkas, Katsumi Takahashi, and Junichi Tomida. 2022. Efficient secure three-party sorting with applications to data analysis and heavy hitters. In Proceedings of the 2022 ACM SIGSAC Conference on Computer and Communications Security. Association for Computing Machinery, 125–138. https://doi.org/10.1145/3548606.3560691
[2] Hilal Asi, Fabian Boemer, Nicholas Genise, Muhammad Haris Mughees, Tabitha Ogilvie, Rehan Rishi, Kunal Talwar, Karl Tarbe, Akshay Wadia, Ruiyu Zhu, and Marco Zuliani. 2026. Wally: Batched Private Nearest Neighbor Search at Scale. arXiv:2406.06761v7. https://arxiv.org/abs/2406.06761v7 Accessed: 2026-09-23.
[3] Martin Aumüller, Erik Bernhardsson, and Alexander Faithfull. 2020. ANN-Benchmarks: A benchmarking tool for approximate nearest neighbor algorithms. Information Systems 87, Article 101374 (2020). https://doi.org/10.1016/j.is.2019.02.006
[4] Artem Babenko and Victor Lempitsky. 2016. Efficient indexing of billion-scale datasets of deep descriptors. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. IEEE, 2055–2063. https://doi.org/10.1109/cvpr.2016.226
[5] Jon Louis Bentley. 1990. K-d trees for semidynamic point sets. In Proceedings of the sixth annual symposium on Computational geometry. Association for Computing Machinery, 187–197. https://doi.org/10.1145/98524.98564
[6] Alexandra Boldyreva and Tianxin Tang. 2021. Privacy-preserving approximate k-nearest-neighbors search that hides access, query and volume patterns. Proceedings on Privacy Enhancing Technologies 2021, 4 (2021), 549–574. https://doi.org/10.2478/popets-2021-0084
[7] Ran Canetti. 2000. Security and Composition of Multiparty Cryptographic Protocols. Journal of Cryptology 13, 1 (Jan. 2000), 143–202. https://doi.org/10.1007/s001459910006
[8] Manos Chatzakis, Yannis Papakonstantinou, and Themis Palpanas. 2025. DARTH: Declarative Recall Through Early Termination for Approximate Nearest Neighbor Search. Proceedings of the ACM on Management of Data 3, 4, Article 242 (2025), 26 pages. https://doi.org/10.1145/3749160
[9] Manos Chatzakis, Yannis Papakonstantinou, and Themis Palpanas. 2026. DARTH+: Approximate Nearest Neighbor Search with Declarative Recall and Quality Guarantees. HAL preprint hal-05566027v1. https://hal.science/hal-05566027v1 Accessed: 2026-09-23.
[10] Cheng Chen, Chenzhe Jin, Yunan Zhang, Sasha Podolsky, Chun Wu, Szu-Po Wang, Eric Hanson, Zhou Sun, Robert Walzer, and Jianguo Wang. 2024. SingleStore-V: An Integrated Vector Database System in SingleStore. Proceedings of the VLDB Endowment 17, 12 (2024), 3772–3785. https://doi.org/10.14778/3685800.3685805
[11] Hao Chen, Ilaria Chillotti, Yihe Dong, Oxana Poburinnaya, Ilya Razenshteyn, and M. Sadegh Riazi. 2020. SANNS: Scaling up secure approximate k-Nearest neighbors search. In 29th USENIX Security Symposium (USENIX Security 20). USENIX Association, 2111–2128. https://www.usenix.org/conference/usenixsecurity20/presentation/chen-hao Accessed: 2026-09-23.
[12] Daniel Demmler, Thomas Schneider, and Michael Zohner. 2015. ABY – A Framework for Efficient Mixed-Protocol Secure Two-Party Computation. In Proceedings of the Network and Distributed System Security Symposium (NDSS). Internet Society. https://doi.org/10.14722/ndss.2015.23113
[13] David P Dobkin, Steven J Friedman, and Kenneth J Supowit. 1990. Delaunay graphs are almost as good as complete graphs. Discrete & Computational Geometry 5, 4 (1990), 399–407. https://doi.org/10.1007/bf02187801
[14] Jack Doerner and abhi shelat. 2017. Scaling ORAM for Secure Computation. In Proceedings of the 2017 ACM SIGSAC Conference on Computer and Communications Security. Association for Computing Machinery, 523–535. https://doi.org/10.1145/3133956.3133967
[15] Joshua J Engelsma, Anil K Jain, and Vishnu Naresh Boddeti. 2022. HERS: Homomorphically Encrypted Representation Search. IEEE Transactions on Biometrics, Behavior, and Identity Science 4, 3 (2022), 349–360. https://doi.org/10.1109/tbiom.2021.3139866
[16] Brett Falk, Rafail Ostrovsky, Matan Shtepel, and Jacob Zhang. 2023. GigaDO-RAM: Breaking the Billion Address Barrier. In 32nd USENIX Security Symposium (USENIX Security 23). USENIX Association, 3871–3888. https://www.usenix.org/conference/usenixsecurity23/presentation/falk Accessed: 2026-09-23.
[17] Cong Fu, Chao Xiang, Changxu Wang, and Deng Cai. 2019. Fast approximate nearest neighbor search with the navigating spreading-out graph. Proceedings of the VLDB Endowment 12, 5 (2019), 461–474. https://doi.org/10.14778/3303753.3303754
[18] Oded Goldreich and Rafail Ostrovsky. 1996. Software Protection and Simulation on Oblivious RAMs. Journal of the ACM 43, 3 (1996), 431–473. https://doi.org/10.1145/233551.233553
[19] S. Dov Gordon, Jonathan Katz, Vladimir Kolesnikov, Fernando Krell, Tal Malkin, Mariana Raykova, and Yevgeniy Vahlis. 2012. Secure two-party computation in sublinear (amortized) time. In ACM CCS 2012, Ting Yu, George Danezis, and Virgil D. Gligor (Eds.). ACM Press, 513–524. https://doi.org/10.1145/2382196.2382251
[20] Rentong Guo, Xiaofan Luan, Long Xiang, Xiao Yan, Xiaomeng Yi, Jigao Luo, Qianya Cheng, Weizhi Xu, Jiarui Luo, Frank Liu, Zhenshan Cao, Yanliang Qiao, Ting Wang, Bo Tang, and Charles Xie. 2022. Manu: a cloud native vector database management system. Proceedings of the VLDB Endowment 15, 12 (2022), 3548–3561. https://doi.org/10.14778/3554821.3554843
[21] Alexandra Henzinger, Emma Dauterman, Henry Corrigan-Gibbs, and Nickolai Zeldovich. 2023. Private Web Search with Tiptoe. In Proceedings of the 29th symposium on operating systems principles. Association for Computing Machinery, 396–416. https://doi.org/10.1145/3600006.3613134
[22] Piotr Indyk and Rajeev Motwani. 1998. Approximate nearest neighbors: towards removing the curse of dimensionality. In Proceedings of the thirtieth annual ACM symposium on Theory of computing. Association for Computing Machinery, 604–613. https://doi.org/10.1145/276698.276876
[23] Hervé Jégou, Matthijs Douze, and Cordelia Schmid. 2011. Product quantization for nearest neighbor search. IEEE Transactions on Pattern Analysis and Machine Intelligence 33, 1 (2011), 117–128. https://doi.org/10.1109/tpami.2010.57
[24] Wenqi Jiang, Hang Hu, Torsten Hoefler, and Gustavo Alonso. 2025. Fast Graph Vector Search via Hardware Acceleration and Delayed-Synchronization Traversal. Proceedings of the VLDB Endowment 18, 11 (2025), 3797–3811. https://doi.org/10.14778/3749646.3749655
[25] Marcel Keller. 2020. MP-SPDZ: A Versatile Framework for Multi-Party Computation. In Proceedings of the 2020 ACM SIGSAC conference on computer and communications security. Association for Computing Machinery, 1575–1590. https://doi.org/10.1145/3372297.3417872
[26] Yann LeCun, Léon Bottou, Yoshua Bengio, and Patrick Haffner. 1998. Gradient-based learning applied to document recognition. Proc. IEEE 86, 11 (1998), 2278–2324. https://doi.org/10.1109/5.726791
[27] Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, Sebastian Riedel, and Douwe Kiela. 2020. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. In Advances in Neural Information Processing Systems, Vol. 33. Curran Associates, Inc., 9459–9474. https://proceedings.neurips.cc/paper/2020/hash/6b493230205f780e1bc26945df7481e5-Abstract.html Accessed: 2026-09-23.
[28] Jingyu Li, Zhicong Huang, Min Zhang, Cheng Hong, Jian Liu, Tao Wei, and Wenguang Chen. 2025. Panther: Private Approximate Nearest Neighbor Search in the Single Server Setting. In Proceedings of the 2025 ACM SIGSAC Conference on Computer and Communications Security. Association for Computing Machinery, 365–379. https://doi.org/10.1145/3719027.3765190
[29] Wen Li, Ying Zhang, Yifang Sun, Wei Wang, Mingjie Li, Wenjie Zhang, and Xuemin Lin. 2020. Approximate nearest neighbor search on high dimensional data—experiments, analyses, and improvement. IEEE Transactions on Knowledge and Data Engineering 32, 8 (2020), 1475–1488. https://doi.org/10.1109/tkde.2019.2909204
[30] Ting Liu, Andrew W. Moore, Alexander Gray, and Ke Yang. 2004. An investigation of practical approximate nearest neighbor algorithms. In Advances in Neural Information Processing Systems, Vol. 17. MIT Press, 825–832. https://proceedings.neurips.cc/paper/2004/hash/1102a326d5f7c9e04fc3c89d0ede88c9-Abstract.html Accessed: 2026-09-23.
[31] Yingfan Liu, Yandi Zhang, Jiadong Xie, Hui Li, Jeffrey Xu Yu, and Jiangtao Cui. 2025. Privacy-preserving approximate nearest neighbor search on high-dimensional data. In 2025 IEEE 41st International Conference on Data Engineering (ICDE). IEEE, 3017–3029. https://doi.org/10.1109/icde65448.2025.00226
[32] Yu. A. Malkov and D. A. Yashunin. 2020. Efficient and Robust Approximate Nearest Neighbor Search Using Hierarchical Navigable Small World Graphs. IEEE Transactions on Pattern Analysis and Machine Intelligence 42, 4 (April 2020), 824–836. https://doi.org/10.1109/tpami.2018.2889473
[33] Qwen, An Yang, Baosong Yang, Beichen Zhang, Binyuan Hui, Bo Zheng, Bowen Yu, Chengyuan Li, Dayiheng Liu, Fei Huang, Haoran Wei, Huan Lin, Jian Yang, Jianhong Tu, Jianwei Zhang, Jianxin Yang, Jiaxi Yang, Jingren Zhou, Junyang Lin, Kai Dang, Keming Lu, Keqin Bao, Kexin Yang, Le Yu, Mei Li, Mingfeng Xue, Pei Zhang, Qin Zhu, Rui Men, Runji Lin, Tianhao Li, Tianyi Tang, Tingyu Xia, Xingzhang Ren, Xuancheng Ren, Yang Fan, Yang Su, Yichang Zhang, Yu Wan, Yuqiong Liu, Zeyu Cui, Zhenru Zhang, and Zihan Qiu. 2025. Qwen2.5 Technical Report. arXiv:2412.15115v2. https://arxiv.org/abs/2412.15115v2 Accessed: 2026-09-23.
[34] Phillipp Schoppmann, Lennart Vogelsang, Adrià Gascón, and Borja Balle. 2020. Secure and Scalable Document Similarity on Distributed Databases: Differential Privacy to the Rescue. Proceedings on Privacy Enhancing Technologies 2020, 2 (2020), 209–229. https://doi.org/10.2478/popets-2020-0024
[35] Sacha Servan-Schreiber, Simon Langowski, and Srinivas Devadas. 2022. Private approximate nearest neighbor search with sublinear communication. In 2022 IEEE Symposium on Security and Privacy (SP). IEEE, 911–929. https://doi.org/10.1109/sp46214.2022.9833702
[36] Hayim Shaul, Dan Feldman, and Daniela Rus. 2020. Secure k-ish Nearest Neighbors Classifier. Proceedings on Privacy Enhancing Technologies 2020, 3 (2020), 42–61. https://doi.org/10.2478/popets-2020-0045
[37] Harsha Vardhan Simhadri, George Williams, Martin Aumüller, Matthijs Douze, Artem Babenko, Dmitry Baranchuk, Qi Chen, Lucas Hosseini, Ravishankar Krishnaswamy, Gopal Srinivasa, Suhas Jayaram Subramanya, and Jingdong Wang. 2022. Results of the NeurIPS'21 Challenge on Billion-Scale Approximate Nearest Neighbor Search. In Proceedings of the NeurIPS 2021 Competitions and Demonstrations Track (Proceedings of Machine Learning Research), Vol. 176. PMLR, 177–189. https://proceedings.mlr.press/v176/simhadri22a.html Accessed: 2026-09-23.
[38] Ebrahim M Songhori, Siam U Hussain, Ahmad-Reza Sadeghi, and Farinaz Koushanfar. 2015. Compacting privacy-preserving k-nearest neighbor search using logic synthesis. In Proceedings of the 52nd Annual Design Automation Conference. Association for Computing Machinery, 1–6. https://doi.org/10.1145/2744769.2744808
[39] Adithya Vadapalli, Ryan Henry, and Ian Goldberg. 2023. DUORAM: A Bandwidth-Efficient Distributed ORAM for 2- and 3-Party Computation. In 32nd USENIX Security Symposium (USENIX Security 23). USENIX Association, 3907–3924. https://www.usenix.org/conference/usenixsecurity23/presentation/vadapalli Accessed: 2026-09-23.
[40] Jianguo Wang, Xiaomeng Yi, Rentong Guo, Hai Jin, Peng Xu, Shengjun Li, Xiangyu Wang, Xiangzhou Guo, Chengming Li, Xiaohai Xu, Kun Yu, Yuxing Yuan, Yinghao Zou, Jiquan Long, Yudong Cai, Zhenxiang Li, Zhifeng Zhang, Yihua Mo, Jun Gu, Ruiyi Jiang, Yi Wei, and Charles Xie. 2021. Milvus: A Purpose-Built Vector Data Management System. In Proceedings of the 2021 International Conference on Management of Data (SIGMOD '21). Association for Computing Machinery, New York, NY, USA, 2614–2627. https://doi.org/10.1145/3448016.3457550
[41] Liang Wang, Nan Yang, Xiaolong Huang, Binxing Jiao, Linjun Yang, Daxin Jiang, Rangan Majumder, and Furu Wei. 2024. Text embeddings by weakly-supervised contrastive pre-training. arXiv:2212.03533v2. https://arxiv.org/abs/2212.03533v2 Accessed: 2026-09-23.
[42] Mengzhao Wang, Weizhi Xu, Xiaomeng Yi, Songlin Wu, Zhangyang Peng, Xiangyu Ke, Yunjun Gao, Xiaoliang Xu, Rentong Guo, and Charles Xie. 2024. Starling: An I/O-Efficient Disk-Resident Graph Index Framework for High-Dimensional Vector Similarity Search on Data Segment. Proceedings of the ACM on Management of Data 2, 1, Article 14 (2024), 27 pages. https://doi.org/10.1145/3639269
[43] Mengzhao Wang, Xiaoliang Xu, Qiang Yue, and Yuxiang Wang. 2021. A comprehensive survey and experimental comparison of graph-based approximate nearest neighbor search. Proceedings of the VLDB Endowment 14, 11 (2021), 1964–1978. https://doi.org/10.14778/3476249.3476255
[44] Xiao Wang, T.-H. Hubert Chan, and Elaine Shi. 2015. Circuit ORAM: On Tightness of the Goldreich-Ostrovsky Lower Bound. In ACM CCS 2015, Indrajit Ray, Ninghui
Li, and Christopher Kruegel (Eds.). ACM Press, 850–861. https://doi.org/10.1145/2810103.2813634
[45] Han Xiao, Kashif Rasul, and Roland Vollgraf. 2017. Fashion-MNIST: A Novel Image Dataset for Benchmarking Machine Learning Algorithms. arXiv:1708.07747v2. https://arxiv.org/abs/1708.07747v2 Accessed: 2026-09-23.
[46] Zhilin Yang, Peng Qi, Saizheng Zhang, Yoshua Bengio, William Cohen, Ruslan Salakhutdinov, and Christopher D Manning. 2018. HotpotQA: A Dataset for Diverse, Explainable Multi-hop Question Answering. In Proceedings of the 2018 conference on empirical methods in natural language processing. Association for Computational Linguistics, 2369–2380. https://doi.org/10.18653/v1/d18-1259
[47] Andrew Chi-Chih Yao. 1986. How to Generate and Exchange Secrets (Extended Abstract). In 27th FOCS. IEEE Computer Society Press, 162–167. https://doi.org/10.1109/SFCS.1986.25
[48] Xun Yi, Russell Paulet, Elisa Bertino, and Vijay Varadharajan. 2016. Practical approximate k nearest neighbor queries with location and query privacy. IEEE Transactions on Knowledge and Data Engineering 28, 6 (2016), 1546–1559. https://doi.org/10.1109/tkde.2016.2520473
[49] Fahong Zhang, Weijie Jin, Lixu Wang, Ning Luo, Xiao Wang, and Wei Dong. 2026. HNSecW: A Logarithmic-Time MPC Protocol for Approximate Nearest Neighbor Search (Extended Version). https://github.com/Kleenex-ultrasoft/Secure_ANN/blob/main/paper.pdf. Accessed: 2026-09-23.
[50] Mingxun Zhou, Elaine Shi, and Giulia Fanti. 2025. Pacmann: Efficient Private Approximate Nearest Neighbor Search. In The Thirteenth International Conference on Learning Representations (ICLR). OpenReview.net. https://proceedings.iclr.cc/paper_files/paper/2025/hash/391d50b3fe1c59b3e2b8b644e0c8fe81-Abstract-Conference.html Accessed: 2026-09-23.
[51] Jinhao Zhu, Liana Patel, Matei Zaharia, and Raluca Ada Popa. 2025. Compass: Encrypted Semantic Search with High Accuracy. In Proceedings of the 19th USENIX Symposium on Operating Systems Design and Implementation (OSDI '25). USENIX Association, Boston, MA, USA, 915–938. https://www.usenix.org/conference/osdi25/presentation/zhu-jinhao Accessed: 2026-09-23.
[52] Jiaxu Zhu, Jiayu Yuan, Kaiwen Yang, Xiaobao Chen, Shihuan Yu, Hongchang Lv, Yan Li, and Bolong Zheng. 2025. An Experimental Evaluation of Hybrid Querying on Vectors. Proceedings of the VLDB Endowment 19, 2 (2025), 183–195. https://doi.org/10.14778/3773749.3773757
[53] Martin Zuber and Renaud Sirdey. 2021. Efficient homomorphic evaluation of k-NN classifiers. Proceedings on Privacy Enhancing Technologies 2021, 2 (2021), 111–129. https://doi.org/10.2478/popets-2021-0020