O2N2: Efficient doubly oblivious approximate nearest neighbor searchO2N2: Efficient Doubly Oblivious Approximate Nearest Neighbor Search
The authors propose O2N2, a double-oblivious ANN system based on a forest of randomly rotated k-d trees and Circuit ORAM; the authors claim it is 9.8–125.9× faster than the fastest double-oblivious baseline at the specified high-recall targets.
The server is equipped with a TEE and holds the database, providing private ANN search for multiple clients; a server-side adversary can observe all memory access patterns between the TEE processor and RAM and within the enclave. Double obliviousness is required: both external and intra-enclave access patterns are independent of sensitive inputs. The TCB includes only the TEE processor and does not defend against attacks exploiting hardware implementation flaws such as Foreshadow, SGAxe, and TEE.fail.
- Private ANN search on a TEE leaks memory access patterns, from which an adversary can infer query content; ORAM can hide access patterns, but the data-dependent accesses of mainstream ANN indexes (IVF, HNSW) are unfriendly to ORAM, and doubly oblivious schemes that eliminate trusted storage are costly.
- O2N2 aligns the defeatist single-path search of randomly rotated k-d trees with pointer-based Circuit ORAM: internal nodes and leaves are stored in two separate ORAMs, top-k is taken within a leaf using an oblivious selection network, and results are merged across trees using fixed-schedule deduplication and selection, achieving double obliviousness.
- Compared with the double-oblivious baselines OIVF/OHNSW on DEEP10M, SIFT1M, MSONG, and MS MARCO, it is 9.8–125.9× faster at the specified high-recall targets (Table 4); SIFT1M 10-NN takes 1.37 ms at 90.01% recall; storage overhead on high-dimensional datasets is higher than the baselines.
- The authors note that reaching high recall on high-dimensional data with tree structures requires more trees and increases storage overhead, and that improving the space-latency trade-off is a future direction; the experiments are conducted on a single Intel TDX machine within 3 TB of storage, and the SIFT100M baselines were not completed due to storage or index-construction time.
- Benchmarks
- DEEP10MSIFT1MMSONGMS MARCOSIFT100M
- Metrics
- Recall@kDSR@kRDE@kquery timestorage
O2N2 implements doubly oblivious approximate nearest neighbor (ANN) search without trusted storage using single-path search over a forest of randomly rotated k-d trees, and hides memory access patterns with pointer-based Circuit ORAM. On real datasets and at the scale of 100 million vectors, 10-NN and 100-NN achieve 9.8–125.9× speedup over the fastest doubly oblivious baseline under specified high-recall targets.
Paper analysis
What problem does this paper attempt to solve?
How to perform ANN search on a TEE so that neither external nor intra-enclave memory access patterns leak the query content, while maintaining practical efficiency.
Core problem: how to design a doubly oblivious ANN search scheme with both strong privacy guarantees and practical efficiency.
- Scenario and importance: ANN search is used in scenarios such as embedding retrieval and RAG; the authors use medical diagnosis and credit scoring as examples to illustrate query privacy needs; as databases grow, ANN increasingly relies on external memory, which is typically untrusted.
- Shortcomings of existing methods: TEEs protect the confidentiality of code and data but do not hide memory access traces; the authors cite existing attacks showing that traces leak sensitive information; ORAM hides access patterns at O(log N) asymptotic cost, but the access patterns of high-performance ANN indexes such as IVF and HNSW are data-dependent and unfriendly to ORAM; standard ORAM assumes a small amount of trusted storage, and schemes that eliminate this assumption (doubly oblivious) typically rise to O(log² N) cost.
- Core observation: Defeatist search on randomly rotated k-d trees traverses only one root-to-leaf path per tree, with a fixed (paddable) path length, naturally compatible with tree ORAM access patterns, avoiding black-box oblivious compilation of adaptive probes.
- The paper proposes: O2N2, a doubly oblivious ANN framework built around single-path search over a forest of randomly rotated k-d trees; it also implements two doubly oblivious baselines, OIVF and OHNSW.
- Threat model:
- Victim system: a server equipped with a TEE, holding a database and providing private ANN search to multiple clients.
- Adversary capability: a server-side adversary can observe all memory access patterns between the TEE processor and RAM and within the enclave (which regions are read and written, and in what order).
- Protection goal: double obliviousness—both external and intra-enclave access patterns are independent of sensitive inputs; the server learns nothing beyond public hyperparameters, and the client learns nothing beyond the ANN results.
- TCB and boundaries: the TCB includes only the TEE processor and relies on remote attestation; it does not defend against attacks exploiting TEE hardware implementation flaws such as Foreshadow, SGAxe, and TEE.fail, which the authors state are orthogonal to the application-layer access pattern leakage addressed in this paper.
What related research exists?
Related work falls into three categories: private ANN with cryptographic primitives, TEE/ORAM-based private ANN, and doubly oblivious RAM; the authors claim O2N2 is the first tree-based scheme in the doubly oblivious ANN line.
Private ANN based on cryptographic primitives
- Fully homomorphic encryption line [36, 54]: protects the computation process, but the paper states that it requires expensive distance evaluations over large candidate sets.
- Two-server non-collusion assumption line [35, 40]: trades additional trust assumptions for efficiency.
- Single-server setting: SANNS [9] and Panther [25] use primitives such as PIR and target a stronger data-privacy setting; Tiptoe [16] and Pacmann [51] assume a public database and protect only query privacy (Table 1 summarizes these differences).
Private ANN based on TEE and ORAM
- Compass [52]: adapts HNSW with Ring ORAM; the paper notes that it provides only single external obliviousness and does not protect access behavior inside the enclave.
- BiSON [12], Onyx [32], TEE Compass [32]: all are ORAM-based, graph-index, single (external) oblivious schemes (Table 1); in Section 8.3 the paper notes that Compass and BiSON keep quantized vector hints, position maps, ORAM metadata, and graph caches in trusted client memory, while Onyx keeps compressed traversal hints and ORAM client state in TEE memory and explicitly excludes DRAM access patterns from its threat model.
Double-oblivious RAM and black-box compilation
- Double-oblivious RAM [29, 50] and double-oblivious maps [8, 29, 42]: eliminate the trusted-storage assumption, but the paper notes that when used as a black-box compiler, each logical access incurs a cost that is typically Ω(log² N), and IVF, HNSW, and DiskANN rely on adaptive, data-dependent probes, so the overhead is repeatedly amplified.
- H2O2RAM [50]: one of the double-oblivious RAM backends used as a baseline in the paper, and the paper relays that it is reported to outperform EnigMap [42] and GraphOS [8].
Baselines and benchmarks: the paper implements two double-oblivious baselines itself, OIVF (IVF + double ORAM) and OHNSW (HNSW + double ORAM), each with two backends, recursive Circuit ORAM and H2O2RAM; it also compares with the published numbers of Compass, BiSON, Onyx, and Panther and with the plaintext schemes HNSWlib and FAISS-IVF (via ann-benchmark); the datasets are DEEP10M, SIFT1M, MSONG, MS MARCO, and SIFT100M.
The authors position O2N2 as a different route from black-box compilation: choosing tree-based ANN algorithms whose query paths can coincide with tree-ORAM access patterns; in Table 1 it is the only scheme that simultaneously provides double obliviousness and does not restrict the data holder.
How does the paper address this problem?
Aligns the fixed-length single-path search of randomly rotated k-d trees with pointer-based Circuit ORAM, and together with a heterogeneous node layout and an oblivious selection network, achieves double-oblivious queries with a fixed, public schedule.
Overall approach: choose a randomly rotated (RR) k-d tree for defeatist search so that its single root-to-leaf path coincides with the tree ORAM access pattern, avoiding black-box oblivious compilation of adaptive ANN probes. O2N2 consists of two components, a doubly oblivious Circuit ORAM and a top-k selection network, which are then combined into single-tree queries and forest queries.
Problem setting and goals
- Dataset D contains N points in R^d; a query q seeks approximate top-k; the metrics are Recall@k, DSR@k, RDE@k.
- Main theorem (Theorem 1/2): for a forest of m trees, the worst-case query time is O(m log2 N + m n0 d log N + m k log2(mk)), where n0 is the leaf capacity; when n0 = Θ(log N) this is about O(dm log² N), and the authors call the extra overhead relative to the oblivious ANN lower bound Ω̃(d log N) a factor of O(log N)×.
- RR k-d tree: first apply the same random rotation to the data and the query, then recursively partition by cyclic coordinates using random quantiles in [1/4, 3/4]; each partition makes any child contain at most 3/4 of the points, so the tree depth is O(log N) and the query path length is fixed (and can be padded).
Component one: doubly oblivious Circuit ORAM
- The stash and position map of standard Circuit ORAM are client-side auxiliary structures and do not satisfy double obliviousness; a generic recursive transformation raises the cost of a single access from O(log N) to O(log² N).
- O2N2 instead uses position embedding: the parent node of the conceptual k-d tree directly stores the child node's identifier and ORAM position, so fetching the child along the parent yields the position, avoiding recursive position-map lookups.
- Stash operations scan a fixed-length array and use masked moves to select or update entries; eviction follows Circuit ORAM's public data-independent schedule; the stash capacity O(log N) is configured according to the target failure probability. The pointer-style interface costs O(BZ log N) per access, where B is the block size and Z is the bucket size.
- The interface is ReadRm (read out and replace with dummy), Add, Evict, with Write = Add + Evict; the read and write schedules are independent of the query and alternate, and distinguishing reads from writes does not leak query information.
Component two: selection network
- Select the k records closest to q from the n0 candidate (distance, identifier) records in the leaf; records are sorted first by distance and then by identifier, with dummy records placed after valid records.
- Uses the combinatorial selection network of Cong et al. [11] (truncated odd-even merge + Yao's recursive selection), choosing between the two methods according to the number of comparators for the public subproblem size; when k ≥ 2 the time is O(n0 log² k), and when k = 1 a linear-time minimum tournament is used.
- The comparator schedule is generated before the query; all compare-exchanges use fixed addresses and masked moves, and the access schedule depends only on n0 and k.
Single-tree query and heterogeneous layout
- A single tree is represented as (T_int, T_leaf, root, R, h): the internal-node ORAM stores (a, τ, lptr, rptr), and each block of the leaf ORAM stores one leaf's point set padded with dummy records to n0 slots; h = O(log N) is the public number of levels, and short paths are padded to that depth.
- Internal nodes and leaves are stored in two separate ORAMs: a unified ORAM would make every internal access also pay O(d·n0·Z·log N), whereas after separation an internal access costs O(Z log N), and the large-block cost is paid only at the leaves.
- Algorithm 1: after computing q′ = R·q, walk h rounds along one root-to-leaf path, with one ReadRm + one Write per round; coordinate access is implemented by scanning all d dimensions with masked moves, and pointer selection accesses the two child pointer fields according to a fixed schedule; finally read the leaf, write it back unchanged, and call Select_k to obtain that leaf's top-k.
Forest query and aggregation
- Algorithm 2: run Algorithm 1 on each of the m independently rotated trees, and each tree returns k candidates, which are appended to array A.
- Aggregation: OSort (a bitonic sorting network, O(n log² n)) sorts by identifier, a fixed scan replaces duplicate identifiers with dummy records, and then the final Select_k is run over the mk slots, outputting the best k distinct candidates.
- Correctness and double obliviousness are given by Claims 1–2 and Theorem 2: a single-tree query simulates the plaintext defeatist search, the access sequence length is fixed at 2h+2, and all operations outside the ORAM are on a fixed schedule.
- Implementation parameters: leaf capacity n0 = ⌈log₂ N⌉, ORAM bucket size Z = 4, and the number of trees m is variable to characterize the time-recall trade-off; Appendix A additionally gives a doubly oblivious max heap based on Circuit ORAM as an alternative selector to the selection network.
What experiments did the paper conduct?
Compares the time-recall trade-off with the double-oblivious baselines OIVF/OHNSW on four datasets, with 9.8–125.9× speedup at the specified high-recall targets, and additionally tests SIFT100M scalability and a selector ablation.
Experimental Setup
- Systems under test: O2N2; baselines OIVF and OHNSW, each paired with two doubly oblivious RAM backends, recursive Circuit ORAM and H2O2RAM (4 baseline configurations in total).
- Datasets (Table 3): DEEP10M (N=9,990,000, d=96), SIFT1M (N=1,000,000, d=128), MSONG (N=994,185, d=420), MS MARCO (N=8,841,823, d=768); scalability is additionally measured on SIFT100M (the first 100 million vectors of BIGANN).
- Metrics: query time, Recall@k, DSR@k, RDE@k, k ∈ {10, 100}; Table 4 additionally reports storage (GB).
- Parameters: O2N2 leaf capacity n0 = ⌈log₂ N⌉, bucket size Z = 4, varying m to characterize the trade-off; OIVF target cluster size 25, Lmax = 50; OHNSW degree bounds 32/64 on DEEP10M/MS MARCO and 16/32 on the other datasets.
- Environment: Intel TDX confidential VM, 192 vCPU @ 2.6 GHz, 3 TiB RAM, 5 Gbps local network; all algorithms implemented in C++20.
- Target recall: In Table 4, all are 90% except SIFT100M (k=100) and MS MARCO (k=10), which are 80%; the fastest O2N2 configuration meeting the target and the baseline point with recall closest to the target are used.
Main Results
According to Table 4 (baseline is the fastest OHNSW (Circuit ORAM); O2N2 storage is measured based on the heap version of the index):
Swipe horizontally to read the table
Dataset k O2N2 m O2N2 storage (GB) O2N2 time (ms) Baseline storage (GB) Baseline time (ms) Speedup DEEP10M 10 128 256 4.4 1165 333.8 76.6× DEEP10M 100 208 415 6.9 1165 497.1 72.3× SIFT1M 10 56 15 1.3 40 161.3 125.9× SIFT1M 100 96 26 2.5 40 260.5 102.9× SIFT100M 10 88 2325 3.5 N/A N/A N/A SIFT100M 100 104 2748 4 N/A N/A N/A MSONG 10 64 55 4.3 49 253.1 58.4× MSONG 100 112 85 8.1 49 322.1 39.6× - MS MARCO (k=10, target 80%): O2N2 m=184, storage 2540 GB, 53.4 ms; baseline storage 1526 GB, 522.2 ms, speedup 9.8×; the 3 TB storage limit means O2N2 reports only k=10 on MS MARCO.
- SIFT100M has no completed baseline: OHNSW exhausted the available storage, and OIVF's index construction was too slow to complete.
- The authors attribute the performance gap to how the index maps to oblivious execution: OIVF must scan many candidate points, OHNSW's fixed-budget graph traversal has serial dependency chains, whereas O2N2's m tree queries can be parallelized.
- Exception (storage): On low-dimensional datasets (SIFT, DEEP), O2N2 storage is lower than the baseline; on high-dimensional datasets (MSONG, MS MARCO), reaching high recall requires increasing m, so storage exceeds the baseline, whereas OHNSW storage is fixed.
Comparison with Existing Private ANN Systems and Plaintext Schemes
- According to Table 5 (k=10, citing the other systems' published numbers): on SIFT1M, O2N2 achieves 90.09% recall at 1.28 ms, and OHNSW 90% at 161.3 ms; on this basis the authors claim O2N2 is 31.2×, 7×, and 14.7× faster than Compass, BiSON, and Onyx, respectively.
- On MS MARCO, O2N2 reports its highest measured recall, 85.26%, at 55.53 ms: the authors state that this advantage does not carry over consistently to high-dimensional workloads; at this point its latency is between BiSON and Onyx and its recall is lower than both, but it is still faster than Compass and Compass-in-TEE; the authors also note that at about 90% recall its Circuit OHNSW takes only about 1.5× the time of Compass-in-TEE while additionally protecting internal accesses.
- Comparison with Panther (PIR line): the authors state that under the SIFT1M setting reported by Panther, its time is 1.49 s, while O2N2 reaches 90% Recall@10 at 1.28 ms, a reported latency ratio of 1,163.4×.
- Comparison with plaintext: on SIFT1M at about 90% Recall@10, HNSWlib takes 0.08 ms and FAISS-IVF 0.4 ms; O2N2 is 3.2× slower than FAISS-IVF and 16× slower than HNSWlib; the authors consider this overhead acceptable for remote service.
Scalability and Query Time Breakdown
- SIFT100M (Figure 5): with m fixed at 64, latency from SIFT1M to SIFT100M rises to 2.17× (k=10) and 1.67× (k=100); at the same m, SIFT100M has lower recall, and the authors state that more trees are needed to reach similar recall.
- Time breakdown (Figures 6, 7): on SIFT1M at k=10, aggregation accounts for less than 3%; at k=100 it rises from 8.7% at m=16 to 24.2% at m=128. At m=128, k=100, search time is 2.52 ms on SIFT1M and 7.88 ms on MSONG, with aggregation about 0.80 ms in both, the share dropping from 24.2% to 9.2%; the authors state that higher dimensionality increases the cost of leaf access and distance computation, whereas aggregation only processes IDs and distances.
Selector Ablation
- Figure 8 / Table 7 (SIFT1M, m=1 to 64, 1000 queries, 32 query workers): the selection network is 1.53–1.92× faster than DO heap at k=10 and 3.41–7.88× at k=100; at m=64, latency drops from 2.31 to 1.45 ms (k=10) and from 8.19 to 1.90 ms (k=100).
- The gains are concentrated in the forest search phase: at m=64, of the total reduction of 0.855 ms at k=10, search accounts for 0.846 ms, and of the total reduction of 6.298 ms at k=100, search accounts for 6.276 ms.
- Recall is consistent within printed precision except at k=10, m=64 (heap 90.00%, network 90.01%), and DSR and RDE are consistent at all reported points.
Other Ablations and Analysis
- Operation-level comparison of DO heap and Path OHeap (Table 6): at k=10/100/1000, DO heap is 2.79×, 1.77×, and 1.17× faster than the fastest Path OHeap configuration at each capacity, respectively; the authors state that the advantage narrows as k increases.
- Backend observation (Figure 3 footnote): the authors state that the Circuit ORAM baseline outperforms the H2O2RAM baseline in many settings, and explain that H2O2RAM relies on cache locality from long contiguous access sequences, which ANN computation interleaved with ORAM accesses disrupts.
What are some points that can be further explored?
The authors point out the limitation that on high-dimensional data, storage overhead rises with the number of trees, and list the space-latency trade-off as a future direction for improvement.
Limitations and future directions noted by the authors
- Space-latency trade-off for high-dimensional data (Section 9 Conclusion): the authors state that O2N2 inherits the limitations of tree-based designs, and that reaching high recall on high-dimensional data requires more trees, which increases storage overhead; improving this trade-off through approaches such as hybrid index structures is a future direction.
- Hardware attacks are out of scope for defenses (Section 4 Threat model): attacks that exploit TEE hardware implementation flaws, such as Foreshadow, SGAxe, and TEE.fail, are not defended against; the authors state that such vulnerabilities can only be mitigated through microcode patches or processor redesign.
- Parameter ceiling on MS MARCO (Table 4 footnote): the 3 TB storage limit prevents O2N2 from reaching 90% Recall@100 and higher recall operating points on MS MARCO, so only k=10 is reported for this dataset.
- Missing SIFT100M baselines (Table 4 footnote): OHNSW exhausts the available storage, and OIVF index construction is too slow at this scale and was not completed within the experiments, so SIFT100M has no baseline comparison.
Experimental coverage
- The systems under test are O2N2 and 4 double-oblivious baseline configurations (OIVF/OHNSW × recursive Circuit ORAM/H2O2RAM), all implemented in C++20 and run on an Intel TDX confidential VM (192 vCPU, 3 TiB RAM).
- The datasets are the four main comparison sets DEEP10M, SIFT1M, MSONG, and MS MARCO, plus a SIFT100M scalability experiment; k is set to 10 and 100.
- The comparison with Compass, BiSON, Onyx, and Panther (Table 5) uses the numbers published in the respective papers, with differing network settings (e.g., Compass at 3 Gbps/1 ms RTT, BiSON at 10 Gbps/0.3 ms RTT), not re-measured in a unified environment.
- The selector ablation (Table 7) is measured on SIFT1M with 1000 queries, 32 query workers, and seed 1; the paper does not report the number of queries or repetitions for the other main experiments.
- The plaintext comparison covers only one operating point, approximately 90% Recall@10 on SIFT1M for HNSWlib and FAISS-IVF (via ann-benchmark).
Summarize the main content of the paper
O2N2 aligns the fixed single-path search of randomly rotated k-d trees with pointer-based Circuit ORAM to achieve doubly oblivious ANN; the authors claim it is 9.8–125.9× faster than the fastest doubly oblivious baseline at high-recall targets.
O2N2 is a doubly oblivious approximate nearest neighbor search system for TEEs, with the goal that a server-side adversary, even when able to observe all access patterns in external memory and within the enclave, still cannot infer the client's query.
- Problem: TEEs do not hide memory access traces; although ORAM can hide access patterns, the data-dependent probes of indexes such as IVF and HNSW are unfriendly to ORAM, and doubly oblivious schemes that eliminate trusted storage typically pay O(log² N) per access.
- Method highlights: It uses randomly rotated k-d trees with defeatist search, whose fixed-length root-to-leaf paths coincide with tree ORAM access patterns; parent nodes embed child nodes' ORAM positions to avoid recursive position maps; internal nodes and leaves are stored in two Circuit ORAMs; within leaves, Cong et al.'s compositional selection network is used to take top-k, and across trees, final selection is done after deduplication via oblivious sorting, with a fixed public schedule throughout. Worst-case query time is O(m log² N + m·n0·d·log N + mk log²(mk)).
- Main results: On DEEP10M, SIFT1M, MSONG, and MS MARCO, at the specified high-recall targets (mostly 90%), it is 9.8–125.9× faster than the fastest doubly oblivious baseline OHNSW (Circuit ORAM) (Table 4); SIFT1M 10-NN has 1.37 ms latency at 90.01% recall.
- Other results: At m=64, scaling from SIFT1M to SIFT100M raises latency to 2.17× (k=10) and 1.67× (k=100); the selection network is 1.53–1.92× (k=10) and 3.41–7.88× (k=100) faster than DO heap on SIFT1M; compared with plaintext schemes, on SIFT1M at about 90% Recall@10 it is 3.2× slower than FAISS-IVF and 16× slower than HNSWlib.
- Exception: On high-dimensional datasets (MSONG, MS MARCO), more trees are needed to reach high recall, and storage exceeds the baseline (2540 GB vs. 1526 GB for MS MARCO at k=10).
- Authors' conclusion: The authors claim O2N2 reduces the per-block-access cost from O(log² N) for general recursive doubly oblivious storage to O(log N), maintaining competitive latency while additionally protecting internal accesses; the space-latency trade-off on high-dimensional data (e.g., hybrid index structures) is left as future work.