Skip to content

Commit

Permalink
Return false when incorrect amount of public inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
markspanbroek committed Jan 30, 2024
1 parent 98ab10c commit 99a3d10
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions contracts/Groth16Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -151,6 +154,7 @@ contract Groth16Verifier is IGroth16Verifier {
return false;
}
}
// Check the pairing
uint outcome;
(success, outcome) = _checkPairing(
_negate(proof.a),
Expand Down

0 comments on commit 99a3d10

Please sign in to comment.