Sketch-Flip-Merge: Mergeable Sketches for Private Distinct Counting

Jonathan Hehir, Daniel Ting, Graham Cormode

Introduction

In modern data engineering, "sketches" are essential tools. They are compact data summaries that allow systems to estimate the number of unique elements (cardinality) in massive datasets—such as counting unique visitors to a website—without storing every individual identifier.

A critical feature of these sketches is mergeability. If you have a sketch from Server A and a sketch from Server B, you must be able to combine them to compute the total unique count for both servers. However, sketches inherently risk leaking sensitive information. While Differential Privacy (DP) is the gold standard for protecting data, adding DP noise traditionally breaks the mathematical properties that make sketches mergeable. Previous attempts to solve this conflict either required secret hash functions (impractical in large-scale distributed systems) or resulted in impractically large errors that rendered the estimates useless.

This paper introduces Sketch-Flip-Merge (SFM), the first practical framework for distinct counting that is simultaneously mergeable and differentially private. By replacing traditional deterministic bit-merging with a novel randomized approach, SFM achieves an order-of-magnitude improvement in accuracy over previous state-of-the-art private sketches.

The Sketch-Flip-Merge (SFM) Framework

The authors build their solution on the PCSA (Probabilistic Counting with Stochastic Averaging) sketch, which represents data as a bitmap. The SFM approach introduces three key innovations:

  1. Symmetric Randomized Response: SFM applies a standard DP technique where bits in the sketch are flipped with a specific probability. This ensures privacy even if the underlying hash functions are publicly known.
  2. Randomized Merging: This is the core innovation. Traditionally, merging bitmaps involves a deterministic OR or XOR operation. The authors mathematically prove that deterministic merges on noisy bits inherently lead to high variance. Instead, they propose a randomized merge—a probabilistic mapping modeled as a Markov transition matrix that combines two noisy bits into one while minimizing the compounded noise.
  3. Composite Likelihood Estimation: To translate the noisy, merged bitmap back into a cardinality estimate, the authors developed a new estimator based on composite marginal log-likelihood. They prove this estimator is asymptotically optimal, extracting the maximum possible information from the noisy sketch.

Key Insights

  • The Deterministic Trap: The authors provide a mathematical proof showing that any deterministic merge of noisy bits must be an XOR operation, which unfortunately destroys significant information. By shifting to a randomized merge, they unlock a 75% reduction in variance.
  • Privacy for Free: Through a tighter mathematical analysis, the authors demonstrate that existing private sketches were actually safer than previously thought. They effectively doubled the usable privacy budget of prior methods simply by improving the theoretical bounds.
  • Semigroup Homomorphism: The paper elegantly frames the problem as a mathematical homomorphism. They show that their merge operation preserves the structure of set unions even after privacy noise is added, allowing for consistent inference across distributed systems.

Empirical Results

The authors evaluated SFM using both synthetic data (randomly generated sets of integers) and the real-world BitcoinHeist dataset (containing ~2.6 million unique Bitcoin addresses).

Performance of SFM compared to prior methods across varying dataset sizes, privacy budgets, and merge counts.
  • Massive Accuracy Gains: In simulations, SFM's error rates were an order of magnitude lower than the previous best theoretical solution by Pagh & Stausholm (PS).
  • Predictable Error: The theoretical error estimates perfectly match the empirical results, providing engineers with a reliable way to tune the privacy-accuracy tradeoff.
Relative efficiency and error rates of SFM versus existing private sketches across different privacy budgets.
  • Space Efficiency: SFM is roughly 100x more efficient than previous methods. To achieve the same level of accuracy, older methods would require two orders of magnitude more memory and storage.

Limitations and Future Work

While SFM represents a massive leap forward, it still adheres to the fundamental laws of Differential Privacy: The Noise Floor. The more sketches you merge, the more noise accumulates. There remains a practical limit to how many times sketches can be merged before the estimate becomes too noisy.

Furthermore, the current work focuses on bitmap-based sketches like PCSA. Adapting these randomized merge techniques to more complex structures—such as HyperLogLog, which stores maximum values rather than just bits—remains an exciting challenge for future research.

Summary updated

BibTeX
@inproceedings{hehir2023sketch,
  author = {Jonathan Hehir and Daniel Ting and Graham Cormode},
  title = {{Sketch-Flip-Merge: Mergeable Sketches for Private Distinct Counting}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=BAQWKRdL1D},
}
Figure