Return false when incorrect amount of public inputs

This commit is contained in:
Mark Spanbroek 2024-01-30 15:16:06 +01:00 committed by markspanbroek
parent bd489c7f9a
commit ab1b91fe49
1 changed files with 6 additions and 2 deletions

View File

@ -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),