Skip to content

Commit

Permalink
Handle chunk_length VDAF parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
divergentdave committed Sep 22, 2023
1 parent aca9f14 commit 608de17
Show file tree
Hide file tree
Showing 20 changed files with 393 additions and 296 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

32 changes: 16 additions & 16 deletions aggregator/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,13 +801,11 @@ impl<C: Clock> TaskAggregator<C> {
VdafOps::Prio3Count(Arc::new(vdaf), verify_key)
}

VdafInstance::Prio3CountVec { length } => {
let vdaf = Prio3::new_sum_vec_multithreaded(
2,
1,
*length,
VdafInstance::chunk_size(*length),
)?;
VdafInstance::Prio3CountVec {
length,
chunk_length,
} => {
let vdaf = Prio3::new_sum_vec_multithreaded(2, 1, *length, *chunk_length)?;
let verify_key = task.vdaf_verify_key()?;
VdafOps::Prio3CountVec(Arc::new(vdaf), verify_key)
}
Expand All @@ -818,19 +816,21 @@ impl<C: Clock> TaskAggregator<C> {
VdafOps::Prio3Sum(Arc::new(vdaf), verify_key)
}

VdafInstance::Prio3SumVec { bits, length } => {
let vdaf = Prio3::new_sum_vec_multithreaded(
2,
*bits,
*length,
VdafInstance::chunk_size(*bits * *length),
)?;
VdafInstance::Prio3SumVec {
bits,
length,
chunk_length,
} => {
let vdaf = Prio3::new_sum_vec_multithreaded(2, *bits, *length, *chunk_length)?;
let verify_key = task.vdaf_verify_key()?;
VdafOps::Prio3SumVec(Arc::new(vdaf), verify_key)
}

VdafInstance::Prio3Histogram { length } => {
let vdaf = Prio3::new_histogram(2, *length, VdafInstance::chunk_size(*length))?;
VdafInstance::Prio3Histogram {
length,
chunk_length,
} => {
let vdaf = Prio3::new_histogram(2, *length, *chunk_length)?;
let verify_key = task.vdaf_verify_key()?;
VdafOps::Prio3Histogram(Arc::new(vdaf), verify_key)
}
Expand Down
61 changes: 41 additions & 20 deletions aggregator/src/aggregator/aggregation_job_creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,18 @@ impl<C: Clock + 'static> AggregationJobCreator<C> {
.await
}

(task::QueryType::TimeInterval, VdafInstance::Prio3CountVec { length }) => {
(
task::QueryType::TimeInterval,
VdafInstance::Prio3CountVec {
length,
chunk_length,
},
) => {
let vdaf = Arc::new(Prio3::new_sum_vec_multithreaded(
2,
1,
*length,
VdafInstance::chunk_size(*length),
*chunk_length,
)?);
self.create_aggregation_jobs_for_time_interval_task_no_param::<
VERIFY_KEY_LENGTH,
Expand All @@ -287,23 +293,32 @@ impl<C: Clock + 'static> AggregationJobCreator<C> {
.await
}

(task::QueryType::TimeInterval, VdafInstance::Prio3SumVec { bits, length }) => {
(
task::QueryType::TimeInterval,
VdafInstance::Prio3SumVec {
bits,
length,
chunk_length,
},
) => {
let vdaf = Arc::new(Prio3::new_sum_vec_multithreaded(
2,
*bits,
*length,
VdafInstance::chunk_size(*bits * *length),
*chunk_length,
)?);
self.create_aggregation_jobs_for_time_interval_task_no_param::<VERIFY_KEY_LENGTH, Prio3SumVecMultithreaded>(task, vdaf)
.await
}

(task::QueryType::TimeInterval, VdafInstance::Prio3Histogram { length }) => {
let vdaf = Arc::new(Prio3::new_histogram(
2,
*length,
VdafInstance::chunk_size(*length),
)?);
(
task::QueryType::TimeInterval,
VdafInstance::Prio3Histogram {
length,
chunk_length,
},
) => {
let vdaf = Arc::new(Prio3::new_histogram(2, *length, *chunk_length)?);
self.create_aggregation_jobs_for_time_interval_task_no_param::<VERIFY_KEY_LENGTH, Prio3Histogram>(task, vdaf)
.await
}
Expand Down Expand Up @@ -368,13 +383,16 @@ impl<C: Clock + 'static> AggregationJobCreator<C> {
max_batch_size,
batch_time_window_size,
},
VdafInstance::Prio3CountVec { length },
VdafInstance::Prio3CountVec {
length,
chunk_length,
},
) => {
let vdaf = Arc::new(Prio3::new_sum_vec_multithreaded(
2,
1,
*length,
VdafInstance::chunk_size(*length),
*chunk_length,
)?);
let max_batch_size = *max_batch_size;
let batch_time_window_size = *batch_time_window_size;
Expand Down Expand Up @@ -405,13 +423,17 @@ impl<C: Clock + 'static> AggregationJobCreator<C> {
max_batch_size,
batch_time_window_size,
},
VdafInstance::Prio3SumVec { bits, length },
VdafInstance::Prio3SumVec {
bits,
length,
chunk_length,
},
) => {
let vdaf = Arc::new(Prio3::new_sum_vec_multithreaded(
2,
*bits,
*length,
VdafInstance::chunk_size(*bits * *length),
*chunk_length,
)?);
let max_batch_size = *max_batch_size;
let batch_time_window_size = *batch_time_window_size;
Expand All @@ -426,13 +448,12 @@ impl<C: Clock + 'static> AggregationJobCreator<C> {
max_batch_size,
batch_time_window_size,
},
VdafInstance::Prio3Histogram { length },
VdafInstance::Prio3Histogram {
length,
chunk_length,
},
) => {
let vdaf = Arc::new(Prio3::new_histogram(
2,
*length,
VdafInstance::chunk_size(*length),
)?);
let vdaf = Arc::new(Prio3::new_histogram(2, *length, *chunk_length)?);
let max_batch_size = *max_batch_size;
let batch_time_window_size = *batch_time_window_size;
self.create_aggregation_jobs_for_fixed_size_task_no_param::<
Expand Down
5 changes: 4 additions & 1 deletion aggregator/src/bin/janus_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,10 @@ mod tests {
max_batch_size: 100,
batch_time_window_size: None,
},
VdafInstance::Prio3CountVec { length: 4 },
VdafInstance::Prio3CountVec {
length: 4,
chunk_length: 2,
},
Role::Leader,
)
.with_id(*tasks[0].id())
Expand Down
27 changes: 21 additions & 6 deletions aggregator_api/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,10 @@ fn post_task_req_serialization() {
max_batch_size: 999,
batch_time_window_size: None,
},
vdaf: VdafInstance::Prio3CountVec { length: 5 },
vdaf: VdafInstance::Prio3CountVec {
length: 5,
chunk_length: 2,
},
role: Role::Helper,
vdaf_verify_key: "encoded".to_owned(),
max_batch_query_count: 1,
Expand Down Expand Up @@ -1556,10 +1559,12 @@ fn post_task_req_serialization() {
Token::StructVariant {
name: "VdafInstance",
variant: "Prio3CountVec",
len: 1,
len: 2,
},
Token::Str("length"),
Token::U64(5),
Token::Str("chunk_length"),
Token::U64(2),
Token::StructVariantEnd,
Token::Str("role"),
Token::UnitVariant {
Expand Down Expand Up @@ -1619,7 +1624,10 @@ fn post_task_req_serialization() {
max_batch_size: 999,
batch_time_window_size: None,
},
vdaf: VdafInstance::Prio3CountVec { length: 5 },
vdaf: VdafInstance::Prio3CountVec {
length: 5,
chunk_length: 2,
},
role: Role::Leader,
vdaf_verify_key: "encoded".to_owned(),
max_batch_query_count: 1,
Expand Down Expand Up @@ -1659,10 +1667,12 @@ fn post_task_req_serialization() {
Token::StructVariant {
name: "VdafInstance",
variant: "Prio3CountVec",
len: 1,
len: 2,
},
Token::Str("length"),
Token::U64(5),
Token::Str("chunk_length"),
Token::U64(2),
Token::StructVariantEnd,
Token::Str("role"),
Token::UnitVariant {
Expand Down Expand Up @@ -1739,7 +1749,10 @@ fn task_resp_serialization() {
max_batch_size: 999,
batch_time_window_size: None,
},
VdafInstance::Prio3CountVec { length: 5 },
VdafInstance::Prio3CountVec {
length: 5,
chunk_length: 2,
},
Role::Leader,
SecretBytes::new(b"vdaf verify key!".to_vec()),
1,
Expand Down Expand Up @@ -1801,10 +1814,12 @@ fn task_resp_serialization() {
Token::StructVariant {
name: "VdafInstance",
variant: "Prio3CountVec",
len: 1,
len: 2,
},
Token::Str("length"),
Token::U64(5),
Token::Str("chunk_length"),
Token::U64(2),
Token::StructVariantEnd,
Token::Str("role"),
Token::UnitVariant {
Expand Down
32 changes: 28 additions & 4 deletions aggregator_core/src/datastore/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,36 @@ async fn roundtrip_task(ephemeral_datastore: EphemeralDatastore) {
let mut want_tasks = HashMap::new();
for (vdaf, role) in [
(VdafInstance::Prio3Count, Role::Leader),
(VdafInstance::Prio3CountVec { length: 8 }, Role::Leader),
(VdafInstance::Prio3CountVec { length: 64 }, Role::Helper),
(
VdafInstance::Prio3CountVec {
length: 8,
chunk_length: 3,
},
Role::Leader,
),
(
VdafInstance::Prio3CountVec {
length: 64,
chunk_length: 10,
},
Role::Helper,
),
(VdafInstance::Prio3Sum { bits: 64 }, Role::Helper),
(VdafInstance::Prio3Sum { bits: 32 }, Role::Helper),
(VdafInstance::Prio3Histogram { length: 4 }, Role::Leader),
(VdafInstance::Prio3Histogram { length: 5 }, Role::Leader),
(
VdafInstance::Prio3Histogram {
length: 4,
chunk_length: 2,
},
Role::Leader,
),
(
VdafInstance::Prio3Histogram {
length: 5,
chunk_length: 2,
},
Role::Leader,
),
(VdafInstance::Poplar1 { bits: 8 }, Role::Helper),
(VdafInstance::Poplar1 { bits: 64 }, Role::Helper),
] {
Expand Down
9 changes: 7 additions & 2 deletions aggregator_core/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,10 @@ mod tests {
max_batch_size: 10,
batch_time_window_size: None,
},
VdafInstance::Prio3CountVec { length: 8 },
VdafInstance::Prio3CountVec {
length: 8,
chunk_length: 3,
},
Role::Helper,
SecretBytes::new(b"1234567812345678".to_vec()),
1,
Expand Down Expand Up @@ -1326,10 +1329,12 @@ mod tests {
Token::StructVariant {
name: "VdafInstance",
variant: "Prio3CountVec",
len: 1,
len: 2,
},
Token::Str("length"),
Token::U64(8),
Token::Str("chunk_length"),
Token::U64(3),
Token::StructVariantEnd,
Token::Str("role"),
Token::UnitVariant {
Expand Down
Loading

0 comments on commit 608de17

Please sign in to comment.