Home

Awesome

Differential Privacy

Note<br> If you are unfamiliar with differential privacy (DP), you might want to go through "A friendly, non-technical introduction to differential privacy".

This repository contains libraries to generate ε- and (ε, δ)-differentially private statistics over datasets. It contains the following tools.

To get started on generating differentially private data, we recommend you follow the Privacy on Beam codelab.

Currently, the DP building block libraries support the following algorithms:

AlgorithmC++GoJava
Laplace mechanismSupportedSupportedSupported
Gaussian mechanismSupportedSupportedSupported
CountSupportedSupportedSupported
SumSupportedSupportedSupported
MeanSupportedSupportedSupported
VarianceSupportedSupportedSupported
Standard deviationSupportedSupportedPlanned
QuantilesSupportedSupportedSupported
Automatic bounds approximationSupportedPlannedSupported
Truncated geometric thresholdingSupportedSupportedSupported
Laplace thresholdingSupportedSupportedSupported
Gaussian thresholdingPlannedSupportedSupported
Pre-thresholdingSupportedSupportedSupported

Implementations of the Laplace mechanism and the Gaussian mechanism use secure noise generation. These mechanisms can be used to perform computations that aren't covered by the algorithms implemented in our libraries.

The DP building block libraries and Privacy on Beam are suitable for research, experimental, or production use cases, while the other tools are currently experimental and subject to change.

How to Build

In order to run the differential privacy library, you need to install bazelisk, if you don't have it already. Bazelisk manages Bazel versions and installs correct one. Follow the instructions for your platform on the bazelisk github page

You also need to install Git, if you don't have it already. Follow the instructions for your platform on the Git website.

Once you've installed bazelisk and Git, open a Terminal and clone the differential privacy directory into a local folder:

git clone https://github.com/google/differential-privacy.git

Navigate into the differential-privacy folder you just created, and build the differential privacy library and dependencies using bazelisk (note: ... is a part of the command and not a placeholder):

To build the C++ library, run:

cd cc
bazelisk build ...

To build the Go library, run:

cd go
bazelisk build ...

To build the Java library, run:

cd java
bazelisk build ...

To build the PipelineDP4j library, run:

cd pipelinedp4j
bazelisk build ...

To build Privacy on Beam, run:

cd privacy-on-beam
bazelisk build ...

You may need to install additional dependencies when building the PostgreSQL extension, for example on Ubuntu you will need these packages:

sudo apt-get install make libreadline-dev bison flex

Caveats of the DP building block libraries

Differential privacy requires some bound on maximum number of contributions each user can make to a single aggregation. The DP building block libraries don't perform such bounding: their implementation assumes that each user contributes only a fixed number of rows to each partition. That number can be configured by the user. The library neither verifies nor enforces this limit; it is the caller's responsibility to pre-process data to enforce this.

We chose not to implement this step at the DP building block level because it requires some global operation over the data: group by user, and aggregate or subsample the contributions of each user before passing them on to the DP building block aggregators. Given scalability constraints, this pre-processing must be done by a higher-level part of the infrastructure, typically a distributed processing framework: for example, Privacy on Beam relies on Apache Beam for this operation.

For more detail about our approach to building scalable end-to-end differential privacy frameworks, we recommend reading:

  1. Differential privacy computations in data pipelines reference doc, which describes how to build such a system using any data pipeline framework (e.g. Apache Beam).
  2. Our paper about differentially private SQL, which describes such a system. Even though the interface of Privacy on Beam is different, it conceptually uses the same framework as the one described in this paper.

Known issues

Our floating-point implementations are subject to the vulnerabilities described in Casacuberta et al. "Widespread Underestimation of Sensitivity in Differentially Private Libraries and How to Fix it" (specifically the rounding, repeated rounding, and re-ordering attacks). These vulnerabilities are particularly concerning when an attacker can control some of the contents of a dataset and/or its order. Our integer implementations are not subject to the vulnerabilities described in the paper (though note that Java does not have an integer implementation).

Please refer to our attack model to learn more about how to use our libraries in a safe way.

Support

We will continue to publish updates and improvements to the library. We are happy to accept contributions to this project. Please follow our guidelines when sending pull requests. We will respond to issues filed in this project. If we intend to stop publishing improvements and responding to issues we will publish notice here at least 3 months in advance.

License

Apache License 2.0

Support Disclaimer

This is not an officially supported Google product.

Reach out

We are always keen on learning about how you use this library and what use cases it helps you to solve. We have two communication channels:

Please refrain from sending any personal identifiable information. If you wish to delete a message you've previously sent, please contact us.

Related projects