Skip to content

Commit

Permalink
Merge pull request #1287 from benjaminsavage/dead_code
Browse files Browse the repository at this point in the history
Kill some dead code
  • Loading branch information
benjaminsavage authored Sep 19, 2024
2 parents b511821 + 03dfb30 commit f847d28
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 60 deletions.
86 changes: 30 additions & 56 deletions ipa-core/src/bin/report_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use ipa_core::{
net::MpcHelperClient,
report::{EncryptedOprfReportStreams, DEFAULT_KEY_ID},
test_fixture::{
ipa::{ipa_in_the_clear, CappingOrder, IpaQueryStyle, IpaSecurityModel, TestRawDataRecord},
ipa::{ipa_in_the_clear, CappingOrder, IpaSecurityModel, TestRawDataRecord},
EventGenerator, EventGeneratorConfig,
},
};
Expand Down Expand Up @@ -171,7 +171,6 @@ async fn main() -> Result<(), Box<dyn Error>> {
IpaSecurityModel::SemiHonest,
config,
&clients,
IpaQueryStyle::Oprf,
)
.await?
}
Expand All @@ -182,7 +181,6 @@ async fn main() -> Result<(), Box<dyn Error>> {
IpaSecurityModel::Malicious,
config,
&clients,
IpaQueryStyle::Oprf,
)
.await?
}
Expand All @@ -195,7 +193,6 @@ async fn main() -> Result<(), Box<dyn Error>> {
IpaSecurityModel::Malicious,
ipa_query_config,
&clients,
IpaQueryStyle::Oprf,
encrypted_inputs,
)
.await?
Expand All @@ -209,7 +206,6 @@ async fn main() -> Result<(), Box<dyn Error>> {
IpaSecurityModel::SemiHonest,
ipa_query_config,
&clients,
IpaQueryStyle::Oprf,
encrypted_inputs,
)
.await?
Expand Down Expand Up @@ -245,20 +241,10 @@ fn gen_inputs(
Ok(())
}

/// Panics
/// if (security_model, query_style) tuple is undefined
fn get_query_type(
security_model: IpaSecurityModel,
query_style: &IpaQueryStyle,
ipa_query_config: IpaQueryConfig,
) -> QueryType {
match (security_model, query_style) {
(IpaSecurityModel::SemiHonest, IpaQueryStyle::Oprf) => {
QueryType::SemiHonestOprfIpa(ipa_query_config)
}
(IpaSecurityModel::Malicious, IpaQueryStyle::Oprf) => {
QueryType::MaliciousOprfIpa(ipa_query_config)
}
fn get_query_type(security_model: IpaSecurityModel, ipa_query_config: IpaQueryConfig) -> QueryType {
match security_model {
IpaSecurityModel::SemiHonest => QueryType::SemiHonestOprfIpa(ipa_query_config),
IpaSecurityModel::Malicious => QueryType::MaliciousOprfIpa(ipa_query_config),
}
}

Expand Down Expand Up @@ -306,10 +292,9 @@ async fn ipa(
security_model: IpaSecurityModel,
ipa_query_config: IpaQueryConfig,
helper_clients: &[MpcHelperClient; 3],
query_style: IpaQueryStyle,
encrypted_inputs: &EncryptedInputs,
) -> Result<(), Box<dyn Error>> {
let query_type = get_query_type(security_model, &query_style, ipa_query_config);
let query_type = get_query_type(security_model, ipa_query_config);

let files = [
&encrypted_inputs.enc_input_file1,
Expand All @@ -331,21 +316,17 @@ async fn ipa(
.expect("Unable to create query!");

tracing::info!("Starting query for OPRF");
let actual = match query_style {
IpaQueryStyle::Oprf => {
// the value for histogram values (BA32) must be kept in sync with the server-side
// implementation, otherwise a runtime reconstruct error will be generated.
// see ipa-core/src/query/executor.rs
run_query_and_validate::<BA32>(
encrypted_oprf_report_streams.streams,
encrypted_oprf_report_streams.query_size,
helper_clients,
query_id,
ipa_query_config,
)
.await
}
};
// the value for histogram values (BA32) must be kept in sync with the server-side
// implementation, otherwise a runtime reconstruct error will be generated.
// see ipa-core/src/query/executor.rs
let actual = run_query_and_validate::<BA32>(
encrypted_oprf_report_streams.streams,
encrypted_oprf_report_streams.query_size,
helper_clients,
query_id,
ipa_query_config,
)
.await;

if let Some(ref path) = args.output_file {
write_ipa_output_file(path, &actual)?;
Expand All @@ -361,10 +342,9 @@ async fn ipa_test(
security_model: IpaSecurityModel,
ipa_query_config: IpaQueryConfig,
helper_clients: &[MpcHelperClient; 3],
query_style: IpaQueryStyle,
) -> Result<(), Box<dyn Error>> {
let input = InputSource::from(&args.input);
let query_type = get_query_type(security_model, &query_style, ipa_query_config);
let query_type = get_query_type(security_model, ipa_query_config);

let input_rows = input.iter::<TestRawDataRecord>().collect::<Vec<_>>();
let query_config = QueryConfig {
Expand All @@ -383,9 +363,7 @@ async fn ipa_test(
ipa_query_config.per_user_credit_cap,
ipa_query_config.attribution_window_seconds,
ipa_query_config.max_breakdown_key,
&(match query_style {
IpaQueryStyle::Oprf => CappingOrder::CapMostRecentFirst,
}),
&CappingOrder::CapMostRecentFirst,
);

// pad the output vector to the max breakdown key, to make sure it is aligned with the MPC results
Expand All @@ -401,21 +379,17 @@ async fn ipa_test(
let Some(key_registries) = key_registries.init_from(network) else {
panic!("could not load network file")
};
let actual = match query_style {
IpaQueryStyle::Oprf => {
// the value for histogram values (BA32) must be kept in sync with the server-side
// implementation, otherwise a runtime reconstruct error will be generated.
// see ipa-core/src/query/executor.rs
playbook_oprf_ipa::<BA32, _>(
input_rows,
helper_clients,
query_id,
ipa_query_config,
Some((DEFAULT_KEY_ID, key_registries)),
)
.await
}
};
// the value for histogram values (BA32) must be kept in sync with the server-side
// implementation, otherwise a runtime reconstruct error will be generated.
// see ipa-core/src/query/executor.rs
let actual = playbook_oprf_ipa::<BA32, _>(
input_rows,
helper_clients,
query_id,
ipa_query_config,
Some((DEFAULT_KEY_ID, key_registries)),
)
.await;

if let Some(ref path) = args.output_file {
write_ipa_output_file(path, &actual)?;
Expand Down
4 changes: 0 additions & 4 deletions ipa-core/src/test_fixture/ipa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ pub enum IpaSecurityModel {
Malicious,
}

pub enum IpaQueryStyle {
Oprf,
}

#[derive(Debug, Clone, Ord, PartialEq, PartialOrd, Eq)]
pub struct TestRawDataRecord {
pub timestamp: u64,
Expand Down

0 comments on commit f847d28

Please sign in to comment.