Repository: cloudflare/daphne
Pull request #746 (2024-12-19 13:43:24)

Cleanup Prio3
A few bits and bobs related to the Prio3 VDAF upgrade.


Patch:
diff --git a/crates/dapf/src/cli_parsers.rs b/crates/dapf/src/cli_parsers.rs
index f0978cd..80cbc7e 100644
--- a/crates/dapf/src/cli_parsers.rs
+++ b/crates/dapf/src/cli_parsers.rs
@@ -26,8 +26,8 @@ use daphne::{
 pub enum DefaultVdafConfigs {
     Prio2Dimension99k,
     #[default]
-    Prio3NumProofs2,
-    Prio3NumProofs3,
+    Prio3Draft09NumProofs2,
+    Prio3Draft09NumProofs3,
 }
 
 impl fmt::Display for DefaultVdafConfigs {
@@ -40,16 +40,16 @@ impl ValueEnum for DefaultVdafConfigs {
     fn value_variants<'a>() -> &'a [Self] {
         &[
             Self::Prio2Dimension99k,
-            Self::Prio3NumProofs2,
-            Self::Prio3NumProofs3,
+            Self::Prio3Draft09NumProofs2,
+            Self::Prio3Draft09NumProofs3,
         ]
     }
 
     fn to_possible_value(&self) -> Option<PossibleValue> {
         match self {
             Self::Prio2Dimension99k => Some(PossibleValue::new("prio2-dimension-99k")),
-            Self::Prio3NumProofs2 => Some(PossibleValue::new("prio3-num-proofs-2")),
-            Self::Prio3NumProofs3 => Some(PossibleValue::new("prio3-num-proofs-3")),
+            Self::Prio3Draft09NumProofs2 => Some(PossibleValue::new("prio3-draft-09-num-proofs-2")),
+            Self::Prio3Draft09NumProofs3 => Some(PossibleValue::new("prio3-draft-09-num-proofs-3")),
         }
     }
 }
@@ -58,7 +58,7 @@ impl DefaultVdafConfigs {
     fn into_vdaf_config(self) -> VdafConfig {
         match self {
             Self::Prio2Dimension99k => VdafConfig::Prio2 { dimension: 99_992 },
-            Self::Prio3NumProofs2 => {
+            Self::Prio3Draft09NumProofs2 => {
                 VdafConfig::Prio3Draft09(Prio3Config::SumVecField64MultiproofHmacSha256Aes128 {
                     bits: 1,
                     length: 100_000,
@@ -66,7 +66,7 @@ impl DefaultVdafConfigs {
                     num_proofs: 2,
                 })
             }
-            Self::Prio3NumProofs3 => {
+            Self::Prio3Draft09NumProofs3 => {
                 VdafConfig::Prio3Draft09(Prio3Config::SumVecField64MultiproofHmacSha256Aes128 {
                     bits: 1,
                     length: 100_000,
diff --git a/crates/daphne/src/roles/mod.rs b/crates/daphne/src/roles/mod.rs
index a09e8bb..cb165d8 100644
--- a/crates/daphne/src/roles/mod.rs
+++ b/crates/daphne/src/roles/mod.rs
@@ -198,7 +198,7 @@ mod test {
             };
 
             // Task Parameters that the Leader and Helper must agree on.
-            let vdaf_config = VdafConfig::Prio3Draft09(Prio3Config::Count);
+            let vdaf_config = VdafConfig::Prio3(Prio3Config::Count);
             let leader_url = Url::parse("https://leader.com/v02/").unwrap();
             let helper_url = Url::parse("http://helper.org:8788/v02/").unwrap();
             let collector_hpke_receiver_config =
@@ -486,10 +486,7 @@ mod test {
             // Construct report. We expect the VDAF to be Prio3Count so that we know what type of
             // measurement to generate. However, we could extend the code to support more VDAFs.
             let task_config = self.leader.unchecked_get_task_config(task_id).await;
-            assert_matches!(
-                task_config.vdaf,
-                VdafConfig::Prio3Draft09(Prio3Config::Count)
-            );
+            assert_matches!(task_config.vdaf, VdafConfig::Prio3(Prio3Config::Count));
 
             self.gen_test_report_for_measurement(task_id, DapMeasurement::U64(1))
                 .await
@@ -1527,7 +1524,9 @@ mod test {
 
     async_test_versions! { e2e_taskprov_prio2 }
 
-    async fn e2e_taskprov_prio3_sum_vec_field64_multiproof_hmac_sha256_aes128(version: DapVersion) {
+    async fn e2e_taskprov_prio3_draft09_sum_vec_field64_multiproof_hmac_sha256_aes128(
+        version: DapVersion,
+    ) {
         e2e_taskprov(
             version,
             VdafConfig::Prio3Draft09(Prio3Config::SumVecField64MultiproofHmacSha256Aes128 {
@@ -1541,7 +1540,7 @@ mod test {
         .await;
     }
 
-    async_test_versions! { e2e_taskprov_prio3_sum_vec_field64_multiproof_hmac_sha256_aes128 }
+    async_test_versions! { e2e_taskprov_prio3_draft09_sum_vec_field64_multiproof_hmac_sha256_aes128 }
 
     async fn e2e_taskprov_pine32_hmac_sha256_aes128(version: DapVersion) {
         use crate::{pine::PineParam, vdaf::pine::PineConfig};
diff --git a/crates/daphne/src/taskprov.rs b/crates/daphne/src/taskprov.rs
index 43d197c..666dab6 100644
--- a/crates/daphne/src/taskprov.rs
+++ b/crates/daphne/src/taskprov.rs
@@ -401,24 +401,6 @@ impl TryFrom<&VdafConfig> for messages::taskprov::VdafTypeVar {
             VdafConfig::Prio3Draft09(..) => Err(fatal_error!(
                 err = format!("{vdaf_config} is not currently supported for taskprov")
             )),
-            VdafConfig::Prio3(Prio3Config::SumVecField64MultiproofHmacSha256Aes128 {
-                bits,
-                length,
-                chunk_length,
-                num_proofs,
-            }) => Ok(Self::Prio3SumVecField64MultiproofHmacSha256Aes128 {
-                bits: (*bits).try_into().map_err(|_| {
-                    fatal_error!(err = format!("{vdaf_config}: bits is too large for taskprov"))
-                })?,
-                length: (*length).try_into().map_err(|_| {
-                    fatal_error!(err = format!("{vdaf_config}: bits is too large for taskprov"))
-                })?,
-
-                chunk_length: (*chunk_length).try_into().map_err(|_| {
-                    fatal_error!(err = format!("{vdaf_config}: bits is too large for taskprov"))
-                })?,
-                num_proofs: *num_proofs,
-            }),
             VdafConfig::Prio3(..) => Err(fatal_error!(
                 err = format!("{vdaf_config} is not currently supported for taskprov")
             )),


Test patch:
diff --git a/crates/daphne-service-utils/src/test_route_types.rs b/crates/daphne-service-utils/src/test_route_types.rs
index 3e33c0a..30c22f1 100644
--- a/crates/daphne-service-utils/src/test_route_types.rs
+++ b/crates/daphne-service-utils/src/test_route_types.rs
@@ -36,24 +36,34 @@ impl From<VdafConfig> for InternalTestVdaf {
     fn from(vdaf: VdafConfig) -> Self {
         let (typ, bits, length, chunk_length) = match vdaf {
             VdafConfig::Prio3Draft09(prio3) => match prio3 {
-                Prio3Config::Count => ("Prio3Count", None, None, None),
-                Prio3Config::Sum { bits } => ("Prio3Sum", Some(bits), None, None),
+                Prio3Config::Count => ("Prio3Draft09Count", None, None, None),
+                Prio3Config::Sum { bits } => ("Prio3Draft09Sum", Some(bits), None, None),
                 Prio3Config::Histogram {
                     length,
                     chunk_length,
-                } => ("Prio3Histogram", None, Some(length), Some(chunk_length)),
+                } => (
+                    "Prio3Draft09Histogram",
+                    None,
+                    Some(length),
+                    Some(chunk_length),
+                ),
                 Prio3Config::SumVec {
                     bits,
                     length,
                     chunk_length,
-                } => ("Prio3SumVec", Some(bits), Some(length), Some(chunk_length)),
+                } => (
+                    "Prio3Draft09SumVec",
+                    Some(bits),
+                    Some(length),
+                    Some(chunk_length),
+                ),
                 Prio3Config::SumVecField64MultiproofHmacSha256Aes128 {
                     bits,
                     length,
                     chunk_length,
                     num_proofs: _unimplemented,
                 } => (
-                    "Prio3SumVecField64MultiproofHmacSha256Aes128",
+                    "Prio3Draft09SumVecField64MultiproofHmacSha256Aes128",
                     Some(bits),
                     Some(length),
                     Some(chunk_length),