arXiv:2611.03415cs.CRNov 2026

Manuscript Offprint

arXiv:2611.03415

O2N2: Efficient Doubly Oblivious Approximate Nearest Neighbor Search

Zhechen Li, Zimai Guo, Mingxun Zhou, Chang Shi, Cheng Hong

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Zhechen Li

Peking University

lizhechen@pku.edu.cn

Zimai Guo

Peking University

endergzm@pku.edu.cn

Mingxun Zhou

The Hong Kong University of Science and Technology

mingxunz@ust.hk

Chang Shi

The Hong Kong University of Science and Technology

2300017795@stu.pku.edu.cn

Cheng Hong

Ant Group

vince.hc@antgroup.com

Abstract—Privacy-preserving approximate nearest neighbor (ANN) search allows clients to search from an untrusted server without revealing sensitive queries, and is useful in scenarios like medical diagnostics and credit scoring. Among the various privacy-preserving primitives, trusted execution environments (TEEs) have much lower overhead than heavy cryptographic ones, yet they leak memory access patterns, enabling adversaries to infer query contents.

Oblivious RAM (ORAM) can be used to hide those access patterns at O(log⁡N)O(\log N) asymptotic cost, but existing high-performance ANN search algorithms (e.g., IVF or HNSW) exhibit complex, data-dependent access patterns that are unfriendly for ORAM. Furthermore, standard ORAM constructions typically assume there exists a small amount of trusted storage, which weakens the security guarantees and is not always feasible. Solutions that eliminate such trusted storage (known as double obliviousness) typically degrade performance further to O(log⁡2N)O(\log^2 N).

We introduce O2N2, a doubly oblivious ANN framework built around single-path search in randomly rotated k-d tree forests. A pointer-based Circuit ORAM stores the search structure, with separate storage for compact internal nodes and vector-bearing leaves. Each visited leaf is processed by an oblivious selection network, and fixed-schedule duplicate removal and selection combine the local results into the final top-k.

We evaluate O2N2 on real-world datasets and further test its scalability on 100 million vectors. For 10-NN and 100-NN search at the specified high-recall targets, it achieves a 9.8–125.9× speedup over the fastest doubly oblivious baselines.

1. Introduction

Approximate nearest neighbor (ANN) search is a core primitive for modern data-intensive applications, including embedding search and retrieval-augmented generation [24, 28]. Given a query vector, ANN search retrieves its (approximately) top-k closest vectors from a vector database, typically using specialized indexes such as IVF [20], HNSW [21], and DiskANN [19] to avoid exhaustive scans. With the growth of database size, ANN search relies more and more on external memory, which is often untrusted. This creates a need for private ANN search schemes that protect both sensitive queries and database contents. Trusted Execution Environments (TEEs) [22, 27, 53] provide an attractive foundation for this goal by offering low-overhead protected execution on untrusted platforms [13, 34], where the enclave plays the role of trusted client in conventional outsourced storage systems.

However, TEEs alone do not solve the private ANN search problem. Although TEEs protect the confidentiality of code and data, they do not hide memory access traces. Prior attacks show that such traces can leak sensitive information [7, 15, 18, 49]. A standard defense against these attacks is to achieve obliviousness [14], which requires the access patterns to be data-independent. Traditional schemes treat the client-side storage as trusted and do not hide accesses to it. In TEEs, however, the enclave plays this client's role, and its internal accesses may be exposed through page-fault or cache-timing attacks [42, 44, 48]. We therefore require double obliviousness [29, 42, 50], which requires both external and enclave memory access patterns to be independent of the sensitive input.

To achieve this guarantee, a natural black-box approach is running a non-private ANN index under a fixed, padded schedule, with all memory accesses routed through a doubly oblivious memory layer, such as doubly oblivious RAMs [29, 50] or doubly oblivious maps [8, 29, 42]. This black-box route mitigates the access pattern leakage, but most of existing constructions typically pay Ω(log⁡2N)\Omega(\log^2 N) cost per logical access. Since mainstream ANN indexes perform many fine-grained, adaptive probes, this per-access overhead is repeatedly incurred and leads to impractical latency in our evaluation. This gap raises the following question.

How can we design a doubly-oblivious ANN search scheme that achieves both strong privacy guarantees and practical efficiency?

We answer this question with O2N2, a doubly oblivious ANN search system built around structural alignment

TABLE 1. COMPARISON OF PRIVATE ANN SEARCH SOLUTIONS, WHERE single (external) obliviousness hides storage access patterns, while double obliviousness also hides access patterns inside the TEE.

WorkData modelCore primitivePrivacy guaranteeUnderlying ANN scheme
Panther [25]Server-ownedPIRQuery privacy + database privacyCluster-based
Pacmann [51]PublicPIRQuery privacyGraph-based
Tiptoe [16]PublicPIRQuery privacyCluster-based
Compass [52]Client-ownedORAMQuery privacySingle (external) obliviousnessGraph-based
BiSON [12]Client-ownedORAMQuery privacy + database privacySingle (external) obliviousnessGraph-based
Onyx [32]Client-ownedORAMQuery privacy + database privacySingle (external) obliviousnessGraph-based
O2N2 (Ours)AnyORAMQuery privacy + database privacyDouble obliviousnessTree-based

between the search algorithm and the oblivious primitive. Defeatist search in a randomly rotated k-d tree forest follows one root-to-leaf path per tree [31]. O2N2 combines pointer-based Circuit ORAM access [46, 47], a heterogeneous layout for internal and leaf nodes, and oblivious selection networks over the complete leaf candidates. Independent tree queries expose multiple candidate sets, while the selection stage retains their best distinct neighbors.

Using the combined network by Cong et al. [11], O2N2 answers 10-NN queries on SIFT1M at 90.01% recall in 1.37 ms. We evaluate latency, recall, and distance error across workloads, and use a paired ablation to isolate the effect of the candidate selector.