Skip to content

Commit

Permalink
remove QueryType relaxed DP (#1263)
Browse files Browse the repository at this point in the history
Co-authored-by: Benjamin Case <[email protected]>
  • Loading branch information
bmcase and Benjamin Case authored Sep 9, 2024
1 parent c431ed1 commit f199c46
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 95 deletions.
2 changes: 1 addition & 1 deletion ipa-core/src/bin/report_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ async fn ipa(
let query_type: QueryType;
match (security_model, &query_style) {
(IpaSecurityModel::SemiHonest, IpaQueryStyle::Oprf) => {
query_type = QueryType::OprfIpaRelaxedDpPadding(ipa_query_config);
query_type = QueryType::OprfIpa(ipa_query_config);
}
(IpaSecurityModel::Malicious, IpaQueryStyle::Oprf) => {
panic!("OPRF for malicious is not implemented as yet")
Expand Down
5 changes: 0 additions & 5 deletions ipa-core/src/helpers/transport/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,13 @@ pub enum QueryType {
TestMultiply,
#[cfg(any(test, feature = "test-fixture", feature = "cli"))]
TestAddInPrimeField,
#[cfg(any(test, feature = "test-fixture", feature = "cli"))]
OprfIpaRelaxedDpPadding(IpaQueryConfig),
OprfIpa(IpaQueryConfig),
}

impl QueryType {
/// TODO: strum
pub const TEST_MULTIPLY_STR: &'static str = "test-multiply";
pub const TEST_ADD_STR: &'static str = "test-add";
pub const OPRF_IPA_RELAXED_DP_PADDING_STR: &'static str = "oprf_ipa_relaxed_dp_padding";
pub const OPRF_IPA_STR: &'static str = "oprf_ipa";
}

Expand All @@ -219,8 +216,6 @@ impl AsRef<str> for QueryType {
QueryType::TestMultiply => Self::TEST_MULTIPLY_STR,
#[cfg(any(test, feature = "cli", feature = "test-fixture"))]
QueryType::TestAddInPrimeField => Self::TEST_ADD_STR,
#[cfg(any(test, feature = "cli", feature = "test-fixture"))]
QueryType::OprfIpaRelaxedDpPadding(_) => Self::OPRF_IPA_RELAXED_DP_PADDING_STR,
QueryType::OprfIpa(_) => Self::OPRF_IPA_STR,
}
}
Expand Down
26 changes: 0 additions & 26 deletions ipa-core/src/net/http_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ pub mod query {
QueryType::TEST_MULTIPLY_STR => Ok(QueryType::TestMultiply),
#[cfg(any(test, feature = "cli", feature = "test-fixture"))]
QueryType::TEST_ADD_STR => Ok(QueryType::TestAddInPrimeField),
#[cfg(any(test, feature = "cli", feature = "test-fixture"))]
QueryType::OPRF_IPA_RELAXED_DP_PADDING_STR => {
let Query(q) = req.extract().await?;
Ok(QueryType::OprfIpaRelaxedDpPadding(q))
}
QueryType::OPRF_IPA_STR => {
let Query(q) = req.extract().await?;
Ok(QueryType::OprfIpa(q))
Expand All @@ -153,27 +148,6 @@ pub mod query {
match self.query_type {
#[cfg(any(test, feature = "test-fixture", feature = "cli"))]
QueryType::TestMultiply | QueryType::TestAddInPrimeField => Ok(()),
#[cfg(any(test, feature = "test-fixture", feature = "cli"))]
QueryType::OprfIpaRelaxedDpPadding(config) => {
write!(
f,
"&per_user_credit_cap={}&max_breakdown_key={}&with_dp={}&epsilon={}",
config.per_user_credit_cap,
config.max_breakdown_key,
config.with_dp,
config.epsilon,
)?;

if config.plaintext_match_keys {
write!(f, "&plaintext_match_keys=true")?;
}

if let Some(window) = config.attribution_window_seconds {
write!(f, "&attribution_window_seconds={}", window.get())?;
}

Ok(())
}
QueryType::OprfIpa(config) => {
write!(
f,
Expand Down
26 changes: 3 additions & 23 deletions ipa-core/src/net/server/handlers/query/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ mod tests {
async fn create_test_ipa_no_attr_window() {
create_test(
QueryConfig::new(
QueryType::OprfIpaRelaxedDpPadding(IpaQueryConfig {
QueryType::OprfIpa(IpaQueryConfig {
per_user_credit_cap: 1,
max_breakdown_key: 1,
attribution_window_seconds: None,
Expand All @@ -108,26 +108,6 @@ mod tests {

#[tokio::test]
async fn create_test_ipa_no_attr_window_with_dp() {
create_test(
QueryConfig::new(
QueryType::OprfIpaRelaxedDpPadding(IpaQueryConfig {
per_user_credit_cap: 8,
max_breakdown_key: 20,
attribution_window_seconds: None,
with_dp: 1,
epsilon: 5.0,
plaintext_match_keys: true,
}),
FieldType::Fp32BitPrime,
1,
)
.unwrap(),
)
.await;
}

#[tokio::test]
async fn create_test_ipa_no_attr_window_with_dp_default_padding() {
create_test(
QueryConfig::new(
QueryType::OprfIpa(IpaQueryConfig {
Expand All @@ -151,7 +131,7 @@ mod tests {
create_test(QueryConfig {
size: 1.try_into().unwrap(),
field_type: FieldType::Fp32BitPrime,
query_type: QueryType::OprfIpaRelaxedDpPadding(IpaQueryConfig {
query_type: QueryType::OprfIpa(IpaQueryConfig {
per_user_credit_cap: 1,
max_breakdown_key: 1,
attribution_window_seconds: NonZeroU32::new(86_400),
Expand Down Expand Up @@ -258,7 +238,7 @@ mod tests {
fn default() -> Self {
Self {
field_type: format!("{:?}", FieldType::Fp32BitPrime),
query_type: QueryType::OPRF_IPA_RELAXED_DP_PADDING_STR.to_string(),
query_type: QueryType::OPRF_IPA_STR.to_string(),
per_user_credit_cap: "1".into(),
max_breakdown_key: "1".into(),
attribution_window_seconds: None,
Expand Down
41 changes: 2 additions & 39 deletions ipa-core/src/query/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,6 @@ pub fn execute<R: PrivateKeyRegistry>(
}
// TODO(953): This is really using BA32, not Fp32bitPrime. The `FieldType` mechanism needs
// to be reworked.
#[cfg(any(test, feature = "cli", feature = "test-fixture"))]
(QueryType::OprfIpaRelaxedDpPadding(ipa_config), FieldType::Fp32BitPrime) => do_query(
config,
gateway,
input,
move |prss, gateway, config, input| {
let ctx = SemiHonestContext::new(prss, gateway);
Box::pin(
OprfIpaQuery::<BA32, R>::new(ipa_config, key_registry)
.execute(ctx, config.size, input)
.then(|res| ready(res.map(|out| Box::new(out) as Box<dyn Result>))),
)
},
),
// TODO(953): This is really using BA32, not Fp32bitPrime. The `FieldType` mechanism needs
// to be reworked.
(QueryType::OprfIpa(ipa_config), FieldType::Fp32BitPrime) => do_query(
config,
gateway,
Expand All @@ -132,13 +116,8 @@ pub fn execute<R: PrivateKeyRegistry>(
),
// TODO(953): This is not doing anything differently than the Fp32BitPrime case, except
// using 16 bits for histogram values
#[cfg(any(
test,
feature = "cli",
feature = "test-fixture",
feature = "weak-field"
))]
(QueryType::OprfIpaRelaxedDpPadding(ipa_config), FieldType::Fp31) => do_query(
#[cfg(any(test, feature = "weak-field"))]
(QueryType::OprfIpa(ipa_config), FieldType::Fp31) => do_query(
config,
gateway,
input,
Expand All @@ -154,22 +133,6 @@ pub fn execute<R: PrivateKeyRegistry>(
)
},
),
// TODO(953): This is really using BA32, not Fp32bitPrime. The `FieldType` mechanism needs
// to be reworked.
#[cfg(any(test, feature = "weak-field"))]
(QueryType::OprfIpa(ipa_config), FieldType::Fp31) => do_query(
config,
gateway,
input,
move |prss, gateway, config, input| {
let ctx = SemiHonestContext::new(prss, gateway);
Box::pin(
OprfIpaQuery::<BA32, R>::new(ipa_config, key_registry)
.execute(ctx, config.size, input)
.then(|res| ready(res.map(|out| Box::new(out) as Box<dyn Result>))),
)
},
),
}
}

Expand Down
2 changes: 1 addition & 1 deletion ipa-core/src/query/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ mod tests {
QueryConfig {
size: record_count.try_into().unwrap(),
field_type: FieldType::Fp31,
query_type: QueryType::OprfIpaRelaxedDpPadding(IpaQueryConfig {
query_type: QueryType::OprfIpa(IpaQueryConfig {
per_user_credit_cap: 8,
max_breakdown_key: 3,
attribution_window_seconds: None,
Expand Down

0 comments on commit f199c46

Please sign in to comment.