@@ -430,9 +430,8 @@ pub fn round2(
430430
431431 // Reconstruct R' = Wi*G - Ci*A_{j,0}
432432 let r_reconstructed = G1Projective :: generator ( ) * wi - a0 * ci;
433- let sender_id_u8 =
434- u8:: try_from ( sender_id)
435- . map_err ( |_| KryptologyError :: InvalidParticipantId ( sender_id) ) ?;
433+ let sender_id_u8 = u8:: try_from ( sender_id)
434+ . map_err ( |_| KryptologyError :: InvalidParticipantId ( sender_id) ) ?;
436435 let ci_check = kryptology_challenge ( sender_id_u8, secret. ctx , & a0, & r_reconstructed) ;
437436 if !ci_check. constant_time_eq ( & ci) {
438437 return Err ( KryptologyError :: InvalidProof { culprit : sender_id } ) ;
@@ -880,7 +879,8 @@ mod tests {
880879 let mut secrets: BTreeMap < u32 , Round1Secret > = BTreeMap :: new ( ) ;
881880
882881 for id in 1 ..=u32:: from ( max_signers) {
883- let ( bcast, shares, secret) = round1 ( id, threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
882+ let ( bcast, shares, secret) =
883+ round1 ( id, threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
884884 bcasts. insert ( id, bcast) ;
885885 secrets. insert ( id, secret) ;
886886 for ( & target_id, share) in & shares {
@@ -925,6 +925,10 @@ mod tests {
925925 signature. verify( vk, message) ,
926926 "BLS threshold signature should verify"
927927 ) ;
928+ let signature_bytes = signature. to_bytes ( ) ;
929+ let parsed_signature = blst:: min_pk:: Signature :: from_bytes ( & signature_bytes)
930+ . expect ( "combined signature should serialize to compressed bytes" ) ;
931+ assert_eq ! ( parsed_signature. to_bytes( ) , signature_bytes) ;
928932
929933 assert ! (
930934 !signature. verify( vk, b"wrong message" ) ,
@@ -944,8 +948,7 @@ mod tests {
944948 round1 ( 1 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
945949 let ( _bcast2, _shares2, secret2) =
946950 round1 ( 2 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
947- let ( bcast3, shares3, _secret3) =
948- round1 ( 3 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
951+ let ( bcast3, shares3, _secret3) = round1 ( 3 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
949952
950953 bcast1. ci [ 31 ] ^= 0x01 ;
951954
@@ -962,6 +965,32 @@ mod tests {
962965 }
963966 }
964967
968+ #[ test]
969+ fn round2_rejects_zero_challenge ( ) {
970+ let mut rng = StdRng :: seed_from_u64 ( 98 ) ;
971+ let threshold = 2u16 ;
972+ let max_signers = 3u16 ;
973+ let ctx = 0u8 ;
974+
975+ let ( mut bcast1, shares1, _secret1) =
976+ round1 ( 1 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
977+ let ( _bcast2, _shares2, secret2) =
978+ round1 ( 2 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
979+
980+ bcast1. ci = [ 0 ; 32 ] ;
981+
982+ let result = round2 (
983+ secret2,
984+ & [ ( 1 , bcast1) ] . into ( ) ,
985+ & [ ( 1 , shares1[ & 2 ] . clone ( ) ) ] . into ( ) ,
986+ ) ;
987+
988+ assert ! ( matches!(
989+ result,
990+ Err ( KryptologyError :: InvalidProof { culprit: 1 } )
991+ ) ) ;
992+ }
993+
965994 /// Verify that a share addressed to the wrong participant is rejected in
966995 /// round2.
967996 #[ test]
@@ -971,12 +1000,10 @@ mod tests {
9711000 let max_signers = 3u16 ;
9721001 let ctx = 0u8 ;
9731002
974- let ( bcast1, shares1, _secret1) =
975- round1 ( 1 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
1003+ let ( bcast1, shares1, _secret1) = round1 ( 1 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
9761004 let ( _bcast2, _shares2, secret2) =
9771005 round1 ( 2 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
978- let ( bcast3, shares3, _secret3) =
979- round1 ( 3 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
1006+ let ( bcast3, shares3, _secret3) = round1 ( 3 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
9801007
9811008 let received_bcasts: BTreeMap < u32 , Round1Bcast > = [ ( 1 , bcast1) , ( 3 , bcast3) ] . into ( ) ;
9821009
@@ -1000,8 +1027,7 @@ mod tests {
10001027 let max_signers = 3u16 ;
10011028 let ctx = 0u8 ;
10021029
1003- let ( bcast1, shares1, _secret1) =
1004- round1 ( 1 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
1030+ let ( bcast1, shares1, _secret1) = round1 ( 1 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
10051031 let ( _bcast2, _shares2, secret2) =
10061032 round1 ( 2 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
10071033 let ( _bcast3, _shares3, _secret3) =
@@ -1025,8 +1051,7 @@ mod tests {
10251051 round1 ( 1 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
10261052 let ( _bcast2, _shares2, secret2) =
10271053 round1 ( 2 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
1028- let ( bcast3, shares3, _secret3) =
1029- round1 ( 3 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
1054+ let ( bcast3, shares3, _secret3) = round1 ( 3 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
10301055
10311056 let received_bcasts: BTreeMap < u32 , Round1Bcast > = [ ( 1 , bcast1) , ( 3 , bcast3) ] . into ( ) ;
10321057 let received_shares: BTreeMap < u32 , ShamirShare > = [ ( 3 , shares3[ & 2 ] . clone ( ) ) ] . into ( ) ;
@@ -1047,8 +1072,7 @@ mod tests {
10471072
10481073 let ( _bcast1, shares1, _secret1) =
10491074 round1 ( 1 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
1050- let ( bcast2, _shares2, secret2) =
1051- round1 ( 2 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
1075+ let ( bcast2, _shares2, secret2) = round1 ( 2 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
10521076
10531077 let received_bcasts: BTreeMap < u32 , Round1Bcast > = [ ( 2 , bcast2) ] . into ( ) ;
10541078 let received_shares: BTreeMap < u32 , ShamirShare > = [ ( 2 , shares1[ & 2 ] . clone ( ) ) ] . into ( ) ;
@@ -1068,10 +1092,8 @@ mod tests {
10681092 let ctx = 0u8 ;
10691093 let message = b"duplicate signer" ;
10701094
1071- let ( bcast1, shares1, secret1) =
1072- round1 ( 1 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
1073- let ( bcast2, shares2, secret2) =
1074- round1 ( 2 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
1095+ let ( bcast1, shares1, secret1) = round1 ( 1 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
1096+ let ( bcast2, shares2, secret2) = round1 ( 2 , threshold, max_signers, ctx, & mut rng) . unwrap ( ) ;
10751097
10761098 let ( _round2_bcast1, key_package1, _public_key_package1) = round2 (
10771099 secret1,
@@ -1087,8 +1109,7 @@ mod tests {
10871109 . unwrap ( ) ;
10881110
10891111 let partial = BlsPartialSignature :: from_key_package ( & key_package1, message) ;
1090- let result =
1091- BlsSignature :: from_partial_signatures ( threshold, & [ partial. clone ( ) , partial] ) ;
1112+ let result = BlsSignature :: from_partial_signatures ( threshold, & [ partial. clone ( ) , partial] ) ;
10921113
10931114 assert ! ( matches!(
10941115 result,
0 commit comments