Skip to content

Commit 2d3d9b7

Browse files
committed
Update taskprov advertisement encoding for latest draft
1 parent 03b8b68 commit 2d3d9b7

File tree

4 files changed

+719
-461
lines changed

4 files changed

+719
-461
lines changed

crates/daphne/src/lib.rs

+24-13
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl DapGlobalConfig {
227227
}
228228
}
229229

230-
/// DAP Query configuration.
230+
/// DAP batch configuration.
231231
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
232232
#[serde(rename_all = "snake_case")]
233233
#[cfg_attr(any(test, feature = "test-utils"), derive(deepsize::DeepSizeOf))]
@@ -241,7 +241,8 @@ pub enum DapBatchMode {
241241
/// Aggregators are meant to stop aggregating reports when this limit is reached.
242242
LeaderSelected {
243243
#[serde(default)]
244-
max_batch_size: Option<NonZeroU32>,
244+
#[serde(rename = "max_batch_size")]
245+
draft09_max_batch_size: Option<NonZeroU32>,
245246
},
246247
}
247248

@@ -553,6 +554,9 @@ impl DapTaskParameters {
553554
now: Time,
554555
taskprov_config: roles::aggregator::TaskprovConfig<'_>,
555556
) -> Result<(DapTaskConfig, TaskId, TaskprovAdvertisement), DapError> {
557+
let not_before = now;
558+
let not_after = now + 86400 * 14; // expires in two weeks
559+
556560
let taskprov_advertisement = messages::taskprov::TaskprovAdvertisement {
557561
task_info,
558562
leader_url: messages::taskprov::UrlBytes {
@@ -561,16 +565,23 @@ impl DapTaskParameters {
561565
helper_url: messages::taskprov::UrlBytes {
562566
bytes: self.helper_url.to_string().into_bytes(),
563567
},
564-
query_config: messages::taskprov::QueryConfig {
565-
time_precision: self.time_precision,
566-
max_batch_query_count: 1,
567-
min_batch_size: self.min_batch_size.try_into().unwrap(),
568-
batch_mode: (&self.query).try_into()?,
568+
time_precision: self.time_precision,
569+
min_batch_size: self.min_batch_size.try_into().unwrap(),
570+
query_config: (&self.query).try_into()?,
571+
lifetime: messages::taskprov::TaskLifetime::from_validity_range(
572+
self.version,
573+
not_before,
574+
not_after,
575+
),
576+
vdaf_config: (&self.vdaf).try_into()?,
577+
extensions: Vec::new(),
578+
draft09_max_batch_query_count: match self.version {
579+
DapVersion::Draft09 => Some(1),
580+
DapVersion::Latest => None,
569581
},
570-
task_expiration: now + 86400 * 14, // expires in two weeks
571-
vdaf_config: messages::taskprov::VdafConfig {
572-
dp_config: messages::taskprov::DpConfig::None,
573-
var: (&self.vdaf).try_into()?,
582+
draft09_dp_config: match self.version {
583+
DapVersion::Draft09 => Some(messages::taskprov::DpConfig::None),
584+
DapVersion::Latest => None,
574585
},
575586
};
576587

@@ -736,7 +747,7 @@ impl DapTaskConfig {
736747
) -> Result<bool, DapAbort> {
737748
match self.query {
738749
DapBatchMode::LeaderSelected {
739-
max_batch_size: Some(max_batch_size),
750+
draft09_max_batch_size: Some(max_batch_size),
740751
} => {
741752
if report_count > u64::from(max_batch_size.get()) {
742753
return Err(DapAbort::InvalidBatchSize {
@@ -749,7 +760,7 @@ impl DapTaskConfig {
749760
}
750761
DapBatchMode::TimeInterval
751762
| DapBatchMode::LeaderSelected {
752-
max_batch_size: None,
763+
draft09_max_batch_size: None,
753764
} => (),
754765
};
755766

0 commit comments

Comments
 (0)