Skip to content

Commit 771f848

Browse files
authored
fix(NISigmaProtocol): add proof size validation in verify_batchable and verify_compact (#62)
1 parent 8395a75 commit 771f848

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/fiat_shamir.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ where
204204
let response = self
205205
.interactive_proof
206206
.deserialize_response(&proof[commitment_size..])?;
207+
let response_size = self.interactive_proof.serialize_response(&response).len();
208+
209+
// Proof size check
210+
if proof.len() != commitment_size + response_size {
211+
return Err(Error::VerificationFailure);
212+
}
207213

208214
let mut hash_state = self.hash_state.clone();
209215

@@ -270,6 +276,12 @@ where
270276
let response = self
271277
.interactive_proof
272278
.deserialize_response(&proof[challenge_size..])?;
279+
let response_size = self.interactive_proof.serialize_response(&response).len();
280+
281+
// Proof size check
282+
if proof.len() != challenge_size + response_size {
283+
return Err(Error::VerificationFailure);
284+
}
273285

274286
// Compute the commitments
275287
let commitment = self

0 commit comments

Comments
 (0)