Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add discrete Laplace noise w/ SumVec and Histogram #3302

Merged
merged 7 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ postgres-types = "0.2.6"
pretty_assertions = "1.4.0"
# Disable default features so that individual workspace crates can choose to
# re-enable them
prio = { version = "0.16.5", default-features = false, features = ["experimental"] }
prio = { version = "0.16.6", default-features = false, features = ["experimental"] }
prometheus = "0.13.4"
querystring = "1.1.0"
quickcheck = { version = "1.0.3", default-features = false }
Expand Down
177 changes: 141 additions & 36 deletions aggregator/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,55 +925,80 @@ impl<C: Clock> TaskAggregator<C> {
bits,
length,
chunk_length,
dp_strategy,
} => {
let vdaf = Prio3::new_sum_vec(2, *bits, *length, *chunk_length)?;
let verify_key = task.vdaf_verify_key()?;
VdafOps::Prio3SumVec(Arc::new(vdaf), verify_key)
VdafOps::Prio3SumVec(
Arc::new(vdaf),
verify_key,
vdaf_ops_strategies::Prio3SumVec::from_vdaf_dp_strategy(dp_strategy.clone()),
)
}

VdafInstance::Prio3SumVecField64MultiproofHmacSha256Aes128 {
proofs,
bits,
length,
chunk_length,
dp_strategy,
} => {
let vdaf = new_prio3_sum_vec_field64_multiproof_hmacsha256_aes128::<
ParallelSum<Field64, Mul<Field64>>,
>(*proofs, *bits, *length, *chunk_length)?;
let verify_key = task.vdaf_verify_key()?;
VdafOps::Prio3SumVecField64MultiproofHmacSha256Aes128(Arc::new(vdaf), verify_key)
VdafOps::Prio3SumVecField64MultiproofHmacSha256Aes128(
Arc::new(vdaf),
verify_key,
vdaf_ops_strategies::Prio3SumVec::from_vdaf_dp_strategy(dp_strategy.clone()),
)
}

VdafInstance::Prio3Histogram {
length,
chunk_length,
dp_strategy,
} => {
let vdaf = Prio3::new_histogram(2, *length, *chunk_length)?;
let verify_key = task.vdaf_verify_key()?;
VdafOps::Prio3Histogram(Arc::new(vdaf), verify_key)
VdafOps::Prio3Histogram(
Arc::new(vdaf),
verify_key,
vdaf_ops_strategies::Prio3Histogram::from_vdaf_dp_strategy(dp_strategy.clone()),
)
}

#[cfg(feature = "fpvec_bounded_l2")]
VdafInstance::Prio3FixedPointBoundedL2VecSum {
bitsize,
dp_strategy,
length,
} => {
match bitsize {
Prio3FixedPointBoundedL2VecSumBitSize::BitSize16 => {
let vdaf: Prio3FixedPointBoundedL2VecSum<FixedI16<U15>> =
Prio3::new_fixedpoint_boundedl2_vec_sum(2, *length)?;
let verify_key = task.vdaf_verify_key()?;
VdafOps::Prio3FixedPoint16BitBoundedL2VecSum(Arc::new(vdaf), verify_key, vdaf_ops_strategies::Prio3FixedPointBoundedL2VecSum::from_vdaf_dp_strategy(dp_strategy.clone()))
}
Prio3FixedPointBoundedL2VecSumBitSize::BitSize32 => {
let vdaf: Prio3FixedPointBoundedL2VecSum<FixedI32<U31>> =
Prio3::new_fixedpoint_boundedl2_vec_sum(2, *length)?;
let verify_key = task.vdaf_verify_key()?;
VdafOps::Prio3FixedPoint32BitBoundedL2VecSum(Arc::new(vdaf), verify_key, vdaf_ops_strategies::Prio3FixedPointBoundedL2VecSum::from_vdaf_dp_strategy(dp_strategy.clone()))
}
} => match bitsize {
Prio3FixedPointBoundedL2VecSumBitSize::BitSize16 => {
let vdaf: Prio3FixedPointBoundedL2VecSum<FixedI16<U15>> =
Prio3::new_fixedpoint_boundedl2_vec_sum(2, *length)?;
let verify_key = task.vdaf_verify_key()?;
VdafOps::Prio3FixedPoint16BitBoundedL2VecSum(
Arc::new(vdaf),
verify_key,
vdaf_ops_strategies::Prio3FixedPointBoundedL2VecSum::from_vdaf_dp_strategy(
dp_strategy.clone(),
),
)
}
}
Prio3FixedPointBoundedL2VecSumBitSize::BitSize32 => {
let vdaf: Prio3FixedPointBoundedL2VecSum<FixedI32<U31>> =
Prio3::new_fixedpoint_boundedl2_vec_sum(2, *length)?;
let verify_key = task.vdaf_verify_key()?;
VdafOps::Prio3FixedPoint32BitBoundedL2VecSum(
Arc::new(vdaf),
verify_key,
vdaf_ops_strategies::Prio3FixedPointBoundedL2VecSum::from_vdaf_dp_strategy(
dp_strategy.clone(),
),
)
}
},

