From ab1b91fe493009beeb755f45de5f1581d07e1737 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Tue, 30 Jan 2024 15:16:06 +0100 Subject: [PATCH] Return false when incorrect amount of public inputs --- contracts/Groth16Verifier.sol | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contracts/Groth16Verifier.sol b/contracts/Groth16Verifier.sol index b80bbac..5f7c60d 100644 --- a/contracts/Groth16Verifier.sol +++ b/contracts/Groth16Verifier.sol @@ -131,8 +131,11 @@ contract Groth16Verifier is IGroth16Verifier { Groth16Proof calldata proof, uint[] memory input ) public view returns (bool success) { - require(input.length + 1 == _verifyingKey.ic.length, "verifier-bad-input"); - // Check that inputs are field elements + // Check amount of public inputs + if (input.length + 1 != _verifyingKey.ic.length) { + return false; + } + // Check that public inputs are field elements for (uint i = 0; i < input.length; i++) { if (input[i] >= _Q) { return false; @@ -151,6 +154,7 @@ contract Groth16Verifier is IGroth16Verifier { return false; } } + // Check the pairing uint outcome; (success, outcome) = _checkPairing( _negate(proof.a),