diff --git a/src/bn128.js b/src/bn128.js index 4e8ba1b..59ed409 100644 --- a/src/bn128.js +++ b/src/bn128.js @@ -173,7 +173,7 @@ class BN128 { throw new Error("Expected values are not equal"); } - if (this.loopCountNef) + if (this.loopCountNeg) { R.Y = this.F2.neg(R.Y); } diff --git a/templates/verifier_groth.sol b/templates/verifier_groth.sol index a2019eb..f1573e1 100644 --- a/templates/verifier_groth.sol +++ b/templates/verifier_groth.sol @@ -187,9 +187,10 @@ contract Verifier { require(input.length + 1 == vk.IC.length,"verifier-bad-input"); // Compute the linear combination vk_x Pairing.G1Point memory vk_x = Pairing.G1Point(0, 0); - for (uint i = 0; i < input.length; i++) + for (uint i = 0; i < input.length; i++) { require(input[i] < snark_scalar_field); vk_x = Pairing.addition(vk_x, Pairing.scalar_mul(vk.IC[i + 1], input[i])); + } vk_x = Pairing.addition(vk_x, vk.IC[0]); if (!Pairing.pairingProd4( Pairing.negate(proof.A), proof.B, diff --git a/templates/verifier_kimleeoh.sol b/templates/verifier_kimleeoh.sol index af528e2..073a2bc 100644 --- a/templates/verifier_kimleeoh.sol +++ b/templates/verifier_kimleeoh.sol @@ -178,9 +178,10 @@ contract Verifier { require(input.length + 1 == vk.IC.length); // Compute the linear combination vk_x Pairing.G1Point memory vk_x = Pairing.G1Point(0, 0); - for (uint i = 0; i < input.length; i++) + for (uint i = 0; i < input.length; i++) { require(input[i] < snark_scalar_field); vk_x = Pairing.addition(vk_x, Pairing.scalar_mul(vk.IC[i + 1], input[i])); + } vk_x = Pairing.addition(vk_x, vk.IC[0]); if (!Pairing.pairingProd4( Pairing.negate(proof.A), proof.B, diff --git a/templates/verifier_original.sol b/templates/verifier_original.sol index a1c1672..a57105c 100644 --- a/templates/verifier_original.sol +++ b/templates/verifier_original.sol @@ -188,9 +188,10 @@ contract Verifier { require(input.length + 1 == vk.IC.length,"verifier-bad-input"); // Compute the linear combination vk_x Pairing.G1Point memory vk_x = Pairing.G1Point(0, 0); - for (uint i = 0; i < input.length; i++) + for (uint i = 0; i < input.length; i++) { require(input[i] < snark_scalar_field); vk_x = Pairing.addition(vk_x, Pairing.scalar_mul(vk.IC[i + 1], input[i])); + } vk_x = Pairing.addition(vk_x, vk.IC[0]); if (!Pairing.pairingProd2(proof.A, vk.A, Pairing.negate(proof.A_p), Pairing.P2())) return 1; if (!Pairing.pairingProd2(vk.B, proof.B, Pairing.negate(proof.B_p), Pairing.P2())) return 2;