Skip to content

Commit

Permalink
break up janus_core::task
Browse files Browse the repository at this point in the history
Moves handling of authentication tokens to a new module
`janus_core::auth_tokens`. Once that's gone, the only thing of substance
left is `enum VdafInstance` and the macros for dispatching on VDAFs, so
that module is renamed to `janus_core::vdaf` to better describe its
purpose.
  • Loading branch information
tgeoghegan committed Sep 25, 2023
1 parent fde0ff7 commit e6ab04d
Show file tree
Hide file tree
Showing 42 changed files with 540 additions and 522 deletions.
23 changes: 12 additions & 11 deletions aggregator/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ use janus_aggregator_core::{
#[cfg(feature = "test-util")]
use janus_core::test_util::dummy_vdaf;
use janus_core::{
auth_tokens::AuthenticationToken,
hpke::{self, HpkeApplicationInfo, HpkeKeypair, Label},
http::response_to_problem_details,
task::{AuthenticationToken, VdafInstance, VERIFY_KEY_LENGTH},
time::{Clock, DurationExt, IntervalExt, TimeExt},
vdaf::{VdafInstance, VERIFY_KEY_LENGTH},
};
use janus_messages::{
problem_type::DapProblemType,
Expand Down Expand Up @@ -1075,39 +1076,39 @@ macro_rules! vdaf_ops_dispatch {
let $vdaf = vdaf;
let $verify_key = verify_key;
type $Vdaf = ::prio::vdaf::prio3::Prio3Count;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::task::VERIFY_KEY_LENGTH;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::vdaf::VERIFY_KEY_LENGTH;
$body
}

crate::aggregator::VdafOps::Prio3CountVec(vdaf, verify_key) => {
let $vdaf = vdaf;
let $verify_key = verify_key;
type $Vdaf = ::prio::vdaf::prio3::Prio3SumVecMultithreaded;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::task::VERIFY_KEY_LENGTH;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::vdaf::VERIFY_KEY_LENGTH;
$body
}

crate::aggregator::VdafOps::Prio3Sum(vdaf, verify_key) => {
let $vdaf = vdaf;
let $verify_key = verify_key;
type $Vdaf = ::prio::vdaf::prio3::Prio3Sum;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::task::VERIFY_KEY_LENGTH;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::vdaf::VERIFY_KEY_LENGTH;
$body
}

crate::aggregator::VdafOps::Prio3SumVec(vdaf, verify_key) => {
let $vdaf = vdaf;
let $verify_key = verify_key;
type $Vdaf = ::prio::vdaf::prio3::Prio3SumVecMultithreaded;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::task::VERIFY_KEY_LENGTH;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::vdaf::VERIFY_KEY_LENGTH;
$body
}

crate::aggregator::VdafOps::Prio3Histogram(vdaf, verify_key) => {
let $vdaf = vdaf;
let $verify_key = verify_key;
type $Vdaf = ::prio::vdaf::prio3::Prio3Histogram;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::task::VERIFY_KEY_LENGTH;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::vdaf::VERIFY_KEY_LENGTH;
$body
}

Expand All @@ -1117,7 +1118,7 @@ macro_rules! vdaf_ops_dispatch {
let $verify_key = verify_key;
type $Vdaf =
::prio::vdaf::prio3::Prio3FixedPointBoundedL2VecSumMultithreaded<FixedI16<U15>>;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::task::VERIFY_KEY_LENGTH;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::vdaf::VERIFY_KEY_LENGTH;
$body
}

Expand All @@ -1127,7 +1128,7 @@ macro_rules! vdaf_ops_dispatch {
let $verify_key = verify_key;
type $Vdaf =
::prio::vdaf::prio3::Prio3FixedPointBoundedL2VecSumMultithreaded<FixedI32<U31>>;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::task::VERIFY_KEY_LENGTH;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::vdaf::VERIFY_KEY_LENGTH;
$body
}

Expand All @@ -1137,15 +1138,15 @@ macro_rules! vdaf_ops_dispatch {
let $verify_key = verify_key;
type $Vdaf =
::prio::vdaf::prio3::Prio3FixedPointBoundedL2VecSumMultithreaded<FixedI64<U63>>;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::task::VERIFY_KEY_LENGTH;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::vdaf::VERIFY_KEY_LENGTH;
$body
}

crate::aggregator::VdafOps::Poplar1(vdaf, verify_key) => {
let $vdaf = vdaf;
let $verify_key = verify_key;
type $Vdaf = ::prio::vdaf::poplar1::Poplar1<::prio::vdaf::xof::XofShake128, 16>;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::task::VERIFY_KEY_LENGTH;
const $VERIFY_KEY_LENGTH: usize = ::janus_core::vdaf::VERIFY_KEY_LENGTH;
$body
}

Expand Down Expand Up @@ -3132,9 +3133,9 @@ mod tests {
self, test_util::generate_test_hpke_config_and_private_key_with_id,
HpkeApplicationInfo, HpkeKeypair, Label,
},
task::{VdafInstance, VERIFY_KEY_LENGTH},
test_util::install_test_trace_subscriber,
time::{Clock, MockClock, TimeExt},
vdaf::{VdafInstance, VERIFY_KEY_LENGTH},
};
use janus_messages::{
query_type::TimeInterval, Duration, Extension, HpkeCiphertext, HpkeConfig, HpkeConfigId,
Expand Down
3 changes: 2 additions & 1 deletion aggregator/src/aggregator/aggregate_init_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ use janus_aggregator_core::{
test_util::noop_meter,
};
use janus_core::{
task::{AuthenticationToken, VdafInstance, DAP_AUTH_HEADER},
auth_tokens::{AuthenticationToken, DAP_AUTH_HEADER},
test_util::{dummy_vdaf, install_test_trace_subscriber, run_vdaf, VdafTranscript},
time::{Clock, MockClock, TimeExt as _},
vdaf::VdafInstance,
};
use janus_messages::{
query_type::TimeInterval, AggregationJobId, AggregationJobInitializeReq, AggregationJobResp,
Expand Down
2 changes: 1 addition & 1 deletion aggregator/src/aggregator/aggregation_job_continue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ mod tests {
test_util::noop_meter,
};
use janus_core::{
task::{VdafInstance, VERIFY_KEY_LENGTH},
test_util::install_test_trace_subscriber,
time::{IntervalExt, MockClock},
vdaf::{VdafInstance, VERIFY_KEY_LENGTH},
};
use janus_messages::{
query_type::TimeInterval, AggregationJobContinueReq, AggregationJobId, AggregationJobResp,
Expand Down
4 changes: 2 additions & 2 deletions aggregator/src/aggregator/aggregation_job_creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use janus_aggregator_core::{
task::{self, Task},
};
use janus_core::{
task::{VdafInstance, VERIFY_KEY_LENGTH},
time::{Clock, DurationExt as _, TimeExt as _},
vdaf::{VdafInstance, VERIFY_KEY_LENGTH},
};
use janus_messages::{
query_type::{FixedSize, TimeInterval},
Expand Down Expand Up @@ -706,9 +706,9 @@ mod tests {
test_util::noop_meter,
};
use janus_core::{
task::{VdafInstance, VERIFY_KEY_LENGTH},
test_util::{dummy_vdaf, install_test_trace_subscriber},
time::{Clock, DurationExt, IntervalExt, MockClock, TimeExt},
vdaf::{VdafInstance, VERIFY_KEY_LENGTH},
};
use janus_messages::{
codec::ParameterizedDecode,
Expand Down
2 changes: 1 addition & 1 deletion aggregator/src/aggregator/aggregation_job_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -931,9 +931,9 @@ mod tests {
self, test_util::generate_test_hpke_config_and_private_key, HpkeApplicationInfo, Label,
},
report_id::ReportIdChecksumExt,
task::{VdafInstance, VERIFY_KEY_LENGTH},
test_util::{install_test_trace_subscriber, run_vdaf, runtime::TestRuntimeManager},
time::{Clock, IntervalExt, MockClock, TimeExt},
vdaf::{VdafInstance, VERIFY_KEY_LENGTH},
Runtime,
};
use janus_messages::{
Expand Down
2 changes: 1 addition & 1 deletion aggregator/src/aggregator/collection_job_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,13 @@ mod tests {
test_util::noop_meter,
};
use janus_core::{
task::VdafInstance,
test_util::{
dummy_vdaf::{self, AggregationParam},
install_test_trace_subscriber,
runtime::TestRuntimeManager,
},
time::{Clock, IntervalExt, MockClock, TimeExt},
vdaf::VdafInstance,
Runtime,
};
use janus_messages::{
Expand Down
3 changes: 2 additions & 1 deletion aggregator/src/aggregator/collection_job_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ use janus_aggregator_core::{
test_util::noop_meter,
};
use janus_core::{
auth_tokens::AuthenticationToken,
hpke::{
self, test_util::generate_test_hpke_config_and_private_key, HpkeApplicationInfo,
HpkeKeypair, Label,
},
task::{AuthenticationToken, VdafInstance},
test_util::{
dummy_vdaf::{self, AggregationParam},
install_test_trace_subscriber,
},
time::{Clock, IntervalExt, MockClock},
vdaf::VdafInstance,
};
use janus_messages::{
query_type::{FixedSize, QueryType as QueryTypeTrait, TimeInterval},
Expand Down
2 changes: 1 addition & 1 deletion aggregator/src/aggregator/garbage_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ mod tests {
task::{self, test_util::TaskBuilder},
};
use janus_core::{
task::VdafInstance,
test_util::{
dummy_vdaf::{self, AggregateShare, AggregationParam},
install_test_trace_subscriber,
},
time::{Clock, IntervalExt, MockClock, TimeExt},
vdaf::VdafInstance,
};
use janus_messages::{
query_type::{FixedSize, TimeInterval},
Expand Down
5 changes: 3 additions & 2 deletions aggregator/src/aggregator/http_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use async_trait::async_trait;
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine};
use janus_aggregator_core::{datastore::Datastore, instrumented};
use janus_core::{
auth_tokens::{AuthenticationToken, DAP_AUTH_HEADER},
http::extract_bearer_token,
task::{AuthenticationToken, DAP_AUTH_HEADER},
taskprov::TASKPROV_HEADER,
time::Clock,
};
Expand Down Expand Up @@ -679,6 +679,7 @@ mod tests {
test_util::noop_meter,
};
use janus_core::{
auth_tokens::AuthenticationToken,
hpke::{
self,
test_util::{
Expand All @@ -688,9 +689,9 @@ mod tests {
HpkeApplicationInfo, HpkeKeypair, Label,
},
report_id::ReportIdChecksumExt,
task::{AuthenticationToken, VdafInstance, VERIFY_KEY_LENGTH},
test_util::{dummy_vdaf, install_test_trace_subscriber, run_vdaf},
time::{Clock, DurationExt, IntervalExt, MockClock, TimeExt},
vdaf::{VdafInstance, VERIFY_KEY_LENGTH},
};
use janus_messages::{
query_type::TimeInterval, AggregateShare as AggregateShareMessage, AggregateShareAad,
Expand Down
2 changes: 1 addition & 1 deletion aggregator/src/aggregator/taskprov_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ use janus_core::{
HpkeKeypair, Label,
},
report_id::ReportIdChecksumExt,
task::VERIFY_KEY_LENGTH,
taskprov::TASKPROV_HEADER,
test_util::{install_test_trace_subscriber, run_vdaf, VdafTranscript},
time::{Clock, DurationExt, MockClock, TimeExt},
vdaf::VERIFY_KEY_LENGTH,
};
use janus_messages::{
codec::{Decode, Encode},
Expand Down
2 changes: 1 addition & 1 deletion aggregator/src/bin/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use janus_aggregator::{
};
use janus_aggregator_api::{self, aggregator_api_handler};
use janus_aggregator_core::datastore::Datastore;
use janus_core::{task::AuthenticationToken, time::RealClock};
use janus_core::{auth_tokens::AuthenticationToken, time::RealClock};
use serde::{de, Deserialize, Deserializer, Serialize};
use std::{
future::{ready, Future},
Expand Down
2 changes: 1 addition & 1 deletion aggregator/src/bin/janus_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,9 @@ mod tests {
task::{test_util::TaskBuilder, QueryType, Task},
};
use janus_core::{
task::VdafInstance,
test_util::{kubernetes, roundtrip_encoding},
time::RealClock,
vdaf::VdafInstance,
};
use janus_messages::{Role, TaskId};
use ring::aead::{UnboundKey, AES_128_GCM};
Expand Down
2 changes: 1 addition & 1 deletion aggregator/src/binary_utils/job_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ mod tests {
test_util::noop_meter,
};
use janus_core::{
task::VdafInstance,
test_util::{install_test_trace_subscriber, runtime::TestRuntimeManager},
time::MockClock,
vdaf::VdafInstance,
Runtime,
};
use janus_messages::{AggregationJobId, TaskId};
Expand Down
2 changes: 1 addition & 1 deletion aggregator/tests/graceful_shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use janus_aggregator_core::{
datastore::test_util::ephemeral_datastore,
task::{test_util::TaskBuilder, QueryType},
};
use janus_core::{task::VdafInstance, test_util::install_test_trace_subscriber, time::RealClock};
use janus_core::{test_util::install_test_trace_subscriber, time::RealClock, vdaf::VdafInstance};
use janus_messages::Role;
use reqwest::Url;
use serde_yaml::{Mapping, Value};
Expand Down
2 changes: 1 addition & 1 deletion aggregator_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use janus_aggregator_core::{
datastore::{self, Datastore},
instrumented,
};
use janus_core::{hpke, http::extract_bearer_token, task::AuthenticationToken, time::Clock};
use janus_core::{auth_tokens::AuthenticationToken, hpke, http::extract_bearer_token, time::Clock};
use janus_messages::{HpkeConfigId, RoleParseError, TaskId};
use routes::*;
use std::{str::FromStr, sync::Arc};
Expand Down
2 changes: 1 addition & 1 deletion aggregator_api/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use janus_aggregator_core::{
task::{QueryType, Task},
taskprov::{PeerAggregator, VerifyKeyInit},
};
use janus_core::task::{AuthenticationToken, VdafInstance};
use janus_core::{auth_tokens::AuthenticationToken, vdaf::VdafInstance};
use janus_messages::{
query_type::Code as SupportedQueryType, Duration, HpkeAeadId, HpkeConfig, HpkeKdfId, HpkeKemId,
Role, TaskId, Time,
Expand Down
3 changes: 2 additions & 1 deletion aggregator_api/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use janus_aggregator_core::{
SecretBytes,
};
use janus_core::{
auth_tokens::AuthenticationToken,
hpke::{
generate_hpke_config_and_private_key,
test_util::{
Expand All @@ -31,12 +32,12 @@ use janus_core::{
},
HpkeKeypair, HpkePrivateKey,
},
task::{AuthenticationToken, VdafInstance},
test_util::{
dummy_vdaf::{self, AggregationParam},
install_test_trace_subscriber,
},
time::MockClock,
vdaf::VdafInstance,
};
use janus_messages::{
query_type::TimeInterval, AggregationJobStep, Duration, HpkeAeadId, HpkeConfig, HpkeConfigId,
Expand Down
3 changes: 2 additions & 1 deletion aggregator_core/src/datastore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ use crate::{
use chrono::NaiveDateTime;
use futures::future::try_join_all;
use janus_core::{
auth_tokens::AuthenticationToken,
hpke::{HpkeKeypair, HpkePrivateKey},
task::{AuthenticationToken, VdafInstance},
time::{Clock, TimeExt},
vdaf::VdafInstance,
};
use janus_messages::{
query_type::{FixedSize, QueryType, TimeInterval},
Expand Down
3 changes: 2 additions & 1 deletion aggregator_core/src/datastore/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ use base64::{display::Base64Display, engine::general_purpose::URL_SAFE_NO_PAD};
use chrono::NaiveDateTime;
use derivative::Derivative;
use janus_core::{
auth_tokens::AuthenticationToken,
hpke::HpkeKeypair,
report_id::ReportIdChecksumExt,
task::{AuthenticationToken, VdafInstance},
time::{DurationExt, IntervalExt, TimeExt},
vdaf::VdafInstance,
};
use janus_messages::{
query_type::{FixedSize, QueryType, TimeInterval},
Expand Down
2 changes: 1 addition & 1 deletion aggregator_core/src/datastore/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ use janus_core::{
hpke::{
self, test_util::generate_test_hpke_config_and_private_key, HpkeApplicationInfo, Label,
},
task::{VdafInstance, VERIFY_KEY_LENGTH},
test_util::{
dummy_vdaf::{self, AggregateShare, AggregationParam},
install_test_trace_subscriber, run_vdaf,
},
time::{Clock, DurationExt, IntervalExt, MockClock, TimeExt},
vdaf::{VdafInstance, VERIFY_KEY_LENGTH},
};
use janus_messages::{
query_type::{FixedSize, QueryType, TimeInterval},
Expand Down
2 changes: 1 addition & 1 deletion aggregator_core/src/query_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ mod tests {
query_type::CollectableQueryType,
task::{test_util::TaskBuilder, QueryType},
};
use janus_core::task::VdafInstance;
use janus_core::vdaf::VdafInstance;
use janus_messages::{query_type::TimeInterval, Duration, Interval, Role, Time};

#[test]
Expand Down
Loading

0 comments on commit e6ab04d

Please sign in to comment.