Table of Contents
Fetching ...

Efficient Ranking, Order Statistics, and Sorting under CKKS

Federico Mazzone, Maarten Everts, Florian Hahn, Andreas Peter

TL;DR

The paper tackles efficient ranking, order statistics, and sorting under CKKS FHE by eschewing swap-based methods in favor of a SIMD-driven re-encoding that enables all-pairs comparisons with constant depth $2$. It introduces a matrix-encoding framework and nonpolynomial function approximations to derive fractional ranks, enable extraction of any order statistic, and perform sorting in parallel. Correctness proofs accompany the ranking, order statistics, and sorting algorithms, including a tie-correction mechanism to handle equal elements. Experimental results on up to $N\approx 2^{16}$ support strong performance for moderate vector sizes and demonstrate practical applicability to privacy-preserving data analysis and secure ML tasks, while acknowledging quadratic space as a limitation. The work provides open-source code and outlines avenues for hardware acceleration and deployment in PPML pipelines such as secure inference and clustering.

Abstract

Fully Homomorphic Encryption (FHE) enables operations on encrypted data, making it extremely useful for privacy-preserving applications, especially in cloud computing environments. In such contexts, operations like ranking, order statistics, and sorting are fundamental functionalities often required for database queries or as building blocks of larger protocols. However, the high computational overhead and limited native operations of FHE pose significant challenges for an efficient implementation of these tasks. These challenges are exacerbated by the fact that all these functionalities are based on comparing elements, which is a severely expensive operation under encryption. Previous solutions have typically based their designs on swap-based techniques, where two elements are conditionally swapped based on the results of their comparison. These methods aim to reduce the primary computational bottleneck: the comparison depth, which is the number of non-parallelizable homomorphic comparisons in the algorithm. The current state of the art solution for sorting by Hong et al. (IEEE TIFS 2021), for instance, achieves a comparison depth of k log_k^2 N. In this paper, we address the challenge of reducing the comparison depth by shifting away from the swap-based paradigm. We present solutions for ranking, order statistics, and sorting, that achieve a comparison depth of up to 2 (constant), making our approach highly parallelizable and suitable for hardware acceleration. Leveraging the SIMD capabilities of the CKKS FHE scheme, our approach re-encodes the input vector under encryption to allow for simultaneous comparisons of all elements with each other. Experimental results show that our approach ranks a 128-element vector in approximately 5.76s, computes its argmin/argmax in 12.83s, and sorts it in 78.64s.

Efficient Ranking, Order Statistics, and Sorting under CKKS

TL;DR

The paper tackles efficient ranking, order statistics, and sorting under CKKS FHE by eschewing swap-based methods in favor of a SIMD-driven re-encoding that enables all-pairs comparisons with constant depth . It introduces a matrix-encoding framework and nonpolynomial function approximations to derive fractional ranks, enable extraction of any order statistic, and perform sorting in parallel. Correctness proofs accompany the ranking, order statistics, and sorting algorithms, including a tie-correction mechanism to handle equal elements. Experimental results on up to support strong performance for moderate vector sizes and demonstrate practical applicability to privacy-preserving data analysis and secure ML tasks, while acknowledging quadratic space as a limitation. The work provides open-source code and outlines avenues for hardware acceleration and deployment in PPML pipelines such as secure inference and clustering.

Abstract

Fully Homomorphic Encryption (FHE) enables operations on encrypted data, making it extremely useful for privacy-preserving applications, especially in cloud computing environments. In such contexts, operations like ranking, order statistics, and sorting are fundamental functionalities often required for database queries or as building blocks of larger protocols. However, the high computational overhead and limited native operations of FHE pose significant challenges for an efficient implementation of these tasks. These challenges are exacerbated by the fact that all these functionalities are based on comparing elements, which is a severely expensive operation under encryption. Previous solutions have typically based their designs on swap-based techniques, where two elements are conditionally swapped based on the results of their comparison. These methods aim to reduce the primary computational bottleneck: the comparison depth, which is the number of non-parallelizable homomorphic comparisons in the algorithm. The current state of the art solution for sorting by Hong et al. (IEEE TIFS 2021), for instance, achieves a comparison depth of k log_k^2 N. In this paper, we address the challenge of reducing the comparison depth by shifting away from the swap-based paradigm. We present solutions for ranking, order statistics, and sorting, that achieve a comparison depth of up to 2 (constant), making our approach highly parallelizable and suitable for hardware acceleration. Leveraging the SIMD capabilities of the CKKS FHE scheme, our approach re-encodes the input vector under encryption to allow for simultaneous comparisons of all elements with each other. Experimental results show that our approach ranks a 128-element vector in approximately 5.76s, computes its argmin/argmax in 12.83s, and sorts it in 78.64s.

Paper Structure

This paper contains 28 sections, 28 equations, 8 figures, 3 tables, 12 algorithms.

Figures (8)

  • Figure 1: Transposing a vector of length $N=8$ from column to row (TransC).
  • Figure 2: Schematic example of ranking a 4-element vector.
  • Figure 3: Schematic example of sorting a 4-element vector.
  • Figure 4: Schematic example of computing the tie-correction offset for a 4-element vector.
  • Figure 5: Comparison in multi-ciphertext mode. The vector $v$ is split into blocks of size $B = 4$. The upper triangle contains information about the comparison between all pairs $v_i > v_j$.
  • ...and 3 more figures