@@ -6,7 +6,7 @@ use mosaic_cac_types::{
66 ChallengeResponseMsgChunk , ChallengeResponseMsgHeader , CommitMsgChunk , CommitMsgHeader ,
77 CompletedSignatures , DepositAdaptors , DepositId , GarblingTableCommitment , HeapArray , Index ,
88 OpenedGarblingTableCommitments , PubKey , ReservedSetupInputShares , Seed , SetupInputs ,
9- TableTransferReceiptMsg , TableTransferRequestMsg , WideLabelWirePolynomialCommitments ,
9+ TableTransferReceiptMsg , WideLabelWirePolynomialCommitments ,
1010 WideLabelZerothPolynomialCoefficients , WithdrawalAdaptors , WithdrawalAdaptorsChunk ,
1111 WithdrawalInputs , state_machine:: evaluator:: * ,
1212} ;
@@ -807,6 +807,18 @@ async fn handle_recv_challenge_response_msg<S: StateMut>(
807807 header,
808808 remaining_chunks,
809809 } => {
810+ let challenge_idxs = state
811+ . get_challenge_indices ( )
812+ . await
813+ . require ( "expected challenge indices" ) ?;
814+
815+ if !challenge_idxs
816+ . iter ( )
817+ . any ( |idx| idx. get ( ) == response_msg_chunk. circuit_index as usize )
818+ {
819+ return Err ( SMError :: InvalidInputData ) ;
820+ }
821+
810822 let chunk_idx = ( response_msg_chunk. circuit_index as usize )
811823 . checked_sub ( 1 )
812824 . unwrap ( ) ;
@@ -815,8 +827,11 @@ async fn handle_recv_challenge_response_msg<S: StateMut>(
815827 // expected chunk
816828 }
817829 Some ( false ) => {
818- // already seen chunk
819- warn ! ( %chunk_idx, "evaluator received duplicate commit chunk, ack and ignore" ) ;
830+ // already seen expected chunk
831+ warn ! (
832+ %chunk_idx,
833+ "evaluator received duplicate challenge response chunk, ack and ignore"
834+ ) ;
820835 return Ok ( ( ) ) ;
821836 }
822837 None => {
0 commit comments