Skip to content

Commit

Permalink
Adopt prio::vdaf::dummy::Vdaf everywhere
Browse files Browse the repository at this point in the history
...and remove the dummy VDAF we had in Janus itself. This is a step
toward implementing support for VDAFs that use an aggregation parameter
(#225). We could use Poplar1, of course, but what's _really_ interesting
is Mastic, which besides using an aggregation parameter, is a
single-round VDAF. I want to be able to contrast the implementation
complexity of VDAFs with an aggregation parameter and ones that also
take multiple rounds, and the dummy VDAF is most expedient way to wire
up the former.
  • Loading branch information
tgeoghegan committed Feb 16, 2024
1 parent 68bee62 commit 782892e
Show file tree
Hide file tree
Showing 20 changed files with 871 additions and 1,285 deletions.
30 changes: 15 additions & 15 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ k8s-openapi = { version = "0.20.0", features = ["v1_26"] } # keep this version
kube = { version = "0.87.2", default-features = false, features = ["client", "rustls-tls"] }
opentelemetry = { version = "0.21", features = ["metrics"] }
opentelemetry_sdk = { version = "0.21", features = ["metrics"] }
prio = { version = "0.16.0", features = ["multithreaded", "experimental"] }
# TODO(timg) go back to a released prio
prio = { git = "https://github.com/divviup/libprio-rs", branch = "timg/dummy-vdaf-bugs", features = ["multithreaded", "experimental"] }
#prio = { version = "0.16.0", features = ["multithreaded", "experimental"] }
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.113"
serde_test = "1.0.175"
Expand Down
16 changes: 7 additions & 9 deletions aggregator/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ use janus_aggregator_core::{
task::{self, AggregatorTask, VerifyKey},
taskprov::PeerAggregator,
};
#[cfg(feature = "test-util")]
use janus_core::test_util::dummy_vdaf;
#[cfg(feature = "fpvec_bounded_l2")]
use janus_core::vdaf::Prio3FixedPointBoundedL2VecSumBitSize;
use janus_core::{
Expand Down Expand Up @@ -71,7 +69,7 @@ use opentelemetry::{
#[cfg(feature = "fpvec_bounded_l2")]
use prio::vdaf::prio3::Prio3FixedPointBoundedL2VecSumMultithreaded;
#[cfg(feature = "test-util")]
use prio::vdaf::{PrepareTransition, VdafError};
use prio::vdaf::{dummy, PrepareTransition, VdafError};
use prio::{
codec::{Decode, Encode, ParameterizedDecode},
dp::DifferentialPrivacyStrategy,
Expand Down Expand Up @@ -928,11 +926,11 @@ impl<C: Clock> TaskAggregator<C> {
}

#[cfg(feature = "test-util")]
VdafInstance::Fake => VdafOps::Fake(Arc::new(dummy_vdaf::Vdaf::new())),
VdafInstance::Fake => VdafOps::Fake(Arc::new(dummy::Vdaf::new(1))),

#[cfg(feature = "test-util")]
VdafInstance::FakeFailsPrepInit => VdafOps::Fake(Arc::new(
dummy_vdaf::Vdaf::new().with_prep_init_fn(|_| -> Result<(), VdafError> {
dummy::Vdaf::new(1).with_prep_init_fn(|_| -> Result<(), VdafError> {
Err(VdafError::Uncategorized(
"FakeFailsPrepInit failed at prep_init".to_string(),
))
Expand All @@ -941,8 +939,8 @@ impl<C: Clock> TaskAggregator<C> {

#[cfg(feature = "test-util")]
VdafInstance::FakeFailsPrepStep => {
VdafOps::Fake(Arc::new(dummy_vdaf::Vdaf::new().with_prep_step_fn(
|| -> Result<PrepareTransition<dummy_vdaf::Vdaf, 0, 16>, VdafError> {
VdafOps::Fake(Arc::new(dummy::Vdaf::new(1).with_prep_step_fn(
|_| -> Result<PrepareTransition<dummy::Vdaf, 0, 16>, VdafError> {
Err(VdafError::Uncategorized(
"FakeFailsPrepStep failed at prep_step".to_string(),
))
Expand Down Expand Up @@ -1166,7 +1164,7 @@ enum VdafOps {
VerifyKey<VERIFY_KEY_LENGTH>,
),
#[cfg(feature = "test-util")]
Fake(Arc<dummy_vdaf::Vdaf>),
Fake(Arc<dummy::Vdaf>),
}

/// Emits a match block dispatching on a [`VdafOps`] object. Takes a `&VdafOps` as the first
Expand Down Expand Up @@ -1299,7 +1297,7 @@ macro_rules! vdaf_ops_dispatch {
crate::aggregator::VdafOps::Fake(vdaf) => {
let $vdaf = vdaf;
let $verify_key = &VerifyKey::new([]);
type $Vdaf = ::janus_core::test_util::dummy_vdaf::Vdaf;
type $Vdaf = ::prio::vdaf::dummy::Vdaf;
const $VERIFY_KEY_LENGTH: usize = 0;
type $DpStrategy = janus_core::dp::NoDifferentialPrivacy;
let $dp_strategy = &Arc::new(janus_core::dp::NoDifferentialPrivacy);
Expand Down
52 changes: 25 additions & 27 deletions aggregator/src/aggregator/aggregate_init_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ use janus_aggregator_core::{
};
use janus_core::{
auth_tokens::{AuthenticationToken, DAP_AUTH_HEADER},
test_util::{
dummy_vdaf, install_test_trace_subscriber, run_vdaf, runtime::TestRuntime, VdafTranscript,
},
test_util::{install_test_trace_subscriber, run_vdaf, runtime::TestRuntime, VdafTranscript},
time::{Clock, MockClock, TimeExt as _},
vdaf::VdafInstance,
};
Expand All @@ -36,7 +34,7 @@ use prio::{
codec::Encode,
idpf::IdpfInput,
vdaf::{
self,
self, dummy,
poplar1::{Poplar1, Poplar1AggregationParam},
xof::XofTurboShake128,
},
Expand Down Expand Up @@ -179,12 +177,12 @@ pub(super) struct AggregationJobInitTestCase<
_ephemeral_datastore: EphemeralDatastore,
}

pub(super) async fn setup_aggregate_init_test() -> AggregationJobInitTestCase<0, dummy_vdaf::Vdaf> {
pub(super) async fn setup_aggregate_init_test() -> AggregationJobInitTestCase<0, dummy::Vdaf> {
setup_aggregate_init_test_for_vdaf(
dummy_vdaf::Vdaf::new(),
dummy::Vdaf::new(1),
VdafInstance::Fake,
dummy_vdaf::AggregationParam(0),
(),
dummy::AggregationParam(0),
0,
)
.await
}
Expand Down Expand Up @@ -330,10 +328,10 @@ pub(crate) async fn put_aggregation_job(
#[tokio::test]
async fn aggregation_job_init_authorization_dap_auth_token() {
let test_case = setup_aggregate_init_test_without_sending_request(
dummy_vdaf::Vdaf::new(),
dummy::Vdaf::new(1),
VdafInstance::Fake,
dummy_vdaf::AggregationParam(0),
(),
dummy::AggregationParam(0),
0,
AuthenticationToken::DapAuth(random()),
)
.await;
Expand Down Expand Up @@ -366,10 +364,10 @@ async fn aggregation_job_init_authorization_dap_auth_token() {
#[tokio::test]
async fn aggregation_job_init_malformed_authorization_header(#[case] header_value: &'static str) {
let test_case = setup_aggregate_init_test_without_sending_request(
dummy_vdaf::Vdaf::new(),
dummy::Vdaf::new(1),
VdafInstance::Fake,
dummy_vdaf::AggregationParam(0),
(),
dummy::AggregationParam(0),
0,
AuthenticationToken::Bearer(random()),
)
.await;
Expand Down Expand Up @@ -401,10 +399,10 @@ async fn aggregation_job_init_malformed_authorization_header(#[case] header_valu
#[tokio::test]
async fn aggregation_job_init_unexpected_taskprov_extension() {
let test_case = setup_aggregate_init_test_without_sending_request(
dummy_vdaf::Vdaf::new(),
dummy::Vdaf::new(1),
VdafInstance::Fake,
dummy_vdaf::AggregationParam(0),
(),
dummy::AggregationParam(0),
0,
random(),
)
.await;
Expand All @@ -416,11 +414,11 @@ async fn aggregation_job_init_unexpected_taskprov_extension() {
ExtensionType::Taskprov,
Vec::new(),
)]))
.next(&())
.next(&0)
.0;
let report_id = *prepare_init.report_share().metadata().id();
let aggregation_job_init_req = AggregationJobInitializeReq::new(
dummy_vdaf::AggregationParam(1).get_encoded().unwrap(),
dummy::AggregationParam(1).get_encoded().unwrap(),
PartialBatchSelector::new_time_interval(),
Vec::from([prepare_init]),
);
Expand Down Expand Up @@ -448,7 +446,7 @@ async fn aggregation_job_mutation_aggregation_job() {

// Put the aggregation job again, but with a different aggregation parameter.
let mutated_aggregation_job_init_req = AggregationJobInitializeReq::new(
dummy_vdaf::AggregationParam(1).get_encoded().unwrap(),
dummy::AggregationParam(1).get_encoded().unwrap(),
PartialBatchSelector::new_time_interval(),
test_case.aggregation_job_init_req.prepare_inits().to_vec(),
);
Expand Down Expand Up @@ -477,13 +475,13 @@ async fn aggregation_job_mutation_report_shares() {
// Include a different report share than was included previously
[
&prepare_inits[0..prepare_inits.len() - 1],
&[test_case.prepare_init_generator.next(&()).0],
&[test_case.prepare_init_generator.next(&0).0],
]
.concat(),
// Include an extra report share than was included previously
[
prepare_inits,
&[test_case.prepare_init_generator.next(&()).0],
&[test_case.prepare_init_generator.next(&0).0],
]
.concat(),
// Reverse the order of the reports
Expand Down Expand Up @@ -547,10 +545,10 @@ async fn aggregation_job_mutation_report_aggregations() {
#[tokio::test]
async fn aggregation_job_intolerable_clock_skew() {
let mut test_case = setup_aggregate_init_test_without_sending_request(
dummy_vdaf::Vdaf::new(),
dummy::Vdaf::new(1),
VdafInstance::Fake,
dummy_vdaf::AggregationParam(0),
(),
dummy::AggregationParam(0),
0,
AuthenticationToken::Bearer(random()),
)
.await;
Expand All @@ -571,7 +569,7 @@ async fn aggregation_job_intolerable_clock_skew() {
.add(test_case.task.tolerable_clock_skew())
.unwrap(),
),
&(),
&0,
)
.0,
// Barely intolerable.
Expand All @@ -588,7 +586,7 @@ async fn aggregation_job_intolerable_clock_skew() {
.add(&Duration::from_seconds(1))
.unwrap(),
),
&(),
&0,
)
.0,
]),
Expand Down
13 changes: 5 additions & 8 deletions aggregator/src/aggregator/aggregation_job_creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ mod tests {
};
use janus_core::{
hpke::test_util::generate_test_hpke_config_and_private_key,
test_util::{dummy_vdaf, install_test_trace_subscriber, run_vdaf},
test_util::{install_test_trace_subscriber, run_vdaf},
time::{Clock, DurationExt, IntervalExt, MockClock, TimeExt},
vdaf::{VdafInstance, VERIFY_KEY_LENGTH},
};
Expand All @@ -782,7 +782,7 @@ mod tests {
AggregationJobStep, Interval, PrepareError, ReportId, ReportMetadata, Role, TaskId, Time,
};
use prio::vdaf::{
self,
self, dummy,
prio3::{Prio3, Prio3Count},
};
use rand::random;
Expand Down Expand Up @@ -865,7 +865,7 @@ mod tests {
tx.put_client_report(vdaf.as_ref(), &leader_report)
.await
.unwrap();
tx.put_client_report(&dummy_vdaf::Vdaf::new(), &helper_report)
tx.put_client_report(&dummy::Vdaf::new(1), &helper_report)
.await
.unwrap();
Ok(())
Expand Down Expand Up @@ -932,13 +932,10 @@ mod tests {
read_and_verify_aggregate_info_for_task::<
0,
TimeInterval,
dummy_vdaf::Vdaf,
dummy::Vdaf,
_,
>(
tx,
&dummy_vdaf::Vdaf::new(),
helper_task.id(),
&HashMap::new(),
tx, &dummy::Vdaf::new(1), helper_task.id(), &HashMap::new()
)
.await;
Ok((
Expand Down
Loading

0 comments on commit 782892e

Please sign in to comment.