@@ -63,16 +63,14 @@ pub(crate) fn extract_prk_from_verify_key_init(
6363 Salt :: new ( HKDF_SHA256 , & TASKPROV_SALT ) . extract ( verify_key_init)
6464}
6565
66- impl VdafConfig {
67- fn expand_into_taskprov_verify_key ( & self , prk : & Prk , task_id : & TaskId ) -> VdafVerifyKey {
68- let mut verify_key = self . uninitialized_verify_key ( ) ;
69- let info = [ task_id. as_ref ( ) ] ;
70- // This expand(), and the associated fill() below can only fail if the length is wrong,
71- // and it won't be, so we unwrap().
72- let okm = prk. expand ( & info, verify_key. clone ( ) ) . unwrap ( ) ;
73- okm. fill ( verify_key. as_mut ( ) ) . unwrap ( ) ;
74- verify_key
75- }
66+ fn expand_into_taskprov_verify_key ( prk : & Prk , task_id : & TaskId ) -> VdafVerifyKey {
67+ let mut verify_key = VdafVerifyKey ( [ 0 ; 32 ] ) ;
68+ let info = [ task_id. as_ref ( ) ] ;
69+ // This expand(), and the associated fill() below can only fail if the length is wrong,
70+ // and it won't be, so we unwrap().
71+ let okm = prk. expand ( & info, verify_key. clone ( ) ) . unwrap ( ) ;
72+ okm. fill ( verify_key. as_mut ( ) ) . unwrap ( ) ;
73+ verify_key
7674}
7775
7876/// Compute the VDAF verify key for `task_id` and the specified VDAF type using the
@@ -86,9 +84,8 @@ fn compute_vdaf_verify_key(
8684 version : DapVersion ,
8785 verify_key_init : & [ u8 ; 32 ] ,
8886 task_id : & TaskId ,
89- vdaf_config : & VdafConfig ,
9087) -> VdafVerifyKey {
91- vdaf_config . expand_into_taskprov_verify_key (
88+ expand_into_taskprov_verify_key (
9289 & extract_prk_from_verify_key_init ( version, verify_key_init) ,
9390 task_id,
9491 )
@@ -313,12 +310,8 @@ impl DapTaskConfigNeedsOptIn {
313310 version,
314311 taskprov_advertisement. vdaf_config . var ,
315312 ) ?;
316- let vdaf_verify_key = compute_vdaf_verify_key (
317- version,
318- taskprov_config. vdaf_verify_key_init ,
319- task_id,
320- & vdaf,
321- ) ;
313+ let vdaf_verify_key =
314+ compute_vdaf_verify_key ( version, taskprov_config. vdaf_verify_key_init , task_id) ;
322315 Ok ( Self {
323316 version,
324317 leader_url : url_from_bytes ( task_id, & taskprov_advertisement. leader_url . bytes ) ?,
@@ -465,7 +458,7 @@ mod test {
465458 messages:: { self , TaskId } ,
466459 taskprov:: { DapTaskConfigNeedsOptIn , OptInParam } ,
467460 test_versions,
468- vdaf:: { VdafConfig , VdafVerifyKey } ,
461+ vdaf:: VdafVerifyKey ,
469462 DapRequestMeta , DapVersion ,
470463 } ;
471464
@@ -536,20 +529,13 @@ mod test {
536529 0x0f , 0x32 , 0xd7 , 0xe1 , 0xbc , 0x6c , 0x75 , 0x10 , 0x05 , 0x60 , 0x7b , 0x81 , 0xda , 0xc3 ,
537530 0xa7 , 0xda , 0x76 , 0x1d ,
538531 ] ;
539- let vk = compute_vdaf_verify_key (
540- version,
541- & verify_key_init,
542- & task_id,
543- & VdafConfig :: Prio2 { dimension : 10 } ,
544- ) ;
532+ let VdafVerifyKey ( verify_key) =
533+ compute_vdaf_verify_key ( version, & verify_key_init, & task_id) ;
545534 let expected: [ u8 ; 32 ] = [
546535 251 , 209 , 125 , 181 , 57 , 15 , 148 , 158 , 227 , 45 , 38 , 52 , 220 , 73 , 159 , 91 , 145 , 40 , 123 ,
547536 204 , 49 , 124 , 7 , 97 , 221 , 4 , 232 , 53 , 194 , 171 , 19 , 51 ,
548537 ] ;
549- match & vk {
550- VdafVerifyKey :: L32 ( bytes) => assert_eq ! ( * bytes, expected) ,
551- VdafVerifyKey :: L16 ( ..) => unreachable ! ( ) ,
552- }
538+ assert_eq ! ( verify_key, expected) ;
553539 }
554540
555541 test_versions ! { check_vdaf_key_computation }
0 commit comments