From 84e1d6835e8bec489c0d00cbc4ecd83a703c85c0 Mon Sep 17 00:00:00 2001 From: Andi Cuko Date: Wed, 11 Dec 2024 12:55:03 +0100 Subject: [PATCH 1/5] fix gaussian tau --- src/differential_privacy/dp_event.rs | 6 +++--- src/differential_privacy/group_by.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/differential_privacy/dp_event.rs b/src/differential_privacy/dp_event.rs index bb428b8a..f98776da 100644 --- a/src/differential_privacy/dp_event.rs +++ b/src/differential_privacy/dp_event.rs @@ -169,9 +169,9 @@ pub fn gaussian_noise_multiplier(epsilon: f64, delta: f64) -> f64 { ((2. * (1.25_f64 / delta).ln()).sqrt() / epsilon).clamp(0.0, f64::MAX) } -pub fn gaussian_tau(epsilon: f64, delta: f64, sensitivity: f64) -> f64 { +pub fn gaussian_tau(epsilon: f64, delta: f64, max_privacy_unit_groups: f64) -> f64 { let dist = Normal::new(0.0, 1.0).unwrap(); - let scale = gaussian_noise(epsilon, delta, sensitivity); + let scale = gaussian_noise(epsilon, delta, max_privacy_unit_groups.sqrt()); // TODO: we want to overestimate tau - 1. + scale * dist.inverse_cdf((1. - delta / 2.).powf(1. / sensitivity)) + F64_PREC + 1. + scale * dist.inverse_cdf((1. - delta).powf(1. / max_privacy_unit_groups)) } diff --git a/src/differential_privacy/group_by.rs b/src/differential_privacy/group_by.rs index fb26ff2e..58877734 100644 --- a/src/differential_privacy/group_by.rs +++ b/src/differential_privacy/group_by.rs @@ -107,7 +107,7 @@ impl PupRelation { // Apply noise let name_sigmas = vec![( COUNT_DISTINCT_PID, - dp_event::gaussian_noise(epsilon, delta, max_privacy_unit_groups as f64), + dp_event::gaussian_noise(epsilon, delta, (max_privacy_unit_groups as f64).sqrt()), )]; let rel = rel.add_gaussian_noise(&name_sigmas); From 6782a0ce99e66a9b7ea7ce9adc2494964e20deda Mon Sep 17 00:00:00 2001 From: Andi Cuko Date: Wed, 11 Dec 2024 12:55:56 +0100 Subject: [PATCH 2/5] version and changelog --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b87ad198..f76d4046 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [0.9.27] - 2024-12-11 +### Fixed +- Fix gaussian tau. + ## [0.9.26] - 2024-12-05 ### Fixed diff --git a/Cargo.toml b/Cargo.toml index 76d25acd..7d1b4851 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Nicolas Grislain "] name = "qrlew" -version = "0.9.26" +version = "0.9.27" edition = "2021" description = "Sarus Qrlew Engine" documentation = "https://docs.rs/qrlew" From ebb4032c9b56ad2f5c7937bc949d84e5290740db Mon Sep 17 00:00:00 2001 From: Andi Cuko Date: Wed, 11 Dec 2024 14:00:02 +0100 Subject: [PATCH 3/5] clean --- src/differential_privacy/dp_event.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/differential_privacy/dp_event.rs b/src/differential_privacy/dp_event.rs index f98776da..31345a57 100644 --- a/src/differential_privacy/dp_event.rs +++ b/src/differential_privacy/dp_event.rs @@ -1,8 +1,5 @@ use itertools::Itertools; -use statrs::{ - distribution::{ContinuousCDF, Normal}, - prec::F64_PREC, -}; +use statrs::distribution::{ContinuousCDF, Normal}; use std::fmt; /// An object inspired by Google's [DPEvent](https://github.com/google/differential-privacy/blob/main/python/dp_accounting/dp_event.py) From 502d29d168596d74950612ebaf3818bdf9ac50b5 Mon Sep 17 00:00:00 2001 From: Andi Cuko Date: Wed, 11 Dec 2024 14:47:43 +0100 Subject: [PATCH 4/5] git fix tokio dependency because of a breaking change in the last version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 7d1b4851..00d016a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ r2d2_postgres = "0.18" rust_decimal = { version = "1.35", features = [ "tokio-pg" ] } statrs = "0.16.0" sqlx = { version = "0.6.3", features = ["mssql", "runtime-tokio-native-tls", "offline", "any"], optional = true } -tokio = { version = "1", features = ["full"], optional = true } +tokio = { version = "1.37.0", features = ["full"], optional = true } # bigquery dependencies gcp-bigquery-client = { version = "=0.20.0", optional = true } From ad96e683428414819dc0e27e532d66b6eb245d30 Mon Sep 17 00:00:00 2001 From: Andi Cuko Date: Thu, 12 Dec 2024 10:22:55 +0100 Subject: [PATCH 5/5] change default value for max_privacy_unit_groups --- src/differential_privacy/dp_parameters.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/differential_privacy/dp_parameters.rs b/src/differential_privacy/dp_parameters.rs index de623413..3cd389c3 100644 --- a/src/differential_privacy/dp_parameters.rs +++ b/src/differential_privacy/dp_parameters.rs @@ -39,7 +39,7 @@ impl DpParameters { pub fn from_epsilon_delta(epsilon: f64, delta: f64) -> DpParameters { // These default values are underestimating the bounds - DpParameters::new(epsilon, delta, 0.5, 100.0, 0.1, 1) + DpParameters::new(epsilon, delta, 0.5, 100.0, 0.1, 5) } pub fn with_tau_thresholding_share(self, tau_thresholding_share: f64) -> DpParameters {