mirror of
https://github.com/status-im/codex-contracts-eth.git
synced 2025-02-24 14:18:24 +00:00
uint -> uint256
Co-Authored-By: Balazs Komuves <bkomuves@gmail.com>
This commit is contained in:
parent
3b6f7b8ec7
commit
c55b34fc76
@ -2,16 +2,16 @@
|
|||||||
pragma solidity 0.8.23;
|
pragma solidity 0.8.23;
|
||||||
|
|
||||||
struct G1Point {
|
struct G1Point {
|
||||||
uint x;
|
uint256 x;
|
||||||
uint y;
|
uint256 y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A field element F_{p^2} encoded as `real + i * imag`.
|
// A field element F_{p^2} encoded as `real + i * imag`.
|
||||||
// We chose to not represent this as an array of 2 numbers, because both Circom
|
// We chose to not represent this as an array of 2 numbers, because both Circom
|
||||||
// and Ethereum EIP-197 encode to an array, but with conflicting encodings.
|
// and Ethereum EIP-197 encode to an array, but with conflicting encodings.
|
||||||
struct Fp2Element {
|
struct Fp2Element {
|
||||||
uint real;
|
uint256 real;
|
||||||
uint imag;
|
uint256 imag;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct G2Point {
|
struct G2Point {
|
||||||
@ -28,6 +28,6 @@ struct Groth16Proof {
|
|||||||
interface IGroth16Verifier {
|
interface IGroth16Verifier {
|
||||||
function verify(
|
function verify(
|
||||||
Groth16Proof calldata proof,
|
Groth16Proof calldata proof,
|
||||||
uint[] calldata pubSignals
|
uint256[] calldata pubSignals
|
||||||
) external view returns (bool);
|
) external view returns (bool);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ pragma solidity 0.8.23;
|
|||||||
import "./Groth16.sol";
|
import "./Groth16.sol";
|
||||||
|
|
||||||
contract Groth16Verifier is IGroth16Verifier {
|
contract Groth16Verifier is IGroth16Verifier {
|
||||||
uint private constant _P =
|
uint256 private constant _P =
|
||||||
21888242871839275222246405745257275088696311157297823662689037894645226208583;
|
21888242871839275222246405745257275088696311157297823662689037894645226208583;
|
||||||
uint256 private constant _R =
|
uint256 private constant _R =
|
||||||
21888242871839275222246405745257275088548364400416034343698204186575808495617;
|
21888242871839275222246405745257275088548364400416034343698204186575808495617;
|
||||||
@ -54,7 +54,7 @@ contract Groth16Verifier is IGroth16Verifier {
|
|||||||
G1Point memory point1,
|
G1Point memory point1,
|
||||||
G1Point memory point2
|
G1Point memory point2
|
||||||
) private view returns (bool success, G1Point memory sum) {
|
) private view returns (bool success, G1Point memory sum) {
|
||||||
uint[4] memory input;
|
uint256[4] memory input;
|
||||||
input[0] = point1.x;
|
input[0] = point1.x;
|
||||||
input[1] = point1.y;
|
input[1] = point1.y;
|
||||||
input[2] = point2.x;
|
input[2] = point2.x;
|
||||||
@ -67,9 +67,9 @@ contract Groth16Verifier is IGroth16Verifier {
|
|||||||
|
|
||||||
function _multiply(
|
function _multiply(
|
||||||
G1Point memory point,
|
G1Point memory point,
|
||||||
uint scalar
|
uint256 scalar
|
||||||
) private view returns (bool success, G1Point memory product) {
|
) private view returns (bool success, G1Point memory product) {
|
||||||
uint[3] memory input;
|
uint256[3] memory input;
|
||||||
input[0] = point.x;
|
input[0] = point.x;
|
||||||
input[1] = point.y;
|
input[1] = point.y;
|
||||||
input[2] = scalar;
|
input[2] = scalar;
|
||||||
@ -88,9 +88,9 @@ contract Groth16Verifier is IGroth16Verifier {
|
|||||||
G2Point memory c2,
|
G2Point memory c2,
|
||||||
G1Point memory d1,
|
G1Point memory d1,
|
||||||
G2Point memory d2
|
G2Point memory d2
|
||||||
) private view returns (bool success, uint outcome) {
|
) private view returns (bool success, uint256 outcome) {
|
||||||
uint[24] memory input; // 4 pairs of G1 and G2 points
|
uint256[24] memory input; // 4 pairs of G1 and G2 points
|
||||||
uint[1] memory output;
|
uint256[1] memory output;
|
||||||
|
|
||||||
input[0] = a1.x;
|
input[0] = a1.x;
|
||||||
input[1] = a1.y;
|
input[1] = a1.y;
|
||||||
@ -129,7 +129,7 @@ contract Groth16Verifier is IGroth16Verifier {
|
|||||||
|
|
||||||
function verify(
|
function verify(
|
||||||
Groth16Proof calldata proof,
|
Groth16Proof calldata proof,
|
||||||
uint[] memory input
|
uint256[] memory input
|
||||||
) public view returns (bool success) {
|
) public view returns (bool success) {
|
||||||
// Check amount of public inputs
|
// Check amount of public inputs
|
||||||
if (input.length + 1 != _verifyingKey.ic.length) {
|
if (input.length + 1 != _verifyingKey.ic.length) {
|
||||||
@ -155,7 +155,7 @@ contract Groth16Verifier is IGroth16Verifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check the pairing
|
// Check the pairing
|
||||||
uint outcome;
|
uint256 outcome;
|
||||||
(success, outcome) = _checkPairing(
|
(success, outcome) = _checkPairing(
|
||||||
_negate(proof.a),
|
_negate(proof.a),
|
||||||
proof.b,
|
proof.b,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user