Efficient Oblivious Sorting and Shuffling for Hardware Enclaves

Ke Yi, Tianyao Gu, Yilei Wang, Bingnan Chen, Afonso Tinoco, Elaine Shi, Ke Yi 0001IACR ePrint 2023

Abstract

Flexway O-Sort is an asymptotically optimal $O(N \log N)$ oblivious sorting algorithm designed specifically for hardware enclaves like Intel SGX. It bridges the long-standing gap between theoretical optimality and practical performance, outperforming the industry-standard Bitonic Sort. By introducing a multi-way butterfly network and a novel "packing trick" for constant-time balancing, Flexway O-Sort achieves up to a 208x speedup over prior methods when data exceeds protected memory limits.

Introduction

In privacy-preserving computing, oblivious algorithms are critical for ensuring that memory access patterns do not leak sensitive information to observers, including those with root access to the operating system. Sorting is a fundamental building block for these systems, supporting operations like private contact discovery and database joins. However, a significant "theory-practice gap" has persisted: simple algorithms like Bitonic Sort are suboptimal ($O(N \log^2 N)$), while theoretically optimal ones like AKS sort are too complex for practical use. Furthermore, hardware enclaves impose strict memory limits (the Enclave Page Cache or EPC), where exceeding capacity triggers expensive page swapping that is roughly 66x slower than internal memory moves.

Flexway O-Sort Design

Flexway O-Sort refines the bucket oblivious sort framework to achieve high performance within enclave constraints.

Overview of the Oblivious Shuffling and Sorting Pipeline

The core of the algorithm is the Flexway Butterfly Network, which supports a variable number of branches at different layers. This flexibility avoids the 2x overhead typically associated with rounding input sizes to the nearest power of two. Key innovations include:

  • Multi-way MergeSplit: The algorithm utilizes a $p$-way split where $p \approx \sqrt{\log N}$, rather than a simple binary split.
  • The Packing Trick: To maintain obliviousness during data balancing, the authors model the problem as an Euler tour on a small graph. By "packing" the adjacency matrix into a single 64-bit CPU word, the enclave can perform balancing operations in constant time without leaking access patterns.
  • Interleave Subroutine: This recursive process ensures that each key's occurrences are balanced across sub-arrays, a necessary step for the subsequent oblivious steps.
The Interleave Subroutine for balancing keys
  • In-place Operations: The butterfly network was redesigned to operate in-place, effectively doubling the data capacity of the enclave before expensive page swapping begins.

Evaluation and Results

The researchers evaluated Flexway O-Sort using synthetic datasets ranging from $10^6$ to $10^{10}$ elements (8GB to 32GB) and real-world applications including ORAM initialization and database joins.

Performance Gains

  • In-Enclave Speedup: For datasets fitting within the enclave (up to 12GB), Flexway O-Sort is 1.32x to 28.8x faster than prior oblivious algorithms.
  • External Memory Efficiency: When data exceeds the EPC, the algorithm's in-place design and locality-awareness result in speedups of 4.1x to 208x over previous optimal constructions.
  • Application Impact: End-to-end tests showed 1.4x to 5.5x improvements over Bitonic Sort for database joins and ORAM setup.

Conclusion

Flexway O-Sort demonstrates that theoretical optimality does not have to come at the cost of practical speed. By optimizing for the specific constraints of hardware enclaves—namely low work constants and memory locality—the authors have provided a powerful new tool for secure data processing. Future work will focus on parallelizing the butterfly network and adapting the design for Multi-Party Computation (MPC) or Fully Homomorphic Encryption (FHE) environments.

Summary updated

BibTeX
@article{yi2023efficient,
  author = {Ke Yi and Tianyao Gu and Yilei Wang and Bingnan Chen and Afonso Tinoco and Elaine Shi and Ke Yi},
  title = {{Efficient Oblivious Sorting and Shuffling for Hardware Enclaves}},
  journal = {IACR ePrint},
  year = {2023},
}
Figure