VdafInstance::Poplar1 { bits } => {
let vdaf = Poplar1::new_turboshake128(*bits);
Expand Down Expand Up @@ -1164,19 +1189,60 @@ impl<C: Clock> TaskAggregator<C> {
}
}

#[cfg(feature = "fpvec_bounded_l2")]
mod vdaf_ops_strategies {
use std::sync::Arc;

use janus_core::vdaf::vdaf_dp_strategies;
use prio::dp::distributions::PureDpDiscreteLaplace;
#[cfg(feature = "fpvec_bounded_l2")]
use prio::dp::distributions::ZCdpDiscreteGaussian;

#[derive(Debug)]
pub enum Prio3Histogram {
NoDifferentialPrivacy,
PureDpDiscreteLaplace(Arc<PureDpDiscreteLaplace>),
}

impl Prio3Histogram {
pub fn from_vdaf_dp_strategy(dp_strategy: vdaf_dp_strategies::Prio3Histogram) -> Self {
match dp_strategy {
vdaf_dp_strategies::Prio3Histogram::NoDifferentialPrivacy => {
Prio3Histogram::NoDifferentialPrivacy
}
vdaf_dp_strategies::Prio3Histogram::PureDpDiscreteLaplace(s) => {
Prio3Histogram::PureDpDiscreteLaplace(Arc::new(s))
}
}
}
}

#[derive(Debug)]
pub enum Prio3SumVec {
NoDifferentialPrivacy,
PureDpDiscreteLaplace(Arc<PureDpDiscreteLaplace>),
}

impl Prio3SumVec {
pub fn from_vdaf_dp_strategy(dp_strategy: vdaf_dp_strategies::Prio3SumVec) -> Self {
match dp_strategy {
vdaf_dp_strategies::Prio3SumVec::NoDifferentialPrivacy => {
Prio3SumVec::NoDifferentialPrivacy
}
vdaf_dp_strategies::Prio3SumVec::PureDpDiscreteLaplace(s) => {
Prio3SumVec::PureDpDiscreteLaplace(Arc::new(s))
}
}
}
}

#[cfg(feature = "fpvec_bounded_l2")]
#[derive(Debug)]
pub enum Prio3FixedPointBoundedL2VecSum {
NoDifferentialPrivacy,
ZCdpDiscreteGaussian(Arc<ZCdpDiscreteGaussian>),
}

#[cfg(feature = "fpvec_bounded_l2")]
impl Prio3FixedPointBoundedL2VecSum {
pub fn from_vdaf_dp_strategy(
dp_strategy: vdaf_dp_strategies::Prio3FixedPointBoundedL2VecSum,
Expand All @@ -1199,12 +1265,21 @@ mod vdaf_ops_strategies {
enum VdafOps {
Prio3Count(Arc<Prio3Count>, VerifyKey<VERIFY_KEY_LENGTH>),
Prio3Sum(Arc<Prio3Sum>, VerifyKey<VERIFY_KEY_LENGTH>),
Prio3SumVec(Arc<Prio3SumVec>, VerifyKey<VERIFY_KEY_LENGTH>),
Prio3SumVec(
Arc<Prio3SumVec>,
VerifyKey<VERIFY_KEY_LENGTH>,
vdaf_ops_strategies::Prio3SumVec,
),
Prio3SumVecField64MultiproofHmacSha256Aes128(
Arc<Prio3SumVecField64MultiproofHmacSha256Aes128<ParallelSum<Field64, Mul<Field64>>>>,
VerifyKey<32>,
vdaf_ops_strategies::Prio3SumVec,
),
Prio3Histogram(
Arc<Prio3Histogram>,
VerifyKey<VERIFY_KEY_LENGTH>,
vdaf_ops_strategies::Prio3Histogram,
),
Prio3Histogram(Arc<Prio3Histogram>, VerifyKey<VERIFY_KEY_LENGTH>),
#[cfg(feature = "fpvec_bounded_l2")]
Prio3FixedPoint16BitBoundedL2VecSum(
Arc<Prio3FixedPointBoundedL2VecSum<FixedI16<U15>>>,
Expand Down Expand Up @@ -1255,18 +1330,28 @@ macro_rules! vdaf_ops_dispatch {
body
}

crate::aggregator::VdafOps::Prio3SumVec(vdaf, verify_key) => {
crate::aggregator::VdafOps::Prio3SumVec(vdaf, verify_key, _dp_strategy) => {
let $vdaf = vdaf;
let $verify_key = verify_key;
type $Vdaf = ::prio::vdaf::prio3::Prio3SumVec;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::vdaf::VERIFY_KEY_LENGTH;
type $DpStrategy = janus_core::dp::NoDifferentialPrivacy;
let $dp_strategy = &Arc::new(janus_core::dp::NoDifferentialPrivacy);
let body = $body;
body
match _dp_strategy {
vdaf_ops_strategies::Prio3SumVec::NoDifferentialPrivacy => {
type $DpStrategy = janus_core::dp::NoDifferentialPrivacy;
let $dp_strategy = &Arc::new(janus_core::dp::NoDifferentialPrivacy);
let body = $body;
body
}
vdaf_ops_strategies::Prio3SumVec::PureDpDiscreteLaplace(_strategy) => {
type $DpStrategy = ::prio::dp::distributions::PureDpDiscreteLaplace;
let $dp_strategy = &_strategy;
let body = $body;
body
}
}
}

crate::aggregator::VdafOps::Prio3SumVecField64MultiproofHmacSha256Aes128(vdaf, verify_key) => {
crate::aggregator::VdafOps::Prio3SumVecField64MultiproofHmacSha256Aes128(vdaf, verify_key, _dp_strategy) => {
let $vdaf = vdaf;
let $verify_key = verify_key;
type $Vdaf = ::janus_core::vdaf::Prio3SumVecField64MultiproofHmacSha256Aes128<
Expand All @@ -1276,21 +1361,41 @@ macro_rules! vdaf_ops_dispatch {
>,
>;
const $VERIFY_KEY_LENGTH: usize = 32;
type $DpStrategy = janus_core::dp::NoDifferentialPrivacy;
let $dp_strategy = &Arc::new(janus_core::dp::NoDifferentialPrivacy);
let body = $body;
body
match _dp_strategy {
vdaf_ops_strategies::Prio3SumVec::NoDifferentialPrivacy => {
type $DpStrategy = janus_core::dp::NoDifferentialPrivacy;
let $dp_strategy = &Arc::new(janus_core::dp::NoDifferentialPrivacy);
let body = $body;
body
}
vdaf_ops_strategies::Prio3SumVec::PureDpDiscreteLaplace(_strategy) => {
type $DpStrategy = ::prio::dp::distributions::PureDpDiscreteLaplace;
let $dp_strategy = &_strategy;
let body = $body;
body
}
}
}

crate::aggregator::VdafOps::Prio3Histogram(vdaf, verify_key) => {
crate::aggregator::VdafOps::Prio3Histogram(vdaf, verify_key, _dp_strategy) => {
let $vdaf = vdaf;
let $verify_key = verify_key;
type $Vdaf = ::prio::vdaf::prio3::Prio3Histogram;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::vdaf::VERIFY_KEY_LENGTH;
type $DpStrategy = janus_core::dp::NoDifferentialPrivacy;
let $dp_strategy = &Arc::new(janus_core::dp::NoDifferentialPrivacy);
let body = $body;
body
match _dp_strategy {
vdaf_ops_strategies::Prio3Histogram::NoDifferentialPrivacy => {
type $DpStrategy = janus_core::dp::NoDifferentialPrivacy;
let $dp_strategy = &Arc::new(janus_core::dp::NoDifferentialPrivacy);
let body = $body;
body
}
vdaf_ops_strategies::Prio3Histogram::PureDpDiscreteLaplace(_strategy) => {
type $DpStrategy = ::prio::dp::distributions::PureDpDiscreteLaplace;
let $dp_strategy = &_strategy;
let body = $body;
body
}
}
}

#[cfg(feature = "fpvec_bounded_l2")]
Expand Down
6 changes: 6 additions & 0 deletions aggregator/src/aggregator/aggregation_job_creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ impl<C: Clock + 'static> AggregationJobCreator<C> {
bits,
length,
chunk_length,
dp_strategy: _,
},
) => {
let vdaf = Arc::new(Prio3::new_sum_vec(2, *bits, *length, *chunk_length)?);
Expand All @@ -335,6 +336,7 @@ impl<C: Clock + 'static> AggregationJobCreator<C> {
bits,
length,
chunk_length,
dp_strategy: _,
},
) => {
let vdaf = Arc::new(new_prio3_sum_vec_field64_multiproof_hmacsha256_aes128::<
Expand All @@ -351,6 +353,7 @@ impl<C: Clock + 'static> AggregationJobCreator<C> {
VdafInstance::Prio3Histogram {
length,
chunk_length,
dp_strategy: _,
},
) => {
let vdaf = Arc::new(Prio3::new_histogram(2, *length, *chunk_length)?);
Expand Down Expand Up @@ -431,6 +434,7 @@ impl<C: Clock + 'static> AggregationJobCreator<C> {
bits,
length,
chunk_length,
dp_strategy: _,
},
) => {
let vdaf = Arc::new(Prio3::new_sum_vec(2, *bits, *length, *chunk_length)?);
Expand All @@ -452,6 +456,7 @@ impl<C: Clock + 'static> AggregationJobCreator<C> {
bits,
length,
chunk_length,
dp_strategy: _,
},
) => {
let vdaf = Arc::new(new_prio3_sum_vec_field64_multiproof_hmacsha256_aes128::<
Expand All @@ -473,6 +478,7 @@ impl<C: Clock + 'static> AggregationJobCreator<C> {
VdafInstance::Prio3Histogram {
length,
chunk_length,
dp_strategy: _,
},
) => {
let vdaf = Arc::new(Prio3::new_histogram(2, *length, *chunk_length)?);
Expand Down
Loading
Loading