mirror of
https://github.com/codex-storage/codex-contracts-eth.git
synced 2025-02-10 10:26:32 +00:00
Return false when public inputs are invalid
This commit is contained in:
parent
d38e0f5954
commit
576254423e
@ -139,13 +139,15 @@ contract Groth16Verifier {
|
|||||||
uint[] memory input
|
uint[] memory input
|
||||||
) public view returns (bool success) {
|
) public view returns (bool success) {
|
||||||
require(input.length + 1 == _verifyingKey.ic.length, "verifier-bad-input");
|
require(input.length + 1 == _verifyingKey.ic.length, "verifier-bad-input");
|
||||||
|
// Check that inputs are field elements
|
||||||
|
for (uint i = 0; i < input.length; i++) {
|
||||||
|
if (input[i] >= _Q) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Compute the linear combination vkX
|
// Compute the linear combination vkX
|
||||||
G1Point memory vkX = G1Point(0, 0);
|
G1Point memory vkX = G1Point(0, 0);
|
||||||
for (uint i = 0; i < input.length; i++) {
|
for (uint i = 0; i < input.length; i++) {
|
||||||
require(
|
|
||||||
input[i] < _Q,
|
|
||||||
"verifier-gte-snark-scalar-field"
|
|
||||||
);
|
|
||||||
G1Point memory product;
|
G1Point memory product;
|
||||||
(success, product) = _multiply(_verifyingKey.ic[i + 1], input[i]);
|
(success, product) = _multiply(_verifyingKey.ic[i + 1], input[i]);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user