diff --git a/ipa-core/src/bin/report_collector.rs b/ipa-core/src/bin/report_collector.rs index 42b765b50..80dbc078d 100644 --- a/ipa-core/src/bin/report_collector.rs +++ b/ipa-core/src/bin/report_collector.rs @@ -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, }, }; @@ -171,7 +171,6 @@ async fn main() -> Result<(), Box> { IpaSecurityModel::SemiHonest, config, &clients, - IpaQueryStyle::Oprf, ) .await? } @@ -182,7 +181,6 @@ async fn main() -> Result<(), Box> { IpaSecurityModel::Malicious, config, &clients, - IpaQueryStyle::Oprf, ) .await? } @@ -195,7 +193,6 @@ async fn main() -> Result<(), Box> { IpaSecurityModel::Malicious, ipa_query_config, &clients, - IpaQueryStyle::Oprf, encrypted_inputs, ) .await? @@ -209,7 +206,6 @@ async fn main() -> Result<(), Box> { IpaSecurityModel::SemiHonest, ipa_query_config, &clients, - IpaQueryStyle::Oprf, encrypted_inputs, ) .await? @@ -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), } } @@ -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> { - 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, @@ -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::( - 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::( + 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)?; @@ -361,10 +342,9 @@ async fn ipa_test( security_model: IpaSecurityModel, ipa_query_config: IpaQueryConfig, helper_clients: &[MpcHelperClient; 3], - query_style: IpaQueryStyle, ) -> Result<(), Box> { 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::().collect::>(); let query_config = QueryConfig { @@ -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 @@ -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::( - 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::( + 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)?; diff --git a/ipa-core/src/test_fixture/ipa.rs b/ipa-core/src/test_fixture/ipa.rs index fd91081db..c38a4bc9f 100644 --- a/ipa-core/src/test_fixture/ipa.rs +++ b/ipa-core/src/test_fixture/ipa.rs @@ -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,