From 31cbe96371d9800655f585e8bca44f4d25c5aedb Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 25 Jul 2024 09:15:58 -0500 Subject: [PATCH] Add a broad range check to DP integration tests --- integration_tests/tests/integration/in_cluster.rs | 9 +++++++++ integration_tests/tests/integration/janus.rs | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/integration_tests/tests/integration/in_cluster.rs b/integration_tests/tests/integration/in_cluster.rs index a31b5bb88..93d9e251f 100644 --- a/integration_tests/tests/integration/in_cluster.rs +++ b/integration_tests/tests/integration/in_cluster.rs @@ -33,6 +33,7 @@ use prio::{ dp::{ distributions::PureDpDiscreteLaplace, DifferentialPrivacyStrategy, PureDpBudget, Rational, }, + field::{Field128, FieldElementWithInteger}, vdaf::prio3::Prio3, }; use std::{env, iter, str::FromStr, time::Duration}; @@ -977,6 +978,10 @@ async fn in_cluster_histogram_dp_noise() { // large (drawn from Laplace_Z(20) + Laplace_Z(20)), and it is highly unlikely that all 100 // noise values will be zero simultaneously. assert_ne!(aggregate_result, un_noised_result); + + assert!(aggregate_result + .iter() + .all(|x| *x < Field128::modulus() / 4 || *x > Field128::modulus() / 4 * 3)); } #[tokio::test(flavor = "multi_thread")] @@ -1041,4 +1046,8 @@ async fn in_cluster_sumvec_dp_noise() { // large (drawn from Laplace_Z(150) + Laplace_Z(150)), and it is highly unlikely that all 50 // noise values will be zero simultaneously. assert_ne!(aggregate_result, un_noised_result); + + assert!(aggregate_result + .iter() + .all(|x| *x < Field128::modulus() / 4 || *x > Field128::modulus() / 4 * 3)); } diff --git a/integration_tests/tests/integration/janus.rs b/integration_tests/tests/integration/janus.rs index 82be09a84..1b8e55f52 100644 --- a/integration_tests/tests/integration/janus.rs +++ b/integration_tests/tests/integration/janus.rs @@ -22,6 +22,7 @@ use prio::{ dp::{ distributions::PureDpDiscreteLaplace, DifferentialPrivacyStrategy, PureDpBudget, Rational, }, + field::{Field128, FieldElementWithInteger}, vdaf::{dummy, prio3::Prio3}, }; use std::{iter, time::Duration}; @@ -514,6 +515,10 @@ async fn janus_in_process_histogram_dp_noise() { // large (drawn from Laplace_Z(20) + Laplace_Z(20)), and it is highly unlikely that all 100 // noise values will be zero simultaneously. assert_ne!(aggregate_result, un_noised_result); + + assert!(aggregate_result + .iter() + .all(|x| *x < Field128::modulus() / 4 || *x > Field128::modulus() / 4 * 3)); } #[tokio::test(flavor = "multi_thread")] @@ -574,4 +579,8 @@ async fn janus_in_process_sumvec_dp_noise() { // large (drawn from Laplace_Z(150) + Laplace_Z(150)), and it is highly unlikely that all 50 // noise values will be zero simultaneously. assert_ne!(aggregate_result, un_noised_result); + + assert!(aggregate_result + .iter() + .all(|x| *x < Field128::modulus() / 4 || *x > Field128::modulus() / 4 * 3)); }