Skip to content

Instantly share code, notes, and snippets.

@lovesh
Last active April 17, 2018 02:33
Show Gist options
  • Save lovesh/99638fc8874520230b6deb260322dc55 to your computer and use it in GitHub Desktop.
Save lovesh/99638fc8874520230b6deb260322dc55 to your computer and use it in GitHub Desktop.
Temporary contract to check pairing operations
pragma solidity ^0.4.14;
pragma experimental ABIEncoderV2;
import './verifier.sol';
contract TempContract is Verifier {
bool public success = false;
event Trace0(string);
function verifyFifteen(
uint[2] a,
uint[2] a_p,
uint[2][2] b,
uint[2] b_p,
uint[2] c,
uint[2] c_p,
uint[2] h,
uint[2] k,
uint[2] input) public {
emit Trace0(">>>-1");
Pairing.G1Point memory A = Pairing.G1Point(a[0], a[1]);
Pairing.G1Point memory A_p = Pairing.G1Point(a_p[0], a_p[1]);
xyz(input, A, A_p);
success = true;
}
function xyz(uint[2] input, Pairing.G1Point A, Pairing.G1Point A_p) public {
uint[] memory inputValues = new uint[](input.length);
for(uint i = 0; i < input.length; i++){
inputValues[i] = input[i];
}
VerifyingKey memory vk = verifyingKey();
Pairing.G1Point memory vk_x = Pairing.G1Point(0, 0);
for (uint j = 0; j < inputValues.length; j++) {
vk_x = Pairing.add(vk_x, Pairing.mul(vk.IC[j + 1], inputValues[j]));
}
vk_x = Pairing.add(vk_x, vk.IC[0]);
Pairing.pairingProd2(A, vk.A, Pairing.negate(A_p), Pairing.P2());
}
function get() constant returns (bool retVal) {
return success;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment