@@ -117,10 +117,13 @@ where
117117 . prover_response ( prover_state, & challenge) ?;
118118
119119 // Local verification of the proof
120- debug_assert ! ( self
120+ if self
121121 . interactive_proof
122122 . verifier ( & commitment, & challenge, & response)
123- . is_ok( ) ) ;
123+ . is_err ( )
124+ {
125+ return Err ( Error :: VerificationFailure ) ;
126+ }
124127 Ok ( ( commitment, challenge, response) )
125128 }
126129
@@ -211,6 +214,13 @@ where
211214 return Err ( Error :: VerificationFailure ) ;
212215 }
213216
217+ // Assert correct proof size
218+ let total_expected_len =
219+ commitment_size + self . interactive_proof . serialize_response ( & response) . len ( ) ;
220+ if proof. len ( ) != total_expected_len {
221+ return Err ( Error :: VerificationFailure ) ;
222+ }
223+
214224 let mut hash_state = self . hash_state . clone ( ) ;
215225
216226 // Recompute the challenge
@@ -283,6 +293,13 @@ where
283293 return Err ( Error :: VerificationFailure ) ;
284294 }
285295
296+ // Assert correct proof size
297+ let total_expected_len =
298+ challenge_size + self . interactive_proof . serialize_response ( & response) . len ( ) ;
299+ if proof. len ( ) != total_expected_len {
300+ return Err ( Error :: VerificationFailure ) ;
301+ }
302+
286303 // Compute the commitments
287304 let commitment = self
288305 . interactive_proof
0 commit comments