Skip to content

Commit

Permalink
Handle wrong input sizes gracefully (#829)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-lj authored Sep 11, 2024
1 parent 501225e commit d75fa17
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fastcrypto-zkp/src/groth16/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ impl<G1: Pairing> VerifyingKey<G1> {
// We can't use bcs because there, the length of the vector is prefixed as a single byte and
// not a little-endian u64 as it is here.

if (bytes.len() - (G1_SIZE + 3 * G2_SIZE + size_of::<u64>())) % G1_SIZE != 0 {
if bytes.len() < G1_SIZE + 3 * G2_SIZE + size_of::<u64>()
|| (bytes.len() - (G1_SIZE + 3 * G2_SIZE + size_of::<u64>())) % G1_SIZE != 0
{
return Err(FastCryptoError::InvalidInput);
}

Expand Down

0 comments on commit d75fa17

Please sign in to comment.