Skip to content

Commit

Permalink
Add a broad range check to DP integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
divergentdave committed Jul 25, 2024
1 parent cbc912c commit f095581
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions integration_tests/tests/integration/in_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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 > 3 * Field128::modulus() / 4));
}

#[tokio::test(flavor = "multi_thread")]
Expand Down Expand Up @@ -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 > 3 * Field128::modulus() / 4));
}
9 changes: 9 additions & 0 deletions integration_tests/tests/integration/janus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use prio::{
dp::{
distributions::PureDpDiscreteLaplace, DifferentialPrivacyStrategy, PureDpBudget, Rational,
},
field::{Field128, FieldElementWithInteger},
vdaf::{dummy, prio3::Prio3},
};
use std::{iter, time::Duration};
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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));
}

0 comments on commit f095581

Please sign in to comment.