From 11d3069bddf17c8cf6af41ef8abe8300841c9b7a Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Fri, 24 May 2024 10:13:46 -0600 Subject: [PATCH] new(tests): EIP-2537: BLS12-381 Precompiles (#499) * new(tests): Add eip-2537 vectors * new(tests): eip-2537 * refactor(tests): eip2537 * new(tests): more eip2537 tests * fix(tests): typos * fix(tests): eip2537: fix k length msm g1 * refactor(tests): eip-2537 * new(tests): eip-2537: multiplication gas tests * nit(tests): eip-2537: function names * fix(tests): eip2537: unused imports * new(tests): eip2537: new msm gas tests * refactor(tests): eip2537 * refactor(tests): eip2537 spec * fix(tests): eip2537, add more tests * fix(tests): eip2537: format vector * fix(tests): eip2537: update vectors from https://github.com/ethereum/bls12-381-tests/tree/eip-2537 * fix(tests): eip2537: conditional integrity check * refactor(tests): eip2537: spec * new(tests): eip2537: pairing tests * fix(tests): eip2537: spec * fix(tests): eip2537: use `Spec.INVALID` constant * new(tests): eip2537: pairing tests * new(tests): eip2537: pairing invalid gas/length tests * new(tests): eip2537: invalid encoding, G1 add, mul, msm, not in subgroup point * new(tests): eip2537: call type tests * new(tests): eip2537: g2 not in subgroup * new(tests): eip2537: incorrect subgroup tests * changelog * fix: tox * fix(tests): eip2537: comments * fix(tests): eip2537: github reference spec hash * fix(tests): eip-2537: refresh vectors * fix(tests): eip-2537: move subgroup tests valid -> invalid * fix(tests): eip-2537: load failing test vectors * feat(forks): Add BLS precompiles to Prague * fix(tests): EIP-2537: spec reference hash update * feat(tests): eip-2537: Add inputs to mul precompiles * new(tests): eip-2537: more tests * fix(tests): hardcode fork name * fix(tests): EIP-2537: load MSM table from file * new(tests): EIP-2537: test precompiles before fork is active --- docs/CHANGELOG.md | 1 + src/ethereum_test_forks/forks/forks.py | 17 + .../__init__.py | 4 + .../conftest.py | 177 +++++++ .../eip2537_bls_12_381_precompiles/helpers.py | 78 +++ .../msm_discount_table.json | 1 + .../eip2537_bls_12_381_precompiles/spec.py | 266 ++++++++++ .../test_bls12_g1add.py | 236 +++++++++ .../test_bls12_g1msm.py | 153 ++++++ .../test_bls12_g1mul.py | 240 +++++++++ .../test_bls12_g2add.py | 242 +++++++++ .../test_bls12_g2msm.py | 143 ++++++ .../test_bls12_g2mul.py | 263 ++++++++++ .../test_bls12_map_fp2_to_g2.py | 177 +++++++ .../test_bls12_map_fp_to_g1.py | 163 ++++++ .../test_bls12_pairing.py | 158 ++++++ .../test_bls12_precompiles_before_fork.py | 86 ++++ ...t_bls12_variable_length_input_contracts.py | 466 ++++++++++++++++++ .../vectors/add_G1_bls.json | 65 +++ .../vectors/add_G2_bls.json | 65 +++ .../vectors/fail-add_G1_bls.json | 32 ++ .../vectors/fail-add_G2_bls.json | 32 ++ .../vectors/fail-map_fp2_to_G2_bls.json | 27 + .../vectors/fail-map_fp_to_G1_bls.json | 27 + .../vectors/fail-mul_G1_bls.json | 37 ++ .../vectors/fail-mul_G2_bls.json | 37 ++ .../vectors/fail-multiexp_G1_bls.json | 37 ++ .../vectors/fail-multiexp_G2_bls.json | 37 ++ .../vectors/fail-pairing_check_bls.json | 47 ++ .../vectors/map_fp2_to_G2_bls.json | 37 ++ .../vectors/map_fp_to_G1_bls.json | 37 ++ .../vectors/mul_G1_bls.json | 79 +++ .../vectors/mul_G2_bls.json | 79 +++ .../vectors/multiexp_G1_bls.json | 79 +++ .../vectors/multiexp_G2_bls.json | 86 ++++ .../vectors/pairing_check_bls.json | 44 ++ .../vectors/test-vectors.md | 3 + whitelist.txt | 14 + 38 files changed, 3772 insertions(+) create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/__init__.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/conftest.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/helpers.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/msm_discount_table.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/spec.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g1add.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g1msm.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g1mul.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g2add.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g2msm.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g2mul.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/test_bls12_map_fp2_to_g2.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/test_bls12_map_fp_to_g1.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/test_bls12_pairing.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/test_bls12_precompiles_before_fork.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/add_G1_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/add_G2_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-add_G1_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-add_G2_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-map_fp2_to_G2_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-map_fp_to_G1_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-mul_G1_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-mul_G2_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-multiexp_G1_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-multiexp_G2_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-pairing_check_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/map_fp2_to_G2_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/map_fp_to_G1_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/mul_G1_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/mul_G2_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/multiexp_G1_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/multiexp_G2_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/pairing_check_bls.json create mode 100644 tests/prague/eip2537_bls_12_381_precompiles/vectors/test-vectors.md diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b2b7f127dd..bae344e295 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,6 +11,7 @@ Test fixtures for use by clients are available for each release on the [Github r - ✨ Add `test_create_selfdestruct_same_tx_increased_nonce` which tests self-destructing a contract with a nonce > 1 ([#478](https://github.com/ethereum/execution-spec-tests/pull/478)). - ✨ Add `test_double_kill` and `test_recreate` which test resurrection of accounts killed with `SELFDESTRUCT` ([#488](https://github.com/ethereum/execution-spec-tests/pull/488)). - ✨ Add eof example valid invalid tests from ori, fetch EOF Container implementation ([#535](https://github.com/ethereum/execution-spec-tests/pull/535)). +- ✨ Add tests for [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) ([#499](https://github.com/ethereum/execution-spec-tests/pull/499)). - ✨ [EIP-663](https://eips.ethereum.org/EIPS/eip-663): Add `test_dupn.py` and `test_swapn.py` ([#502](https://github.com/ethereum/execution-spec-tests/pull/502)). ### 🛠️ Framework diff --git a/src/ethereum_test_forks/forks/forks.py b/src/ethereum_test_forks/forks/forks.py index 298bc2d5f5..bd780f5a39 100644 --- a/src/ethereum_test_forks/forks/forks.py +++ b/src/ethereum_test_forks/forks/forks.py @@ -475,6 +475,23 @@ def solc_min_version(cls) -> Version: """ return Version.parse("1.0.0") # set a high version; currently unknown + @classmethod + def precompiles(cls, block_number: int = 0, timestamp: int = 0) -> List[int]: + """ + At Prague, pre-compile for BLS operations are added: + + G1ADD = 0x0B + G1MUL = 0x0C + G1MSM = 0x0D + G2ADD = 0x0E + G2MUL = 0x0F + G2MSM = 0x10 + PAIRING = 0x11 + MAP_FP_TO_G1 = 0x12 + MAP_FP2_TO_G2 = 0x13 + """ + return list(range(0xB, 0x13 + 1)) + super(Prague, cls).precompiles(block_number, timestamp) + @classmethod def engine_new_payload_version( cls, block_number: int = 0, timestamp: int = 0 diff --git a/tests/prague/eip2537_bls_12_381_precompiles/__init__.py b/tests/prague/eip2537_bls_12_381_precompiles/__init__.py new file mode 100644 index 0000000000..2cede19405 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/__init__.py @@ -0,0 +1,4 @@ +""" +abstract: Tests [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) + Tests for [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537). +""" # noqa: E501 diff --git a/tests/prague/eip2537_bls_12_381_precompiles/conftest.py b/tests/prague/eip2537_bls_12_381_precompiles/conftest.py new file mode 100644 index 0000000000..454ca4baa2 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/conftest.py @@ -0,0 +1,177 @@ +""" +Shared pytest definitions local to EIP-2537 tests. +""" +from typing import SupportsBytes + +import pytest +from ethereum.crypto.hash import keccak256 + +from ethereum_test_tools import Storage, TestAddress, Transaction +from ethereum_test_tools.vm import Opcodes as Op + +from .spec import GAS_CALCULATION_FUNCTION_MAP + + +@pytest.fixture +def precompile_gas(precompile_address: int, input: bytes) -> int: + """Gas cost for the precompile.""" + return GAS_CALCULATION_FUNCTION_MAP[precompile_address](len(input)) + + +@pytest.fixture +def precompile_gas_modifier() -> int: + """ + Used to modify the gas passed to the precompile, for testing purposes. + + By default the call is made with the exact gas amount required for the given opcode, + but when this fixture is overridden, the gas amount can be modified to, e.g., test + a lower amount and test if the precompile call fails. + """ + return 0 + + +@pytest.fixture +def call_opcode() -> Op: + """ + Type of call used to call the precompile. + + By default it is Op.CALL, but it can be overridden in the test. + """ + return Op.CALL + + +@pytest.fixture +def call_contract_post_storage() -> Storage: + """ + Storage of the test contract after the transaction is executed. + Note: Fixture `call_contract_code` fills the actual expected storage values. + """ + return Storage() + + +@pytest.fixture +def call_succeeds( + expected_output: bytes | SupportsBytes, +) -> bool: + """ + By default, depending on the expected output, we can deduce if the call is expected to succeed + or fail. + """ + return len(bytes(expected_output)) > 0 + + +@pytest.fixture +def call_contract_code( + precompile_address: int, + precompile_gas: int, + precompile_gas_modifier: int, + expected_output: bytes | SupportsBytes, + call_succeeds: bool, + call_opcode: Op, + call_contract_post_storage: Storage, +) -> bytes: + """ + Code of the test contract. + + Args: + precompile_address: + Address of the precompile to call. + precompile_gas: + Gas cost for the precompile, which is automatically calculated by the `precompile_gas` + fixture, but can be overridden in the test. + precompile_gas_modifier: + Gas cost modifier for the precompile, which is automatically set to zero by the + `precompile_gas_modifier` fixture, but can be overridden in the test. + expected_output: + Expected output of the precompile call. This value is used to determine if the call is + expected to succeed or fail. + call_succeeds: + Boolean that indicates if the call is expected to succeed or fail. + call_opcode: + Type of call used to call the precompile (Op.CALL, Op.CALLCODE, Op.DELEGATECALL, + Op.STATICCALL). + call_contract_post_storage: + Storage of the test contract after the transaction is executed. + """ + expected_output = bytes(expected_output) + + assert call_opcode in [Op.CALL, Op.CALLCODE, Op.DELEGATECALL, Op.STATICCALL] + value = [0] if call_opcode in [Op.CALL, Op.CALLCODE] else [] + + code = ( + Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE()) + + Op.SSTORE( + call_contract_post_storage.store_next(call_succeeds), + call_opcode( + precompile_gas + precompile_gas_modifier, + precompile_address, + *value, # Optional, only used for CALL and CALLCODE. + 0, + Op.CALLDATASIZE(), + 0, + 0, + ), + ) + + Op.SSTORE( + call_contract_post_storage.store_next(len(expected_output)), + Op.RETURNDATASIZE(), + ) + ) + if call_succeeds: + # Add integrity check only if the call is expected to succeed. + code += Op.RETURNDATACOPY(0, 0, Op.RETURNDATASIZE()) + Op.SSTORE( + call_contract_post_storage.store_next(keccak256(expected_output)), + Op.SHA3(0, Op.RETURNDATASIZE()), + ) + + return code + + +@pytest.fixture +def call_contract_address() -> int: + """Address where the test contract will be deployed.""" + return 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + + +@pytest.fixture +def pre(call_contract_address: int, call_contract_code: bytes): + """Pre-allocation for every test.""" + return { + call_contract_address: { + "balance": 0, + "nonce": 1, + "code": call_contract_code, + }, + TestAddress: { + "balance": 1_000_000_000_000_000, + "nonce": 0, + }, + } + + +@pytest.fixture +def post(call_contract_address: int, call_contract_post_storage: Storage): + """Test expected post outcome.""" + return { + call_contract_address: { + "storage": call_contract_post_storage, + }, + } + + +@pytest.fixture +def tx_gas_limit(precompile_gas: int) -> int: + """ + Transaction gas limit used for the test (Can be overridden in the test). + """ + return 10_000_000 + precompile_gas + + +@pytest.fixture +def tx(input: bytes, tx_gas_limit: int, call_contract_address: int) -> Transaction: + """Transaction for the test.""" + return Transaction( + gas_limit=tx_gas_limit, + input=input, + to=call_contract_address, + ) diff --git a/tests/prague/eip2537_bls_12_381_precompiles/helpers.py b/tests/prague/eip2537_bls_12_381_precompiles/helpers.py new file mode 100644 index 0000000000..9030365ecb --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/helpers.py @@ -0,0 +1,78 @@ +""" +Helper functions for the EIP-2537 BLS12-381 precompiles tests. +""" +import os +from typing import Annotated, List + +import pytest +from pydantic import BaseModel, BeforeValidator, ConfigDict, RootModel, TypeAdapter +from pydantic.alias_generators import to_pascal + + +def current_python_script_directory(*args: str) -> str: + """ + Get the current Python script directory, optionally appending additional path components. + """ + return os.path.join(os.path.dirname(os.path.realpath(__file__)), *args) + + +class TestVector(BaseModel): + """ + Test vector for the BLS12-381 precompiles. + """ + + input: Annotated[bytes, BeforeValidator(bytes.fromhex)] + expected: Annotated[bytes, BeforeValidator(bytes.fromhex)] + gas: int + name: str + + model_config = ConfigDict(alias_generator=to_pascal) + + def to_pytest_param(self): + """ + Convert the test vector to a tuple that can be used as a parameter in a pytest test. + """ + return pytest.param(self.input, self.expected, id=self.name) + + +class FailTestVector(BaseModel): + """ + Test vector for the BLS12-381 precompiles. + """ + + input: Annotated[bytes, BeforeValidator(bytes.fromhex)] + expected_error: str + name: str + + model_config = ConfigDict(alias_generator=to_pascal) + + def to_pytest_param(self): + """ + Convert the test vector to a tuple that can be used as a parameter in a pytest test. + """ + return pytest.param(self.input, id=self.name) + + +class TestVectorList(RootModel): + """ + List of test vectors for the BLS12-381 precompiles. + """ + + root: List[TestVector | FailTestVector] + + +TestVectorListAdapter = TypeAdapter(TestVectorList) + + +def vectors_from_file(filename: str) -> List: + """ + Load test vectors from a file. + """ + with open( + current_python_script_directory( + "vectors", + filename, + ), + "rb", + ) as f: + return [v.to_pytest_param() for v in TestVectorListAdapter.validate_json(f.read()).root] diff --git a/tests/prague/eip2537_bls_12_381_precompiles/msm_discount_table.json b/tests/prague/eip2537_bls_12_381_precompiles/msm_discount_table.json new file mode 100644 index 0000000000..570d39244f --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/msm_discount_table.json @@ -0,0 +1 @@ +[0,1200,888,764,641,594,547,500,453,438,423,408,394,379,364,349,334,330,326,322,318,314,310,306,302,298,294,289,285,281,277,273,269,268,266,265,263,262,260,259,257,256,254,253,251,250,248,247,245,244,242,241,239,238,236,235,233,232,231,229,228,226,225,223,222,221,220,219,219,218,217,216,216,215,214,213,213,212,211,211,210,209,208,208,207,206,205,205,204,203,202,202,201,200,199,199,198,197,196,196,195,194,193,193,192,191,191,190,189,188,188,187,186,185,185,184,183,182,182,181,180,179,179,178,177,176,176,175,174] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/spec.py b/tests/prague/eip2537_bls_12_381_precompiles/spec.py new file mode 100644 index 0000000000..513a2ae9b2 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/spec.py @@ -0,0 +1,266 @@ +""" +Defines EIP-2537 specification constants and functions. +""" +import json +from dataclasses import dataclass +from typing import Callable, List, Sized, SupportsBytes, Tuple + +from .helpers import current_python_script_directory + + +@dataclass(frozen=True) +class ReferenceSpec: + """ + Defines the reference spec version and git path. + """ + + git_path: str + version: str + + +ref_spec_2537 = ReferenceSpec("EIPS/eip-2537.md", "cd0f016ad0c4c68b8b1f5c502ef61ab9353b6e5e") + + +class BytesConcatenation(SupportsBytes, Sized): + """ + A class that can be concatenated with bytes. + """ + + def __len__(self) -> int: + """Returns the length of the object when converted to bytes.""" + return len(bytes(self)) + + def __add__(self, other: bytes | SupportsBytes) -> bytes: + """Concatenates the object with another bytes object.""" + return bytes(self) + bytes(other) + + def __radd__(self, other: bytes | SupportsBytes) -> bytes: + """Concatenates the object with another bytes object.""" + return bytes(other) + bytes(self) + + +@dataclass(frozen=True) +class FP(BytesConcatenation): + """Dataclass that defines a single element of Fp.""" + + x: int = 0 + + def __bytes__(self) -> bytes: + """Converts the field element to bytes.""" + return self.x.to_bytes(64, byteorder="big") + + +@dataclass(frozen=True) +class PointG1(BytesConcatenation): + """Dataclass that defines a single point in G1.""" + + x: int = 0 + y: int = 0 + + def __bytes__(self) -> bytes: + """Converts the point to bytes.""" + return self.x.to_bytes(64, byteorder="big") + self.y.to_bytes(64, byteorder="big") + + def __neg__(self): + """Negates the point.""" + return PointG1(self.x, Spec.P - self.y) + + +@dataclass(frozen=True) +class FP2(BytesConcatenation): + """Dataclass that defines a single element of Fp2.""" + + x: Tuple[int, int] = (0, 0) + + def __bytes__(self) -> bytes: + """Converts the field element to bytes.""" + return self.x[0].to_bytes(64, byteorder="big") + self.x[1].to_bytes(64, byteorder="big") + + +@dataclass(frozen=True) +class PointG2(BytesConcatenation): + """Dataclass that defines a single point in G2.""" + + x: Tuple[int, int] = (0, 0) + y: Tuple[int, int] = (0, 0) + + def __bytes__(self) -> bytes: + """Converts the point to bytes.""" + return ( + self.x[0].to_bytes(64, byteorder="big") + + self.x[1].to_bytes(64, byteorder="big") + + self.y[0].to_bytes(64, byteorder="big") + + self.y[1].to_bytes(64, byteorder="big") + ) + + def __neg__(self): + """Negates the point.""" + return PointG2(self.x, (Spec.P - self.y[0], Spec.P - self.y[1])) + + +@dataclass(frozen=True) +class Scalar(BytesConcatenation): + """Dataclass that defines a single scalar.""" + + x: int = 0 + + def __bytes__(self) -> bytes: + """Converts the scalar to bytes.""" + return self.x.to_bytes(32, byteorder="big") + + +with open(current_python_script_directory("msm_discount_table.json")) as f: + MSM_DISCOUNT_TABLE: List[int] = json.load(f) + assert type(MSM_DISCOUNT_TABLE) is list + + +@dataclass(frozen=True) +class Spec: + """ + Parameters from the EIP-2537 specifications as defined at + https://eips.ethereum.org/EIPS/eip-2537 + """ + + # Addresses + G1ADD = 0x0B + G1MUL = 0x0C + G1MSM = 0x0D + G2ADD = 0x0E + G2MUL = 0x0F + G2MSM = 0x10 + PAIRING = 0x11 + MAP_FP_TO_G1 = 0x12 + MAP_FP2_TO_G2 = 0x13 + + # Gas constants + G1ADD_GAS = 500 + G1MUL_GAS = 12_000 + G2ADD_GAS = 800 + G2MUL_GAS = 45_000 + MAP_FP_TO_G1_GAS = 5_500 + MAP_FP2_TO_G2_GAS = 75_000 + PAIRING_BASE_GAS = 65_000 + PAIRING_PER_PAIR_GAS = 43_000 + + # Other constants + B_COEFFICIENT = 0x04 + X = -0xD201000000010000 + Q = X**4 - X**2 + 1 + P = (X - 1) ** 2 * Q // 3 + X + LEN_PER_PAIR = len(PointG1() + PointG2()) + MSM_MULTIPLIER = 1_000 + MSM_DISCOUNT_TABLE = MSM_DISCOUNT_TABLE + + # Test constants (from https://github.com/ethereum/bls12-381-tests/tree/eip-2537) + P1 = PointG1( # random point in G1 + 0x112B98340EEE2777CC3C14163DEA3EC97977AC3DC5C70DA32E6E87578F44912E902CCEF9EFE28D4A78B8999DFBCA9426, # noqa: E501 + 0x186B28D92356C4DFEC4B5201AD099DBDEDE3781F8998DDF929B4CD7756192185CA7B8F4EF7088F813270AC3D48868A21, # noqa: E501 + ) + G1 = PointG1( + 0x17F1D3A73197D7942695638C4FA9AC0FC3688C4F9774B905A14E3A3F171BAC586C55E83FF97A1AEFFB3AF00ADB22C6BB, # noqa: E501 + 0x8B3F481E3AAA0F1A09E30ED741D8AE4FCF5E095D5D00AF600DB18CB2C04B3EDD03CC744A2888AE40CAA232946C5E7E1, # noqa: E501 + ) + # point at infinity in G1 + INF_G1 = PointG1(0, 0) + # random point in G2 + P2 = PointG2( + ( + 0x103121A2CEAAE586D240843A398967325F8EB5A93E8FEA99B62B9F88D8556C80DD726A4B30E84A36EEABAF3592937F27, # noqa: E501 + 0x86B990F3DA2AEAC0A36143B7D7C824428215140DB1BB859338764CB58458F081D92664F9053B50B3FBD2E4723121B68, # noqa: E501 + ), + ( + 0xF9E7BA9A86A8F7624AA2B42DCC8772E1AF4AE115685E60ABC2C9B90242167ACEF3D0BE4050BF935EED7C3B6FC7BA77E, # noqa: E501 + 0xD22C3652D0DC6F0FC9316E14268477C2049EF772E852108D269D9C38DBA1D4802E8DAE479818184C08F9A569D878451, # noqa: E501 + ), + ) + G2 = PointG2( + ( + 0x24AA2B2F08F0A91260805272DC51051C6E47AD4FA403B02B4510B647AE3D1770BAC0326A805BBEFD48056C8C121BDB8, # noqa: E501 + 0x13E02B6052719F607DACD3A088274F65596BD0D09920B61AB5DA61BBDC7F5049334CF11213945D57E5AC7D055D042B7E, # noqa: E501 + ), + ( + 0xCE5D527727D6E118CC9CDC6DA2E351AADFD9BAA8CBDD3A76D429A695160D12C923AC9CC3BACA289E193548608B82801, # noqa: E501 + 0x606C4A02EA734CC32ACD2B02BC28B99CB3E287E85A763AF267492AB572E99AB3F370D275CEC1DA1AAA9075FF05F79BE, # noqa: E501 + ), + ) + # point at infinity in G2 + INF_G2 = PointG2((0, 0), (0, 0)) + + # Other test constants + # point not in subgroup in curve Fp + P1_NOT_IN_SUBGROUP = PointG1(0, 2) + P1_NOT_IN_SUBGROUP_TIMES_2 = PointG1(0, P - 2) + # point not in subgroup in curve Fp2 + P2_NOT_IN_SUBGROUP = PointG2( + (1, 1), + ( + 0x17FAA6201231304F270B858DAD9462089F2A5B83388E4B10773ABC1EEF6D193B9FCE4E8EA2D9D28E3C3A315AA7DE14CA, # noqa: E501 + 0xCC12449BE6AC4E7F367E7242250427C4FB4C39325D3164AD397C1837A90F0EA1A534757DF374DD6569345EB41ED76E, # noqa: E501 + ), + ) + P2_NOT_IN_SUBGROUP_TIMES_2 = PointG2( + ( + 0x919F97860ECC3E933E3477FCAC0E2E4FCC35A6E886E935C97511685232456263DEF6665F143CCCCB44C733333331553, # noqa: E501 + 0x18B4376B50398178FA8D78ED2654B0FFD2A487BE4DBE6B69086E61B283F4E9D58389CCCB8EDC99995718A66666661555, # noqa: E501 + ), + ( + 0x26898F699C4B07A405AB4183A10B47F923D1C0FDA1018682DD2CCC88968C1B90D44534D6B9270CF57F8DC6D4891678A, # noqa: E501 + 0x3270414330EAD5EC92219A03A24DFA059DBCBE610868BE1851CC13DAC447F60B40D41113FD007D3307B19ADD4B0F061, # noqa: E501 + ), + ) + + # Pairing precompile results + PAIRING_TRUE = int.to_bytes(1, length=32, byteorder="big") + PAIRING_FALSE = int.to_bytes(0, length=32, byteorder="big") + + # Returned on precompile failure + INVALID = b"" + + +def msm_discount(k: int) -> int: + """ + Returns the discount for the G1MSM and G2MSM precompiles. + """ + return Spec.MSM_DISCOUNT_TABLE[min(k, 128)] + + +def msm_gas_func_gen(len_per_pair: int, multiplication_cost: int) -> Callable[[int], int]: + """ + Generates a function that calculates the gas cost for the G1MSM and G2MSM + precompiles. + """ + + def msm_gas(input_length: int) -> int: + """ + Calculates the gas cost for the G1MSM and G2MSM precompiles. + """ + k = input_length // len_per_pair + if k == 0: + return 0 + + gas_cost = k * multiplication_cost * msm_discount(k) // Spec.MSM_MULTIPLIER + + return gas_cost + + return msm_gas + + +def pairing_gas(input_length: int) -> int: + """ + Calculates the gas cost for the PAIRING precompile. + """ + k = input_length // Spec.LEN_PER_PAIR + return (Spec.PAIRING_PER_PAIR_GAS * k) + Spec.PAIRING_BASE_GAS + + +GAS_CALCULATION_FUNCTION_MAP = { + Spec.G1ADD: lambda _: Spec.G1ADD_GAS, + Spec.G1MUL: lambda _: Spec.G1MUL_GAS, + Spec.G1MSM: msm_gas_func_gen(len(PointG1() + Scalar()), Spec.G1MUL_GAS), + Spec.G2ADD: lambda _: Spec.G2ADD_GAS, + Spec.G2MUL: lambda _: Spec.G2MUL_GAS, + Spec.G2MSM: msm_gas_func_gen(len(PointG2() + Scalar()), Spec.G2MUL_GAS), + Spec.PAIRING: pairing_gas, + Spec.MAP_FP_TO_G1: lambda _: Spec.MAP_FP_TO_G1_GAS, + Spec.MAP_FP2_TO_G2: lambda _: Spec.MAP_FP2_TO_G2_GAS, +} diff --git a/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g1add.py b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g1add.py new file mode 100644 index 0000000000..7d03436eb8 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g1add.py @@ -0,0 +1,236 @@ +""" +abstract: Tests BLS12_G1ADD precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) + Tests BLS12_G1ADD precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537). +""" # noqa: E501 + +import pytest + +from ethereum_test_tools import Environment +from ethereum_test_tools import Opcodes as Op +from ethereum_test_tools import StateTestFiller, Transaction + +from .helpers import vectors_from_file +from .spec import PointG1, Spec, ref_spec_2537 + +REFERENCE_SPEC_GIT_PATH = ref_spec_2537.git_path +REFERENCE_SPEC_VERSION = ref_spec_2537.version + +pytestmark = [ + pytest.mark.valid_from("Prague"), + pytest.mark.parametrize("precompile_address", [Spec.G1ADD], ids=[""]), +] + + +@pytest.mark.parametrize( + "input,expected_output", + vectors_from_file("add_G1_bls.json") + + [ + pytest.param( + Spec.INF_G1 + Spec.INF_G1, + Spec.INF_G1, + id="inf_plus_inf", + ), + pytest.param( + Spec.P1_NOT_IN_SUBGROUP + Spec.P1_NOT_IN_SUBGROUP, + Spec.P1_NOT_IN_SUBGROUP_TIMES_2, + id="not_in_subgroup_1", + ), + pytest.param( + Spec.P1_NOT_IN_SUBGROUP + Spec.P1_NOT_IN_SUBGROUP_TIMES_2, + Spec.INF_G1, + id="not_in_subgroup_2", + ), + ], +) +def test_valid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G1ADD precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input", + vectors_from_file("fail-add_G1_bls.json") + + [ + pytest.param( + PointG1(0, 1) + Spec.INF_G1, + id="invalid_point_a_1", + ), + pytest.param( + PointG1(Spec.P1.x, Spec.P1.y - 1) + Spec.INF_G1, + id="invalid_point_a_2", + ), + pytest.param( + PointG1(Spec.P1.x, Spec.P1.y + 1) + Spec.INF_G1, + id="invalid_point_a_3", + ), + pytest.param( + PointG1(Spec.P1.x, Spec.P1.x) + Spec.INF_G1, + id="invalid_point_a_4", + ), + pytest.param( + PointG1(Spec.P1.x, Spec.P1.y - 1) + Spec.P1, + id="invalid_point_a_5", + ), + pytest.param( + Spec.INF_G1 + PointG1(0, 1), + id="invalid_point_b_1", + ), + pytest.param( + Spec.INF_G1 + PointG1(Spec.P1.x, Spec.P1.y - 1), + id="invalid_point_b_2", + ), + pytest.param( + Spec.INF_G1 + PointG1(Spec.P1.x, Spec.P1.y + 1), + id="invalid_point_b_3", + ), + pytest.param( + Spec.INF_G1 + PointG1(Spec.P1.x, Spec.P1.x), + id="invalid_point_b_4", + ), + pytest.param( + Spec.P1 + PointG1(Spec.P1.x, Spec.P1.y - 1), + id="invalid_point_b_5", + ), + pytest.param( + PointG1(Spec.P, 0) + Spec.INF_G1, + id="a_x_equal_to_p", + ), + pytest.param( + Spec.INF_G1 + PointG1(Spec.P, 0), + id="b_x_equal_to_p", + ), + pytest.param( + PointG1(0, Spec.P) + Spec.INF_G1, + id="a_y_equal_to_p", + ), + pytest.param( + Spec.INF_G1 + PointG1(0, Spec.P), + id="b_y_equal_to_p", + ), + pytest.param( + b"\x80" + bytes(Spec.INF_G1)[1:] + Spec.INF_G1, + id="invalid_encoding_a", + ), + pytest.param( + Spec.INF_G1 + b"\x80" + bytes(Spec.INF_G1)[1:], + id="invalid_encoding_b", + ), + pytest.param( + (Spec.INF_G1 + PointG1(Spec.P1.x, Spec.P1.x))[:-1], + id="input_too_short", + ), + pytest.param( + b"\x00" + (Spec.INF_G1 + PointG1(Spec.P1.x, Spec.P1.x)), + id="input_too_long", + ), + pytest.param( + b"", + id="zero_length_input", + ), + pytest.param( + Spec.G1, + id="only_one_point", + ), + pytest.param( + Spec.G2 + Spec.G2, + id="g2_points", + ), + ], +) +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +def test_invalid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Negative tests for the BLS12_G1ADD precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input,expected_output,precompile_gas_modifier", + [ + pytest.param( + Spec.INF_G1 + Spec.INF_G1, + Spec.INF_G1, + 1, + id="extra_gas", + ), + pytest.param( + Spec.INF_G1 + Spec.INF_G1, + Spec.INVALID, + -1, + id="insufficient_gas", + ), + ], +) +def test_gas( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G1ADD precompile gas requirements. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "call_opcode", + [ + Op.STATICCALL, + Op.DELEGATECALL, + Op.CALLCODE, + ], +) +@pytest.mark.parametrize( + "input,expected_output", + [ + pytest.param( + Spec.INF_G1 + Spec.INF_G1, + Spec.INF_G1, + id="inf_plus_inf", + ), + ], +) +def test_call_types( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G1ADD precompile using different call types. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) diff --git a/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g1msm.py b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g1msm.py new file mode 100644 index 0000000000..94f53e45dd --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g1msm.py @@ -0,0 +1,153 @@ +""" +abstract: Tests BLS12_G1MSM precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) + Tests BLS12_G1MSM precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537). +""" # noqa: E501 + +import pytest + +from ethereum_test_tools import Environment +from ethereum_test_tools import Opcodes as Op +from ethereum_test_tools import StateTestFiller, Transaction + +from .helpers import vectors_from_file +from .spec import PointG1, Scalar, Spec, ref_spec_2537 + +REFERENCE_SPEC_GIT_PATH = ref_spec_2537.git_path +REFERENCE_SPEC_VERSION = ref_spec_2537.version + +pytestmark = [ + pytest.mark.valid_from("Prague"), + pytest.mark.parametrize("precompile_address", [Spec.G1MSM], ids=[""]), +] + + +@pytest.mark.parametrize( + "input,expected_output", + vectors_from_file("multiexp_G1_bls.json") + + [ + pytest.param( + (Spec.P1 + Scalar(Spec.Q)) * (len(Spec.MSM_DISCOUNT_TABLE) - 1), + Spec.INF_G1, + id="max_discount", + ), + pytest.param( + (Spec.P1 + Scalar(Spec.Q)) * len(Spec.MSM_DISCOUNT_TABLE), + Spec.INF_G1, + id="max_discount_plus_1", + ), + ], +) +def test_valid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G1MSM precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input", + vectors_from_file("fail-multiexp_G1_bls.json") + + [ + pytest.param( + PointG1(0, 1) + Scalar(0), + id="invalid_point_1", + ), + pytest.param( + PointG1(Spec.P1.x, Spec.P1.y - 1) + Scalar(0), + id="invalid_point_2", + ), + pytest.param( + PointG1(Spec.P1.x, Spec.P1.y + 1) + Scalar(0), + id="invalid_point_3", + ), + pytest.param( + PointG1(Spec.P1.x, Spec.P1.x) + Scalar(0), + id="invalid_point_4", + ), + pytest.param( + b"\x80" + bytes(Spec.INF_G1)[1:] + Scalar(0), + id="invalid_encoding", + ), + pytest.param( + b"\x80" + bytes(Spec.INF_G1)[1:] + Scalar(0), + id="invalid_encoding", + ), + pytest.param( + Spec.P1_NOT_IN_SUBGROUP + Scalar(Spec.Q), + id="not_in_subgroup_1", + ), + pytest.param( + Spec.P1_NOT_IN_SUBGROUP_TIMES_2 + Scalar(Spec.Q), + id="not_in_subgroup_2", + ), + pytest.param( + Spec.G1, + id="bls_g1_truncated_input", + ), + ], + # Input length tests can be found in ./test_bls12_variable_length_input_contracts.py +) +@pytest.mark.parametrize( + "precompile_gas_modifier", [100_000], ids=[""] +) # Add gas so that won't be the cause of failure +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +def test_invalid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G1MSM precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "call_opcode", + [ + Op.STATICCALL, + Op.DELEGATECALL, + Op.CALLCODE, + ], +) +@pytest.mark.parametrize( + "input,expected_output", + [ + pytest.param( + Spec.INF_G1 + Scalar(0), + Spec.INF_G1, + id="inf_times_zero", + ), + ], +) +def test_call_types( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G1MSM precompile using different call types. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) diff --git a/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g1mul.py b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g1mul.py new file mode 100644 index 0000000000..9b2c24232e --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g1mul.py @@ -0,0 +1,240 @@ +""" +abstract: Tests BLS12_G1MUL precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) + Tests BLS12_G1MUL precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537). +""" # noqa: E501 + +import pytest + +from ethereum_test_tools import Environment +from ethereum_test_tools import Opcodes as Op +from ethereum_test_tools import StateTestFiller, Transaction + +from .helpers import vectors_from_file +from .spec import PointG1, Scalar, Spec, ref_spec_2537 + +REFERENCE_SPEC_GIT_PATH = ref_spec_2537.git_path +REFERENCE_SPEC_VERSION = ref_spec_2537.version + +pytestmark = [ + pytest.mark.valid_from("Prague"), + pytest.mark.parametrize("precompile_address", [Spec.G1MUL], ids=[""]), +] + + +@pytest.mark.parametrize( + "input,expected_output", + vectors_from_file("mul_G1_bls.json") + + [ + pytest.param( + Spec.INF_G1 + Scalar(0), + Spec.INF_G1, + id="bls_g1mul_(0*inf=inf)", + ), + pytest.param( + Spec.INF_G1 + Scalar(2**256 - 1), + Spec.INF_G1, + id="bls_g1mul_(2**256-1*inf=inf)", + ), + pytest.param( + Spec.P1 + Scalar(2**256 - 1), + PointG1( + 0x3DA1F13DDEF2B8B5A46CD543CE56C0A90B8B3B0D6D43DEC95836A5FD2BACD6AA8F692601F870CF22E05DDA5E83F460B, # noqa: E501 + 0x18D64F3C0E9785365CBDB375795454A8A4FA26F30B9C4F6E33CA078EB5C29B7AEA478B076C619BC1ED22B14C95569B2D, # noqa: E501 + ), + id="bls_g1mul_(2**256-1*P1)", + ), + pytest.param( + Spec.P1 + Scalar(Spec.Q - 1), + -Spec.P1, # negated P1 + id="bls_g1mul_(q-1*P1)", + ), + pytest.param( + Spec.P1 + Scalar(Spec.Q), + Spec.INF_G1, + id="bls_g1mul_(q*P1)", + ), + pytest.param( + Spec.P1 + Scalar(Spec.Q + 1), + Spec.P1, + id="bls_g1mul_(q+1*P1)", + ), + pytest.param( + Spec.P1 + Scalar(2 * Spec.Q), + Spec.INF_G1, + id="bls_g1mul_(2q*P1)", + ), + pytest.param( + Spec.P1 + Scalar((2**256 // Spec.Q) * Spec.Q), + Spec.INF_G1, + id="bls_g1mul_(Nq*P1)", + ), + ], +) +def test_valid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G1MUL precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input", + vectors_from_file("fail-mul_G1_bls.json") + + [ + pytest.param( + PointG1(0, 1) + Scalar(0), + id="invalid_point_1", + ), + pytest.param( + PointG1(Spec.P1.x, Spec.P1.y - 1) + Scalar(0), + id="invalid_point_2", + ), + pytest.param( + PointG1(Spec.P1.x, Spec.P1.y + 1) + Scalar(0), + id="invalid_point_3", + ), + pytest.param( + PointG1(Spec.P1.x, Spec.P1.x) + Scalar(0), + id="invalid_point_4", + ), + pytest.param( + b"\x80" + bytes(Spec.INF_G1)[1:] + Scalar(0), + id="invalid_encoding", + ), + pytest.param( + (Spec.INF_G1 + Scalar(0))[:-1], + id="input_too_short", + ), + pytest.param( + b"\x00" + (Spec.INF_G1 + Scalar(0)), + id="input_too_long", + ), + pytest.param( + b"", + id="zero_length_input", + ), + pytest.param( + Spec.P1_NOT_IN_SUBGROUP + Scalar(1), + id="bls_g1mul_not_in_subgroup_1", + ), + pytest.param( + Spec.P1_NOT_IN_SUBGROUP_TIMES_2 + Scalar(1), + id="bls_g1mul_not_in_subgroup_2", + ), + pytest.param( + Spec.P1_NOT_IN_SUBGROUP_TIMES_2 + Scalar(Spec.Q), + id="bls_g1mul_not_in_subgroup_times_q", + ), + pytest.param( + Spec.P1_NOT_IN_SUBGROUP + Scalar(Spec.Q), + id="bls_g1mul_not_in_subgroup_times_q_2", + ), + pytest.param( + Spec.G1 + Spec.G1, + id="bls_g1_add_input_invalid_length", + ), + pytest.param( + Spec.G2 + Spec.G2, + id="bls_g2_add_input_invalid_length", + ), + pytest.param( + Spec.G1, + id="bls_g1_truncated_input", + ), + ], +) +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +def test_invalid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Negative tests for the BLS12_G1MUL precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input,expected_output,precompile_gas_modifier", + [ + pytest.param( + Spec.INF_G1 + Scalar(0), + Spec.INF_G1, + 1, + id="extra_gas", + ), + pytest.param( + Spec.INF_G1 + Scalar(0), + Spec.INVALID, + -1, + id="insufficient_gas", + ), + ], +) +def test_gas( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G1MUL precompile gas requirements. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "call_opcode", + [ + Op.STATICCALL, + Op.DELEGATECALL, + Op.CALLCODE, + ], +) +@pytest.mark.parametrize( + "input,expected_output", + [ + pytest.param( + Spec.INF_G1 + Scalar(0), + Spec.INF_G1, + id="bls_g1mul_(0*inf=inf)", + ), + ], +) +def test_call_types( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G1MUL precompile using different call types. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) diff --git a/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g2add.py b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g2add.py new file mode 100644 index 0000000000..adcd905427 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g2add.py @@ -0,0 +1,242 @@ +""" +abstract: Tests BLS12_G2ADD precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) + Tests BLS12_G2ADD precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537). +""" # noqa: E501 + +import pytest + +from ethereum_test_tools import Environment +from ethereum_test_tools import Opcodes as Op +from ethereum_test_tools import StateTestFiller, Transaction + +from .helpers import vectors_from_file +from .spec import PointG2, Spec, ref_spec_2537 + +REFERENCE_SPEC_GIT_PATH = ref_spec_2537.git_path +REFERENCE_SPEC_VERSION = ref_spec_2537.version + +pytestmark = [ + pytest.mark.valid_from("Prague"), + pytest.mark.parametrize("precompile_address", [Spec.G2ADD], ids=[""]), +] + + +@pytest.mark.parametrize( + "input,expected_output", + vectors_from_file("add_G2_bls.json") + + [ + pytest.param( + Spec.P2_NOT_IN_SUBGROUP + Spec.P2_NOT_IN_SUBGROUP, + Spec.P2_NOT_IN_SUBGROUP_TIMES_2, + id="not_in_subgroup", + ), + ], +) +def test_valid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G2ADD precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input", + vectors_from_file("fail-add_G2_bls.json") + + [ + pytest.param( + PointG2((1, 0), (0, 0)) + Spec.INF_G2, + id="invalid_point_a_1", + ), + pytest.param( + PointG2((0, 0), (1, 0)) + Spec.INF_G2, + id="invalid_point_a_2", + ), + pytest.param( + PointG2((0, 1), (0, 0)) + Spec.INF_G2, + id="invalid_point_a_3", + ), + pytest.param( + PointG2((0, 0), (0, 1)) + Spec.INF_G2, + id="invalid_point_a_4", + ), + pytest.param( + PointG2(Spec.P2.x, (Spec.P2.y[0], Spec.P2.y[1] - 1)) + Spec.P2, + id="invalid_point_a_5", + ), + pytest.param( + Spec.INF_G2 + PointG2((1, 0), (0, 0)), + id="invalid_point_b_1", + ), + pytest.param( + Spec.INF_G2 + PointG2((0, 0), (1, 0)), + id="invalid_point_b_2", + ), + pytest.param( + Spec.INF_G2 + PointG2((0, 1), (0, 0)), + id="invalid_point_b_3", + ), + pytest.param( + Spec.INF_G2 + PointG2((0, 0), (0, 1)), + id="invalid_point_b_4", + ), + pytest.param( + Spec.P2 + PointG2(Spec.P2.x, (Spec.P2.y[0], Spec.P2.y[1] - 1)), + id="invalid_point_b_5", + ), + pytest.param( + PointG2((Spec.P, 0), (0, 0)) + Spec.INF_G2, + id="a_x_1_equal_to_p", + ), + pytest.param( + PointG2((0, Spec.P), (0, 0)) + Spec.INF_G2, + id="a_x_2_equal_to_p", + ), + pytest.param( + PointG2((0, 0), (Spec.P, 0)) + Spec.INF_G2, + id="a_y_1_equal_to_p", + ), + pytest.param( + PointG2((0, 0), (0, Spec.P)) + Spec.INF_G2, + id="a_y_2_equal_to_p", + ), + pytest.param( + Spec.INF_G2 + PointG2((Spec.P, 0), (0, 0)), + id="b_x_1_equal_to_p", + ), + pytest.param( + Spec.INF_G2 + PointG2((0, Spec.P), (0, 0)), + id="b_x_2_equal_to_p", + ), + pytest.param( + Spec.INF_G2 + PointG2((0, 0), (Spec.P, 0)), + id="b_y_1_equal_to_p", + ), + pytest.param( + Spec.INF_G2 + PointG2((0, 0), (0, Spec.P)), + id="b_y_2_equal_to_p", + ), + pytest.param( + b"\x80" + bytes(Spec.INF_G2)[1:] + Spec.INF_G2, + id="invalid_encoding_a", + ), + pytest.param( + Spec.INF_G2 + b"\x80" + bytes(Spec.INF_G2)[1:], + id="invalid_encoding_b", + ), + pytest.param( + (Spec.INF_G2 + Spec.INF_G2)[:-1], + id="input_too_short", + ), + pytest.param( + b"\x00" + (Spec.INF_G2 + Spec.INF_G2), + id="input_too_long", + ), + pytest.param( + b"", + id="zero_length_input", + ), + pytest.param( + Spec.G2, + id="only_one_point", + ), + pytest.param( + Spec.G1 + Spec.G1, + id="g1_points", + ), + ], +) +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +def test_invalid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Negative tests for the BLS12_G2ADD precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input,expected_output,precompile_gas_modifier", + [ + pytest.param( + Spec.INF_G2 + Spec.INF_G2, + Spec.INF_G2, + 1, + id="extra_gas", + ), + pytest.param( + Spec.INF_G2 + Spec.INF_G2, + Spec.INVALID, + -1, + id="insufficient_gas", + ), + ], +) +def test_gas( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G2ADD precompile gas requirements. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "call_opcode", + [ + Op.STATICCALL, + Op.DELEGATECALL, + Op.CALLCODE, + ], +) +@pytest.mark.parametrize( + "input,expected_output", + [ + pytest.param( + Spec.INF_G2 + Spec.INF_G2, + Spec.INF_G2, + id="inf_plus_inf", + ), + ], +) +def test_call_types( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G2ADD precompile using different call types. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) diff --git a/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g2msm.py b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g2msm.py new file mode 100644 index 0000000000..e3236c7787 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g2msm.py @@ -0,0 +1,143 @@ +""" +abstract: Tests BLS12_G2MSM precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) + Tests BLS12_G2MSM precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537). +""" # noqa: E501 + +import pytest + +from ethereum_test_tools import Environment +from ethereum_test_tools import Opcodes as Op +from ethereum_test_tools import StateTestFiller, Transaction + +from .helpers import vectors_from_file +from .spec import PointG2, Scalar, Spec, ref_spec_2537 + +REFERENCE_SPEC_GIT_PATH = ref_spec_2537.git_path +REFERENCE_SPEC_VERSION = ref_spec_2537.version + +pytestmark = [ + pytest.mark.valid_from("Prague"), + pytest.mark.parametrize("precompile_address", [Spec.G2MSM], ids=[""]), +] + + +@pytest.mark.parametrize("input,expected_output", vectors_from_file("multiexp_G2_bls.json")) +def test_valid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G2MSM precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input", + vectors_from_file("fail-multiexp_G2_bls.json") + + [ + pytest.param( + PointG2((1, 0), (0, 0)) + Scalar(0), + id="invalid_point_a_1", + ), + pytest.param( + PointG2((0, 1), (0, 0)) + Scalar(0), + id="invalid_point_a_2", + ), + pytest.param( + PointG2((0, 0), (1, 0)) + Scalar(0), + id="invalid_point_a_3", + ), + pytest.param( + PointG2((0, 0), (0, 1)) + Scalar(0), + id="invalid_point_a_4", + ), + pytest.param( + PointG2((Spec.P, 0), (0, 0)) + Scalar(0), + id="x_1_equal_to_p", + ), + pytest.param( + PointG2((0, Spec.P), (0, 0)) + Scalar(0), + id="x_2_equal_to_p", + ), + pytest.param( + PointG2((0, 0), (Spec.P, 0)) + Scalar(0), + id="y_1_equal_to_p", + ), + pytest.param( + PointG2((0, 0), (0, Spec.P)) + Scalar(0), + id="y_2_equal_to_p", + ), + pytest.param( + b"\x80" + bytes(Spec.INF_G2)[1:] + Scalar(0), + id="invalid_encoding", + ), + pytest.param( + Spec.P2_NOT_IN_SUBGROUP + Scalar(1), + id="bls_g2mul_not_in_subgroup", + ), + pytest.param( + Spec.G2, + id="bls_g2_truncated_input", + ), + # Input length tests can be found in ./test_bls12_variable_length_input_contracts.py + ], +) +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +def test_invalid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Negative tests for the BLS12_G2MSM precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "call_opcode", + [ + Op.STATICCALL, + Op.DELEGATECALL, + Op.CALLCODE, + ], +) +@pytest.mark.parametrize( + "input,expected_output", + [ + pytest.param( + Spec.INF_G2 + Scalar(0), + Spec.INF_G2, + id="inf_times_zero", + ), + ], +) +def test_call_types( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G2MSM precompile using different call types. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) diff --git a/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g2mul.py b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g2mul.py new file mode 100644 index 0000000000..118a4449fe --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_g2mul.py @@ -0,0 +1,263 @@ +""" +abstract: Tests BLS12_G2MUL precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) + Tests BLS12_G2MUL precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537). +""" # noqa: E501 + +import pytest + +from ethereum_test_tools import Environment +from ethereum_test_tools import Opcodes as Op +from ethereum_test_tools import StateTestFiller, Transaction + +from .helpers import vectors_from_file +from .spec import PointG2, Scalar, Spec, ref_spec_2537 + +REFERENCE_SPEC_GIT_PATH = ref_spec_2537.git_path +REFERENCE_SPEC_VERSION = ref_spec_2537.version + +pytestmark = [ + pytest.mark.valid_from("Prague"), + pytest.mark.parametrize("precompile_address", [Spec.G2MUL], ids=[""]), +] + + +@pytest.mark.parametrize( + "input,expected_output", + vectors_from_file("mul_G2_bls.json") + + [ + pytest.param( + Spec.INF_G2 + Scalar(0), + Spec.INF_G2, + id="bls_g2mul_(0*inf=inf)", + ), + pytest.param( + Spec.INF_G2 + Scalar(2**256 - 1), + Spec.INF_G2, + id="bls_g2mul_(2**256-1*inf=inf)", + ), + pytest.param( + Spec.P2 + Scalar(2**256 - 1), + PointG2( + ( + 0x2663E1C3431E174CA80E5A84489569462E13B52DA27E7720AF5567941603475F1F9BC0102E13B92A0A21D96B94E9B22, # noqa: E501 + 0x6A80D056486365020A6B53E2680B2D72D8A93561FC2F72B960936BB16F509C1A39C4E4174A7C9219E3D7EF130317C05, # noqa: E501 + ), + ( + 0xC49EAD39E9EB7E36E8BC25824299661D5B6D0E200BBC527ECCB946134726BF5DBD861E8E6EC946260B82ED26AFE15FB, # noqa: E501 + 0x5397DAD1357CF8333189821B737172B18099ECF7EE8BDB4B3F05EBCCDF40E1782A6C71436D5ACE0843D7F361CBC6DB2, # noqa: E501 + ), + ), + id="bls_g2mul_(2**256-1*P2)", + ), + pytest.param( + Spec.P2 + Scalar(Spec.Q - 1), + -Spec.P2, # negated P2 + id="bls_g2mul_(q-1*P2)", + ), + pytest.param( + Spec.P2 + Scalar(Spec.Q), + Spec.INF_G2, + id="bls_g2mul_(q*P2)", + ), + pytest.param( + Spec.G2 + Scalar(Spec.Q), + Spec.INF_G2, + id="bls_g2mul_(q*G2)", + ), + pytest.param( + Spec.P2 + Scalar(Spec.Q + 1), + Spec.P2, + id="bls_g2mul_(q+1*P2)", + ), + pytest.param( + Spec.P2 + Scalar(2 * Spec.Q), + Spec.INF_G2, + id="bls_g2mul_(2q*P2)", + ), + pytest.param( + Spec.P2 + Scalar((2**256 // Spec.Q) * Spec.Q), + Spec.INF_G2, + id="bls_g2mul_(Nq*P2)", + ), + ], +) +def test_valid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G2MUL precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input", + vectors_from_file("fail-mul_G2_bls.json") + + [ + pytest.param( + PointG2((1, 0), (0, 0)) + Scalar(0), + id="invalid_point_a_1", + ), + pytest.param( + PointG2((0, 1), (0, 0)) + Scalar(0), + id="invalid_point_a_2", + ), + pytest.param( + PointG2((0, 0), (1, 0)) + Scalar(0), + id="invalid_point_a_3", + ), + pytest.param( + PointG2((0, 0), (0, 1)) + Scalar(0), + id="invalid_point_a_4", + ), + pytest.param( + PointG2((Spec.P, 0), (0, 0)) + Scalar(0), + id="x_1_equal_to_p", + ), + pytest.param( + PointG2((0, Spec.P), (0, 0)) + Scalar(0), + id="x_2_equal_to_p", + ), + pytest.param( + PointG2((0, 0), (Spec.P, 0)) + Scalar(0), + id="y_1_equal_to_p", + ), + pytest.param( + PointG2((0, 0), (0, Spec.P)) + Scalar(0), + id="y_2_equal_to_p", + ), + pytest.param( + b"\x80" + bytes(Spec.INF_G2)[1:] + Scalar(0), + id="invalid_encoding", + ), + pytest.param( + (Spec.INF_G2 + Scalar(0))[:-1], + id="input_too_short", + ), + pytest.param( + b"\x00" + (Spec.INF_G2 + Scalar(0)), + id="input_too_long", + ), + pytest.param( + b"", + id="zero_length_input", + ), + pytest.param( + Spec.P2_NOT_IN_SUBGROUP + Scalar(1), + id="bls_g2mul_not_in_subgroup", + ), + pytest.param( + Spec.P2_NOT_IN_SUBGROUP + Scalar(2), + id="bls_g2mul_not_in_subgroup_times_2", + ), + pytest.param( + Spec.P2_NOT_IN_SUBGROUP + Scalar(Spec.Q), + id="bls_g2mul_not_in_subgroup_times_q", + ), + pytest.param( + Spec.G1 + Spec.G1, + id="bls_g1_add_input_invalid_length", + ), + pytest.param( + Spec.G2 + Spec.G2, + id="bls_g2_add_input_invalid_length", + ), + pytest.param( + Spec.G2, + id="bls_g2_truncated_input", + ), + ], +) +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +def test_invalid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Negative tests for the BLS12_G2MUL precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input,expected_output,precompile_gas_modifier", + [ + pytest.param( + Spec.INF_G2 + Scalar(0), + Spec.INF_G2, + 1, + id="extra_gas", + ), + pytest.param( + Spec.INF_G2 + Scalar(0), + Spec.INVALID, + -1, + id="insufficient_gas", + ), + ], +) +def test_gas( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G1MUL precompile gas requirements. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "call_opcode", + [ + Op.STATICCALL, + Op.DELEGATECALL, + Op.CALLCODE, + ], +) +@pytest.mark.parametrize( + "input,expected_output", + [ + pytest.param( + Spec.INF_G2 + Scalar(0), + Spec.INF_G2, + id="bls_g2mul_(0*inf=inf)", + ), + ], +) +def test_call_types( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G2MUL using different call types. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) diff --git a/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_map_fp2_to_g2.py b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_map_fp2_to_g2.py new file mode 100644 index 0000000000..385f3ad38f --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_map_fp2_to_g2.py @@ -0,0 +1,177 @@ +""" +abstract: Tests BLS12_MAP_FP2_TO_G2 precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) + Tests BLS12_MAP_FP2_TO_G2 precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537). +""" # noqa: E501 + + +import pytest + +from ethereum_test_tools import Environment +from ethereum_test_tools import Opcodes as Op +from ethereum_test_tools import StateTestFiller, Transaction + +from .helpers import vectors_from_file +from .spec import FP2, PointG2, Spec, ref_spec_2537 + +REFERENCE_SPEC_GIT_PATH = ref_spec_2537.git_path +REFERENCE_SPEC_VERSION = ref_spec_2537.version + +pytestmark = [ + pytest.mark.valid_from("Prague"), + pytest.mark.parametrize("precompile_address", [Spec.MAP_FP2_TO_G2], ids=[""]), +] + +G2_POINT_ZERO_FP = PointG2( + ( + 0x18320896EC9EEF9D5E619848DC29CE266F413D02DD31D9B9D44EC0C79CD61F18B075DDBA6D7BD20B7FF27A4B324BFCE, # noqa: E501 + 0xA67D12118B5A35BB02D2E86B3EBFA7E23410DB93DE39FB06D7025FA95E96FFA428A7A27C3AE4DD4B40BD251AC658892, # noqa: E501 + ), + ( + 0x260E03644D1A2C321256B3246BAD2B895CAD13890CBE6F85DF55106A0D334604FB143C7A042D878006271865BC35941, # noqa: E501 + 0x4C69777A43F0BDA07679D5805E63F18CF4E0E7C6112AC7F70266D199B4F76AE27C6269A3CEEBDAE30806E9A76AADF5C, # noqa: E501 + ), +) + + +@pytest.mark.parametrize( + "input,expected_output", + vectors_from_file("map_fp2_to_G2_bls.json") + + [ + pytest.param( + FP2((0, 0)), + G2_POINT_ZERO_FP, + id="fp_0", + ), + pytest.param( + FP2((Spec.P - 1, Spec.P - 1)), + PointG2( + ( + 0x9BF1B857D8C15F317F649ACCFA7023EF21CFC03059936B83B487DB476FF9D2FE64C6147140A5F0A436B875F51FFDF07, # noqa: E501 + 0xBB10E09BDF236CB2951BD7BCC044E1B9A6BB5FD4B2019DCC20FFDE851D52D4F0D1A32382AF9D7DA2C5BA27E0F1C69E6, # noqa: E501 + ), + ( + 0xDD416A927AB1C15490AB753C973FD377387B12EFCBE6BED2BF768B9DC95A0CA04D1A8F0F30DBC078A2350A1F823CFD3, # noqa: E501 + 0x171565CE4FCD047B35EA6BCEE4EF6FDBFEC8CC73B7ACDB3A1EC97A776E13ACDFEFFC21ED6648E3F0EEC53DDB6C20FB61, # noqa: E501 + ), + ), + id="fp_p_minus_1", + ), + ], +) +def test_valid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_MAP_FP2_TO_G2 precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input", + vectors_from_file("fail-map_fp2_to_G2_bls.json") + + [ + pytest.param(b"\x80" + bytes(FP2((0, 0)))[1:], id="invalid_encoding"), + pytest.param(bytes(FP2((0, 0)))[1:], id="input_too_short"), + pytest.param(b"\x00" + FP2((0, 0)), id="input_too_long"), + pytest.param(b"", id="zero_length_input"), + pytest.param(FP2((Spec.P, 0)), id="fq_eq_q"), + pytest.param(FP2((0, Spec.P)), id="fq_eq_q_2"), + pytest.param(FP2((2**512 - 1, 0)), id="fq_eq_2_512_minus_1"), + pytest.param(FP2((0, 2**512 - 1)), id="fq_eq_2_512_minus_1_2"), + pytest.param(Spec.G2, id="g2_input"), + ], +) +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +def test_invalid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Negative tests for the BLS12_MAP_FP_TO_G2 precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input,expected_output,precompile_gas_modifier", + [ + pytest.param( + FP2((0, 0)), + G2_POINT_ZERO_FP, + 1, + id="extra_gas", + ), + pytest.param( + FP2((0, 0)), + Spec.INVALID, + -1, + id="insufficient_gas", + ), + ], +) +def test_gas( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_MAP_FP_TO_G2 precompile gas requirements. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "call_opcode", + [ + Op.STATICCALL, + Op.DELEGATECALL, + Op.CALLCODE, + ], +) +@pytest.mark.parametrize( + "input,expected_output", + [ + pytest.param( + FP2((0, 0)), + G2_POINT_ZERO_FP, + id="fp_0", + ), + ], +) +def test_call_types( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_MAP_FP_TO_G2 precompile using different call types. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) diff --git a/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_map_fp_to_g1.py b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_map_fp_to_g1.py new file mode 100644 index 0000000000..71247fcb49 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_map_fp_to_g1.py @@ -0,0 +1,163 @@ +""" +abstract: Tests BLS12_MAP_FP_TO_G1 precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) + Tests BLS12_MAP_FP_TO_G1 precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537). +""" # noqa: E501 + + +import pytest + +from ethereum_test_tools import Environment +from ethereum_test_tools import Opcodes as Op +from ethereum_test_tools import StateTestFiller, Transaction + +from .helpers import vectors_from_file +from .spec import FP, PointG1, Spec, ref_spec_2537 + +REFERENCE_SPEC_GIT_PATH = ref_spec_2537.git_path +REFERENCE_SPEC_VERSION = ref_spec_2537.version + +pytestmark = [ + pytest.mark.valid_from("Prague"), + pytest.mark.parametrize("precompile_address", [Spec.MAP_FP_TO_G1], ids=[""]), +] + +G1_POINT_ZERO_FP = PointG1( + 0x11A9A0372B8F332D5C30DE9AD14E50372A73FA4C45D5F2FA5097F2D6FB93BCAC592F2E1711AC43DB0519870C7D0EA415, # noqa: E501 + 0x92C0F994164A0719F51C24BA3788DE240FF926B55F58C445116E8BC6A47CD63392FD4E8E22BDF9FEAA96EE773222133, # noqa: E501 +) + + +@pytest.mark.parametrize( + "input,expected_output", + vectors_from_file("map_fp_to_G1_bls.json") + + [ + pytest.param( + FP(0), + G1_POINT_ZERO_FP, + id="fp_0", + ), + pytest.param( + FP(Spec.P - 1), + PointG1( + 0x1073311196F8EF19477219CCEE3A48035FF432295AA9419EED45D186027D88B90832E14C4F0E2AA4D15F54D1C3ED0F93, # noqa: E501 + 0x16B3A3B2E3DDDF6A11459DDAF657FDE21C4F10282A56029D9B55AB3CE1F41E1CF39AD27E0EA35823C7D3250E81FF3D66, # noqa: E501 + ), + id="fp_p_minus_1", + ), + ], +) +def test_valid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_MAP_FP_TO_G1 precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input", + vectors_from_file("fail-map_fp_to_G1_bls.json") + + [ + pytest.param(b"\x80" + bytes(FP(0))[1:], id="invalid_encoding"), + pytest.param(bytes(FP(0))[1:], id="input_too_short"), + pytest.param(b"\x00" + FP(0), id="input_too_long"), + pytest.param(b"", id="zero_length_input"), + pytest.param(FP(Spec.P), id="fq_eq_q"), + pytest.param(FP(2**512 - 1), id="fq_eq_2_512_minus_1"), + pytest.param(Spec.G1, id="g1_point_input"), + ], +) +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +def test_invalid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Negative tests for the BLS12_MAP_FP_TO_G1 precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input,expected_output,precompile_gas_modifier", + [ + pytest.param( + FP(0), + G1_POINT_ZERO_FP, + 1, + id="extra_gas", + ), + pytest.param( + FP(0), + Spec.INVALID, + -1, + id="insufficient_gas", + ), + ], +) +def test_gas( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_MAP_FP_TO_G1 precompile gas requirements. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "call_opcode", + [ + Op.STATICCALL, + Op.DELEGATECALL, + Op.CALLCODE, + ], +) +@pytest.mark.parametrize( + "input,expected_output", + [ + pytest.param( + FP(0), + G1_POINT_ZERO_FP, + id="fp_0", + ), + ], +) +def test_call_types( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_MAP_FP_TO_G1 precompile using different call types. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) diff --git a/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_pairing.py b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_pairing.py new file mode 100644 index 0000000000..729f685525 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_pairing.py @@ -0,0 +1,158 @@ +""" +abstract: Tests BLS12_PAIRING precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) + Tests BLS12_PAIRING precompile of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537). +""" # noqa: E501 + +import pytest + +from ethereum_test_tools import Environment +from ethereum_test_tools import Opcodes as Op +from ethereum_test_tools import StateTestFiller, Transaction + +from .helpers import vectors_from_file +from .spec import PointG1, PointG2, Spec, ref_spec_2537 + +REFERENCE_SPEC_GIT_PATH = ref_spec_2537.git_path +REFERENCE_SPEC_VERSION = ref_spec_2537.version + +pytestmark = [ + pytest.mark.valid_from("Prague"), + pytest.mark.parametrize("precompile_address", [Spec.PAIRING], ids=[""]), +] + + +@pytest.mark.parametrize( + "input,expected_output", + vectors_from_file("pairing_check_bls.json") + + [ + pytest.param( + Spec.INF_G1 + Spec.INF_G2, + Spec.PAIRING_TRUE, + id="inf_pair", + ), + pytest.param( + (Spec.INF_G1 + Spec.INF_G2) * 1000, + Spec.PAIRING_TRUE, + id="multi_inf_pair", + ), + ], +) +def test_valid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_PAIRING precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "input", + vectors_from_file("fail-pairing_check_bls.json") + + [ + pytest.param( + PointG1(Spec.P, 0) + Spec.INF_G2, + id="g1_P_g2_inf_1", + ), + pytest.param( + PointG1(0, Spec.P) + Spec.INF_G2, + id="g1_P_g2_inf_2", + ), + pytest.param( + Spec.INF_G1 + PointG2((Spec.P, 0), (0, 0)), + id="g1_inf_g2_P_1", + ), + pytest.param( + Spec.INF_G1 + PointG2((0, Spec.P), (0, 0)), + id="g1_inf_g2_P_2", + ), + pytest.param( + Spec.INF_G1 + PointG2((0, 0), (Spec.P, 0)), + id="g1_inf_g2_P_3", + ), + pytest.param( + Spec.INF_G1 + PointG2((0, 0), (0, Spec.P)), + id="g1_inf_g2_P_4", + ), + pytest.param( + b"\x80" + bytes(Spec.INF_G1)[1:] + Spec.INF_G2, + id="invalid_encoding_g1", + ), + pytest.param( + Spec.INF_G1 + b"\x80" + bytes(Spec.INF_G2)[1:], + id="invalid_encoding_g2", + ), + pytest.param( + (Spec.INF_G1 + Spec.INF_G2) * 1000 + PointG1(Spec.P, 0) + Spec.INF_G2, + id="multi_inf_plus_g1_P_g2_inf_1", + ), + pytest.param( + Spec.P1_NOT_IN_SUBGROUP + Spec.INF_G2, + id="P1_not_in_subgroup", + ), + pytest.param( + Spec.INF_G1 + Spec.P2_NOT_IN_SUBGROUP, + id="P2_not_in_subgroup", + ), + # Input length tests can be found in ./test_bls12_variable_length_input_contracts.py + ], +) +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +def test_invalid( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Negative tests for the BLS12_PAIRING precompile. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "call_opcode", + [ + Op.STATICCALL, + Op.DELEGATECALL, + Op.CALLCODE, + ], +) +@pytest.mark.parametrize( + "input,expected_output", + [ + pytest.param( + Spec.INF_G1 + Spec.INF_G2, + Spec.PAIRING_TRUE, + id="inf_pair", + ), + ], +) +def test_call_types( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_PAIRING precompile using different call types. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) diff --git a/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_precompiles_before_fork.py b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_precompiles_before_fork.py new file mode 100644 index 0000000000..d5ae6bb96d --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_precompiles_before_fork.py @@ -0,0 +1,86 @@ +""" +abstract: Tests BLS12 precompiles of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) + Tests BLS12 precompiles of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) + before the Prague hard fork is active +""" # noqa: E501 + +import pytest + +from ethereum_test_tools import Environment, StateTestFiller, Transaction + +from .spec import FP, FP2, Scalar, Spec, ref_spec_2537 + +REFERENCE_SPEC_GIT_PATH = ref_spec_2537.git_path +REFERENCE_SPEC_VERSION = ref_spec_2537.version + +pytestmark = pytest.mark.valid_at_transition_to("Prague") + + +@pytest.mark.parametrize( + "precompile_address,input", + [ + pytest.param( + Spec.G1ADD, + Spec.INF_G1 + Spec.INF_G1, + id="G1ADD", + ), + pytest.param( + Spec.G1MSM, + Spec.INF_G1 + Scalar(0), + id="G1MSM", + ), + pytest.param( + Spec.G1MUL, + Spec.INF_G1 + Scalar(0), + id="G1MUL", + ), + pytest.param( + Spec.G2ADD, + Spec.INF_G2 + Spec.INF_G2, + id="G2ADD", + ), + pytest.param( + Spec.G2MSM, + Spec.INF_G2 + Scalar(0), + id="G2MSM", + ), + pytest.param( + Spec.G2MUL, + Spec.INF_G2 + Scalar(0), + id="G2MUL", + ), + pytest.param( + Spec.PAIRING, + Spec.INF_G1 + Spec.INF_G2, + id="PAIRING", + ), + pytest.param( + Spec.MAP_FP_TO_G1, + FP(0), + id="MAP_FP_TO_G1", + ), + pytest.param( + Spec.MAP_FP2_TO_G2, + FP2((0, 0)), + id="MAP_FP2_TO_G2", + ), + ], +) +@pytest.mark.parametrize("expected_output,call_succeeds", [pytest.param(b"", True, id="")]) +def test_precompile_before_fork( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test all BLS12 precompiles before the Prague hard fork is active. + + The call must succeed but the output must be empty. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) diff --git a/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py new file mode 100644 index 0000000000..159cb083ca --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/test_bls12_variable_length_input_contracts.py @@ -0,0 +1,466 @@ +""" +abstract: Tests minimum gas and input length for BLS12_G1MSM, BLS12_G2MSM, BLS12_PAIRING precompiles of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537) + Tests minimum gas and input length for BLS12_G1MSM, BLS12_G2MSM, BLS12_PAIRING precompiles of [EIP-2537: Precompile for BLS12-381 curve operations](https://eips.ethereum.org/EIPS/eip-2537). +""" # noqa: E501 + +from typing import List, SupportsBytes + +import pytest + +from ethereum_test_tools import Environment +from ethereum_test_tools import Opcodes as Op +from ethereum_test_tools import StateTestFiller, Storage, Transaction + +from .spec import GAS_CALCULATION_FUNCTION_MAP, PointG1, PointG2, Scalar, Spec, ref_spec_2537 + +REFERENCE_SPEC_GIT_PATH = ref_spec_2537.git_path +REFERENCE_SPEC_VERSION = ref_spec_2537.version + +pytestmark = pytest.mark.valid_from("Prague") + +G1_MSM_K_INPUT_LENGTH = len(PointG1() + Scalar()) +G2_MSM_K_INPUT_LENGTH = len(PointG2() + Scalar()) +G1_GAS = GAS_CALCULATION_FUNCTION_MAP[Spec.G1MSM] +G2_GAS = GAS_CALCULATION_FUNCTION_MAP[Spec.G2MSM] +PAIRING_GAS = GAS_CALCULATION_FUNCTION_MAP[Spec.PAIRING] +PAIRINGS_TO_TEST = 20 + + +@pytest.fixture +def input() -> bytes: + """Input data for the contract.""" + return b"" + + +@pytest.fixture +def call_contract_code( + precompile_address: int, + precompile_gas_list: List[int], + precompile_data_length_list: List[int], + expected_output: bytes | SupportsBytes, + call_opcode: Op, + call_contract_post_storage: Storage, +) -> bytes: + """ + Code of the test contract to validate minimum expected gas in precompiles, as well as + expected input lengths on all variable-length input precompiles. + + Code differs from the one used in all other tests in this file, because it accepts a list of + precompile gas values and a list of precompile data lengths, and for each pair of values, it + calls the precompile with the given gas and data length, data being passed to the precompile + is all zeros. + + Args: + precompile_address: + Address of the precompile to call. + precompile_gas_list: + List of gas values to be used to call the precompile, one for each call. + precompile_data_length_list: + List of data lengths to be used to call the precompile, one for each call. + expected_output: + Expected output of the contract, it is only used to determine if the call is expected + to succeed or fail. + call_opcode: + Type of call used to call the precompile (Op.CALL, Op.CALLCODE, Op.DELEGATECALL, + Op.STATICCALL). + call_contract_post_storage: + Storage of the test contract after the transaction is executed. + """ + expected_output = bytes(expected_output) + + # Depending on the expected output, we can deduce if the call is expected to succeed or fail. + call_succeeds = len(expected_output) > 0 + + assert len(precompile_gas_list) == len(precompile_data_length_list) + + assert call_opcode in [Op.CALL, Op.CALLCODE, Op.DELEGATECALL, Op.STATICCALL] + value = [0] if call_opcode in [Op.CALL, Op.CALLCODE] else [] + + code = b"" + for precompile_gas, precompile_args_length in zip( + precompile_gas_list, precompile_data_length_list + ): + # For each given precompile gas value, and given arguments length, call the precompile + # with the given gas and call data (all zeros) and compare the result. + code += Op.SSTORE( + call_contract_post_storage.store_next(1 if call_succeeds else 0), + Op.CALL( + precompile_gas, + precompile_address, + *value, # Optional, only used for CALL and CALLCODE. + 0, + precompile_args_length, # Memory is empty, so we pass zeros. + 0, + 0, + ), + ) + return code + + +@pytest.mark.parametrize( + "precompile_gas_list,precompile_data_length_list", + [ + pytest.param( + [G1_GAS(i * G1_MSM_K_INPUT_LENGTH) for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + [i * G1_MSM_K_INPUT_LENGTH for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + id="exact_gas_full_discount_table", + ), + pytest.param( + [ + G1_GAS(i * G1_MSM_K_INPUT_LENGTH) + 1 + for i in range(1, len(Spec.MSM_DISCOUNT_TABLE)) + ], + [i * G1_MSM_K_INPUT_LENGTH for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + id="one_extra_gas_full_discount_table", + ), + ], +) +@pytest.mark.parametrize("expected_output", [PointG1()], ids=[""]) +@pytest.mark.parametrize("tx_gas_limit", [100_000_000], ids=[""]) +@pytest.mark.parametrize("precompile_address", [Spec.G1MSM]) +def test_valid_gas_g1msm( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G1MSM discount gas table in full, by expecting the call to succeed for + all possible input lengths because the appropriate amount of gas is provided. + + If any of the calls fail, the test will fail. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "precompile_gas_list,precompile_data_length_list", + [ + pytest.param( + [0], + [G1_MSM_K_INPUT_LENGTH], + id="zero_gas_passed", + ), + pytest.param( + [ + G1_GAS(i * G1_MSM_K_INPUT_LENGTH) - 1 + for i in range(1, len(Spec.MSM_DISCOUNT_TABLE)) + ], + [i * G1_MSM_K_INPUT_LENGTH for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + id="insufficient_gas_full_discount_table", + ), + ], +) +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +@pytest.mark.parametrize("tx_gas_limit", [100_000_000], ids=[""]) +@pytest.mark.parametrize("precompile_address", [Spec.G1MSM]) +def test_invalid_gas_g1msm( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G1MSM discount gas table in full, by expecting the call to fail for + all possible input lengths because the appropriate amount of gas is not provided. + + If any of the calls succeeds, the test will fail. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "precompile_gas_list,precompile_data_length_list", + [ + pytest.param( + [G1_GAS(G1_MSM_K_INPUT_LENGTH)], + [0], + id="zero_length_input", + ), + pytest.param( + [G1_GAS(i * G1_MSM_K_INPUT_LENGTH) for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + [(i * G1_MSM_K_INPUT_LENGTH) - 1 for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + id="input_one_byte_too_short_full_discount_table", + ), + pytest.param( + [G1_GAS(i * G1_MSM_K_INPUT_LENGTH) for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + [(i * G1_MSM_K_INPUT_LENGTH) + 1 for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + id="input_one_byte_too_long_full_discount_table", + ), + ], +) +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +@pytest.mark.parametrize("tx_gas_limit", [100_000_000], ids=[""]) +@pytest.mark.parametrize("precompile_address", [Spec.G1MSM]) +def test_invalid_length_g1msm( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G1MSM discount gas table in full, by expecting the call to fail for + all possible input lengths provided because they are too long or short, or zero length. + + If any of the calls succeeds, the test will fail. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "precompile_gas_list,precompile_data_length_list", + [ + pytest.param( + [G2_GAS(i * G2_MSM_K_INPUT_LENGTH) for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + [i * G2_MSM_K_INPUT_LENGTH for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + id="exact_gas_full_discount_table", + ), + pytest.param( + [ + G2_GAS(i * G2_MSM_K_INPUT_LENGTH) + 1 + for i in range(1, len(Spec.MSM_DISCOUNT_TABLE)) + ], + [i * G2_MSM_K_INPUT_LENGTH for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + id="one_extra_gas_full_discount_table", + ), + ], +) +@pytest.mark.parametrize("expected_output", [PointG2()], ids=[""]) +@pytest.mark.parametrize("tx_gas_limit", [100_000_000], ids=[""]) +@pytest.mark.parametrize("precompile_address", [Spec.G2MSM]) +def test_valid_gas_g2msm( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G2MSM discount gas table in full, by expecting the call to succeed for + all possible input lengths because the appropriate amount of gas is provided. + + If any of the calls fail, the test will fail. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "precompile_gas_list,precompile_data_length_list", + [ + pytest.param( + [0], + [G2_MSM_K_INPUT_LENGTH], + id="zero_gas_passed", + ), + pytest.param( + [ + G2_GAS(i * G2_MSM_K_INPUT_LENGTH) - 1 + for i in range(1, len(Spec.MSM_DISCOUNT_TABLE)) + ], + [i * G2_MSM_K_INPUT_LENGTH for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + id="insufficient_gas_full_discount_table", + ), + ], +) +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +@pytest.mark.parametrize("tx_gas_limit", [100_000_000], ids=[""]) +@pytest.mark.parametrize("precompile_address", [Spec.G2MSM]) +def test_invalid_gas_g2msm( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G2MSM discount gas table in full, by expecting the call to fail for + all possible input lengths because the appropriate amount of gas is not provided. + + If any of the calls succeeds, the test will fail. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "precompile_gas_list,precompile_data_length_list", + [ + pytest.param( + [G2_GAS(G2_MSM_K_INPUT_LENGTH)], + [0], + id="zero_length_input", + ), + pytest.param( + [G2_GAS(i * G2_MSM_K_INPUT_LENGTH) for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + [(i * G2_MSM_K_INPUT_LENGTH) - 1 for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + id="input_one_byte_too_short_full_discount_table", + ), + pytest.param( + [G2_GAS(i * G2_MSM_K_INPUT_LENGTH) for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + [(i * G2_MSM_K_INPUT_LENGTH) + 1 for i in range(1, len(Spec.MSM_DISCOUNT_TABLE))], + id="input_one_byte_too_long_full_discount_table", + ), + ], +) +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +@pytest.mark.parametrize("tx_gas_limit", [100_000_000], ids=[""]) +@pytest.mark.parametrize("precompile_address", [Spec.G2MSM]) +def test_invalid_length_g2msm( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_G2MSM discount gas table in full, by expecting the call to fail for + all possible input lengths provided because they are too long or short, or zero length. + + If any of the calls succeeds, the test will fail. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "precompile_gas_list,precompile_data_length_list", + [ + pytest.param( + [PAIRING_GAS(i * Spec.LEN_PER_PAIR) for i in range(1, PAIRINGS_TO_TEST + 1)], + [i * Spec.LEN_PER_PAIR for i in range(1, PAIRINGS_TO_TEST + 1)], + id="sufficient_gas", + ), + pytest.param( + [PAIRING_GAS(i * Spec.LEN_PER_PAIR) + 1 for i in range(1, PAIRINGS_TO_TEST + 1)], + [i * Spec.LEN_PER_PAIR for i in range(1, PAIRINGS_TO_TEST + 1)], + id="extra_gas", + ), + ], +) +@pytest.mark.parametrize("expected_output", [Spec.PAIRING_TRUE], ids=[""]) +@pytest.mark.parametrize("tx_gas_limit", [100_000_000], ids=[""]) +@pytest.mark.parametrize("precompile_address", [Spec.PAIRING]) +def test_valid_gas_pairing( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_PAIRING precompile, by expecting the call to succeed for all possible input + lengths (up to k == PAIRINGS_TO_TEST). + + If any of the calls fails, the test will fail. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "precompile_gas_list,precompile_data_length_list", + [ + pytest.param( + [0], + [Spec.LEN_PER_PAIR], + id="zero_gas_passed", + ), + pytest.param( + [PAIRING_GAS(i * Spec.LEN_PER_PAIR) - 1 for i in range(1, PAIRINGS_TO_TEST + 1)], + [i * Spec.LEN_PER_PAIR for i in range(1, PAIRINGS_TO_TEST + 1)], + id="insufficient_gas", + ), + ], +) +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +@pytest.mark.parametrize("tx_gas_limit", [100_000_000], ids=[""]) +@pytest.mark.parametrize("precompile_address", [Spec.PAIRING]) +def test_invalid_gas_pairing( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_PAIRING precompile, by expecting the call to fail for all possible input + lengths (up to k == PAIRINGS_TO_TEST) because the appropriate amount of gas is not provided. + + If any of the calls succeeds, the test will fail. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) + + +@pytest.mark.parametrize( + "precompile_gas_list,precompile_data_length_list", + [ + pytest.param( + [PAIRING_GAS(Spec.LEN_PER_PAIR)], + [0], + id="zero_length", + ), + pytest.param( + [PAIRING_GAS(i * Spec.LEN_PER_PAIR) for i in range(1, PAIRINGS_TO_TEST + 1)], + [(i * Spec.LEN_PER_PAIR) - 1 for i in range(1, PAIRINGS_TO_TEST + 1)], + id="input_too_short", + ), + pytest.param( + [PAIRING_GAS(i * Spec.LEN_PER_PAIR) for i in range(1, PAIRINGS_TO_TEST + 1)], + [(i * Spec.LEN_PER_PAIR) + 1 for i in range(1, PAIRINGS_TO_TEST + 1)], + id="input_too_long", + ), + ], +) +@pytest.mark.parametrize("expected_output", [Spec.INVALID], ids=[""]) +@pytest.mark.parametrize("tx_gas_limit", [100_000_000], ids=[""]) +@pytest.mark.parametrize("precompile_address", [Spec.PAIRING]) +def test_invalid_length_pairing( + state_test: StateTestFiller, + pre: dict, + post: dict, + tx: Transaction, +): + """ + Test the BLS12_PAIRING precompile, by expecting the call to fail for all possible input + lengths (up to k == PAIRINGS_TO_TEST) because the incorrect input length was used. + + If any of the calls succeeds, the test will fail. + """ + state_test( + env=Environment(), + pre=pre, + tx=tx, + post=post, + ) diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/add_G1_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/add_G1_bls.json new file mode 100644 index 0000000000..b3112c4c19 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/add_G1_bls.json @@ -0,0 +1,65 @@ +[ + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a21", + "Name": "bls_g1add_g1+p1", + "Expected": "000000000000000000000000000000000a40300ce2dec9888b60690e9a41d3004fda4886854573974fab73b046d3147ba5b7a5bde85279ffede1b45b3918d82d0000000000000000000000000000000006d3d887e9f53b9ec4eb6cedf5607226754b07c01ace7834f57f3e7315faefb739e59018e22c492006190fba4a870025", + "Gas": 500, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1", + "Name": "bls_g1add_p1+g1", + "Expected": "000000000000000000000000000000000a40300ce2dec9888b60690e9a41d3004fda4886854573974fab73b046d3147ba5b7a5bde85279ffede1b45b3918d82d0000000000000000000000000000000006d3d887e9f53b9ec4eb6cedf5607226754b07c01ace7834f57f3e7315faefb739e59018e22c492006190fba4a870025", + "Gas": 500, + "NoBenchmark": false + }, + { + "Input": "000000000000000000000000000000000123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef00000000000000000000000000000000193fb7cedb32b2c3adc06ec11a96bc0d661869316f5e4a577a9f7c179593987beb4fb2ee424dbb2f5dd891e228b46c4a0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1", + "Name": "bls_g1add_g1_wrong_order+g1", + "Expected": "000000000000000000000000000000000abe7ae4ae2b092a5cc1779b1f5605d904fa6ec59b0f084907d1f5e4d2663e117a3810e027210a72186159a21271df3e0000000000000000000000000000000001e1669f00e10205f2e2f1195d65c21022f6a9a6de21f329756309815281a4434b2864d34ebcbc1d7e7cfaaee3feeea2", + "Gas": 500, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g1add_(g1+0=g1)", + "Expected": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1", + "Gas": 500, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g1add_(p1+0=p1)", + "Expected": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a21", + "Gas": 500, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb00000000000000000000000000000000114d1d6855d545a8aa7d76c8cf2e21f267816aef1db507c96655b9d5caac42364e6f38ba0ecb751bad54dcd6b939c2ca", + "Name": "bls_g1add_(g1-g1=0)", + "Expected": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 500, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a2100000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca9426000000000000000000000000000000000195e911162921ba5ed055b496420f197693d36569ec34c63d7c0529a097d49e543070afba4b707e878e53c2b779208a", + "Name": "bls_g1add_(p1-p1=0)", + "Expected": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 500, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1", + "Name": "bls_g1add_(g1+g1=2*g1)", + "Expected": "000000000000000000000000000000000572cbea904d67468808c8eb50a9450c9721db309128012543902d0ac358a62ae28f75bb8f1c7c42c39a8c5529bf0f4e00000000000000000000000000000000166a9d8cabc673a322fda673779d8e3822ba3ecb8670e461f73bb9021d5fd76a4c56d9d4cd16bd1bba86881979749d28", + "Gas": 500, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a2100000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a21", + "Name": "bls_g1add_(p1+p1=2*p1)", + "Expected": "0000000000000000000000000000000015222cddbabdd764c4bee0b3720322a65ff4712c86fc4b1588d0c209210a0884fa9468e855d261c483091b2bf7de6a630000000000000000000000000000000009f9edb99bc3b75d7489735c98b16ab78b9386c5f7a1f76c7e96ac6eb5bbde30dbca31a74ec6e0f0b12229eecea33c39", + "Gas": 500, + "NoBenchmark": false + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/add_G2_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/add_G2_bls.json new file mode 100644 index 0000000000..630ff71789 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/add_G2_bls.json @@ -0,0 +1,65 @@ +[ + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d878451", + "Name": "bls_g2add_g2+p2", + "Expected": "000000000000000000000000000000000b54a8a7b08bd6827ed9a797de216b8c9057b3a9ca93e2f88e7f04f19accc42da90d883632b9ca4dc38d013f71ede4db00000000000000000000000000000000077eba4eecf0bd764dce8ed5f45040dd8f3b3427cb35230509482c14651713282946306247866dfe39a8e33016fcbe520000000000000000000000000000000014e60a76a29ef85cbd69f251b9f29147b67cfe3ed2823d3f9776b3a0efd2731941d47436dc6d2b58d9e65f8438bad073000000000000000000000000000000001586c3c910d95754fef7a732df78e279c3d37431c6a2b77e67a00c7c130a8fcd4d19f159cbeb997a178108fffffcbd20", + "Gas": 800, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d87845100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be", + "Name": "bls_g2add_p2+g2", + "Expected": "000000000000000000000000000000000b54a8a7b08bd6827ed9a797de216b8c9057b3a9ca93e2f88e7f04f19accc42da90d883632b9ca4dc38d013f71ede4db00000000000000000000000000000000077eba4eecf0bd764dce8ed5f45040dd8f3b3427cb35230509482c14651713282946306247866dfe39a8e33016fcbe520000000000000000000000000000000014e60a76a29ef85cbd69f251b9f29147b67cfe3ed2823d3f9776b3a0efd2731941d47436dc6d2b58d9e65f8438bad073000000000000000000000000000000001586c3c910d95754fef7a732df78e279c3d37431c6a2b77e67a00c7c130a8fcd4d19f159cbeb997a178108fffffcbd20", + "Gas": 800, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000197bfd0342bbc8bee2beced2f173e1a87be576379b343e93232d6cef98d84b1d696e5612ff283ce2cfdccb2cfb65fa0c00000000000000000000000000000000184e811f55e6f9d84d77d2f79102fd7ea7422f4759df5bf7f6331d550245e3f1bcf6a30e3b29110d85e0ca16f9f6ae7a000000000000000000000000000000000f10e1eb3c1e53d2ad9cf2d398b2dc22c5842fab0a74b174f691a7e914975da3564d835cd7d2982815b8ac57f507348f000000000000000000000000000000000767d1c453890f1b9110fda82f5815c27281aba3f026ee868e4176a0654feea41a96575e0c4d58a14dbfbcc05b5010b100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be", + "Name": "bls_g2add_g2_wrong_order+g2", + "Expected": "0000000000000000000000000000000011f00077935238fc57086414804303b20fab5880bc29f35ebda22c13dd44e586c8a889fe2ba799082c8458d861ac10cf0000000000000000000000000000000007318be09b19be000fe5df77f6e664a8286887ad8373005d7f7a203fcc458c28004042780146d3e43fa542d921c69512000000000000000000000000000000001287eab085d6f8a29f1f1aedb5ad9e8546963f0b11865e05454d86b9720c281db567682a233631f63a2794432a5596ae0000000000000000000000000000000012ec87cea1bacb75aa97728bcd64b27c7a42dd2319a2e17fe3837a05f85d089c5ebbfb73c1d08b7007e2b59ec9c8e065", + "Gas": 800, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g2add_(g2+0=g2)", + "Expected": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be", + "Gas": 800, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d87845100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g2add_(p2+0=p2)", + "Expected": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d878451", + "Gas": 800, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000d1b3cc2c7027888be51d9ef691d77bcb679afda66c73f17f9ee3837a55024f78c71363275a75d75d86bab79f74782aa0000000000000000000000000000000013fa4d4a0ad8b1ce186ed5061789213d993923066dddaf1040bc3ff59f825c78df74f2d75467e25e0f55f8a00fa030ed", + "Name": "bls_g2add_(g2-g2=0)", + "Expected": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 800, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d87845100000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000a6296409115572426717c73668335a949829d739cff2cb4ab043710d28f8e772f6ef41aac4806c9cb273c490384032d000000000000000000000000000000000cde4e850c721fa94e8890d500e3655b442d5c0dc4fff1b694c6f8dd68f6d8dc1bc3251a37d27e7af96f65a96278265a", + "Name": "bls_g2add_(p2-p2=0)", + "Expected": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 800, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be", + "Name": "bls_g2add_(g2+g2=2*g2)", + "Expected": "000000000000000000000000000000001638533957d540a9d2370f17cc7ed5863bc0b995b8825e0ee1ea1e1e4d00dbae81f14b0bf3611b78c952aacab827a053000000000000000000000000000000000a4edef9c1ed7f729f520e47730a124fd70662a904ba1074728114d1031e1572c6c886f6b57ec72a6178288c47c33577000000000000000000000000000000000468fb440d82b0630aeb8dca2b5256789a66da69bf91009cbfe6bd221e47aa8ae88dece9764bf3bd999d95d71e4c9899000000000000000000000000000000000f6d4552fa65dd2638b361543f887136a43253d9c66c411697003f7a13c308f5422e1aa0a59c8967acdefd8b6e36ccf3", + "Gas": 800, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d87845100000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d878451", + "Name": "bls_g2add_(p2+p2=2*p2)", + "Expected": "000000000000000000000000000000000b76fcbb604082a4f2d19858a7befd6053fa181c5119a612dfec83832537f644e02454f2b70d40985ebb08042d1620d40000000000000000000000000000000019a4a02c0ae51365d964c73be7babb719db1c69e0ddbf9a8a335b5bed3b0a4b070d2d5df01d2da4a3f1e56aae2ec106d000000000000000000000000000000000d18322f821ac72d3ca92f92b000483cf5b7d9e5d06873a44071c4e7e81efd904f210208fe0b9b4824f01c65bc7e62080000000000000000000000000000000004e563d53609a2d1e216aaaee5fbc14ef460160db8d1fdc5e1bd4e8b54cd2f39abf6f925969fa405efb9e700b01c7085", + "Gas": 800, + "NoBenchmark": false + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-add_G1_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-add_G1_bls.json new file mode 100644 index 0000000000..e61e269d21 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-add_G1_bls.json @@ -0,0 +1,32 @@ +[ + { + "Input": "", + "ExpectedError": "invalid input length", + "Name": "bls_g1add_empty_input" + }, + { + "Input": "00000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a21", + "ExpectedError": "invalid input length", + "Name": "bls_g1add_short_input" + }, + { + "Input": "000000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a21", + "ExpectedError": "invalid input length", + "Name": "bls_g1add_large_input" + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb00000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a2100000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a21", + "ExpectedError": "invalid point: not on curve", + "Name": "bls_g1add_point_not_on_curve" + }, + { + "Input": "0000000000000000000000000000000031f2e5916b17be2e71b10b4292f558e727dfd7d48af9cbc5087f0ce00dcca27c8b01e83eaace1aefb539f00adb2271660000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a21", + "ExpectedError": "invalid fp.Element encoding", + "Name": "bls_g2add_invalid_field_element" + }, + { + "Input": "1000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a21", + "ExpectedError": "invalid field element top bytes", + "Name": "bls_g1add_violate_top_bytes" + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-add_G2_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-add_G2_bls.json new file mode 100644 index 0000000000..9d3ab9c18a --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-add_G2_bls.json @@ -0,0 +1,32 @@ +[ + { + "Input": "", + "ExpectedError": "invalid input length", + "Name": "bls_g2add_empty_input" + }, + { + "Input": "000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d878451", + "ExpectedError": "invalid input length", + "Name": "bls_g2add_short_input" + }, + { + "Input": "0000000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d878451", + "ExpectedError": "invalid input length", + "Name": "bls_g2add_long_input" + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb800000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d878451", + "ExpectedError": "invalid point: not on curve", + "Name": "bls_g2add_point_not_on_curve" + }, + { + "Input": "000000000000000000000000000000001c4bb49d2a0ef12b7123acdd7110bd292b5bc659edc54dc21b81de057194c79b2a5803255959bbef8e7f56c8c12168630000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d878451", + "ExpectedError": "invalid fp.Element encoding", + "Name": "bls_g2add_invalid_field_element" + }, + { + "Input": "10000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d878451", + "ExpectedError": "invalid field element top bytes", + "Name": "bls_g2add_violate_top_bytes" + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-map_fp2_to_G2_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-map_fp2_to_G2_bls.json new file mode 100644 index 0000000000..4411fdcc0f --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-map_fp2_to_G2_bls.json @@ -0,0 +1,27 @@ +[ + { + "Input": "", + "ExpectedError": "invalid input length", + "Name": "bls_mapg2_empty_input" + }, + { + "Input": "0000000000000000000000000000000007355d25caf6e7f2f0cb2812ca0e513bd026ed09dda65b177500fa31714e09ea0ded3a078b526bed3307f804d4b93b040000000000000000000000000000000002829ce3c021339ccb5caf3e187f6370e1e2a311dec9b75363117063ab2015603ff52c3d3b98f19c2f65575e99e8b7", + "ExpectedError": "invalid input length", + "Name": "bls_mapg2_short_input" + }, + { + "Input": "000000000000000000000000000000000007355d25caf6e7f2f0cb2812ca0e513bd026ed09dda65b177500fa31714e09ea0ded3a078b526bed3307f804d4b93b040000000000000000000000000000000002829ce3c021339ccb5caf3e187f6370e1e2a311dec9b75363117063ab2015603ff52c3d3b98f19c2f65575e99e8b78c", + "ExpectedError": "invalid input length", + "Name": "bls_mapg2_long_input" + }, + { + "Input": "000000000000000000000000000000000007355d25caf6e7f2f0cb2812ca0e513bd026ed09dda65b177500fa31714e09ea0ded3a078b526bed3307f804d4b93b040000000000000000000000000000000002829ce3c021339ccb5caf3e187f6370e1e2a311dec9b75363117063ab2015603ff52c3d3b98f19c2f65575e99e8b7", + "ExpectedError": "invalid field element top bytes", + "Name": "bls_mapg2_top_bytes" + }, + { + "Input": "0000000000000000000000000000000021366f100476ce8d3be6cfc90d59fe13349e388ed12b6dd6dc31ccd267ff000e2c993a063ca66beced06f804d4b8e5af0000000000000000000000000000000002829ce3c021339ccb5caf3e187f6370e1e2a311dec9b75363117063ab2015603ff52c3d3b98f19c2f65575e99e8b78c", + "ExpectedError": "invalid fp.Element encoding", + "Name": "bls_mapg2_invalid_fq_element" + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-map_fp_to_G1_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-map_fp_to_G1_bls.json new file mode 100644 index 0000000000..2f66856931 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-map_fp_to_G1_bls.json @@ -0,0 +1,27 @@ +[ + { + "Input": "", + "ExpectedError": "invalid input length", + "Name": "bls_mapg1_empty_input" + }, + { + "Input": "00000000000000000000000000000000156c8a6a2c184569d69a76be144b5cdc5141d2d2ca4fe341f011e25e3969c55ad9e9b9ce2eb833c81a908e5fa4ac5f", + "ExpectedError": "invalid input length", + "Name": "bls_mapg1_short_input" + }, + { + "Input": "0000000000000000000000000000000000156c8a6a2c184569d69a76be144b5cdc5141d2d2ca4fe341f011e25e3969c55ad9e9b9ce2eb833c81a908e5fa4ac5f03", + "ExpectedError": "invalid input length", + "Name": "bls_mapg1_large_input" + }, + { + "Input": "1000000000000000000000000000000000156c8a6a2c184569d69a76be144b5cdc5141d2d2ca4fe341f011e25e3969c55ad9e9b9ce2eb833c81a908e5fa4ac5f", + "ExpectedError": "invalid field element top bytes", + "Name": "bls_mapg1_top_bytes" + }, + { + "Input": "000000000000000000000000000000002f6d9c5465982c0421b61e74579709b3b5b91e57bdd4f6015742b4ff301abb7ef895b9cce00c33c7d48f8e5fa4ac09ae", + "ExpectedError": "invalid fp.Element encoding", + "Name": "bls_invalid_fq_element" + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-mul_G1_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-mul_G1_bls.json new file mode 100644 index 0000000000..5ae8e3b536 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-mul_G1_bls.json @@ -0,0 +1,37 @@ +[ + { + "Input": "", + "ExpectedError": "invalid input length", + "Name": "bls_g1mul_empty_input" + }, + { + "Input": "00000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid input length", + "Name": "bls_g1mul_short_input" + }, + { + "Input": "000000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid input length", + "Name": "bls_g1mul_large_input" + }, + { + "Input": "0000000000000000000000000000000031f2e5916b17be2e71b10b4292f558e727dfd7d48af9cbc5087f0ce00dcca27c8b01e83eaace1aefb539f00adb2271660000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid fp.Element encoding", + "Name": "bls_g1mul_invalid_field_element" + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb00000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid point: not on curve", + "Name": "bls_g1mul_point_not_on_curve" + }, + { + "Input": "1000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid field element top bytes", + "Name": "bls_g1mul_violate_top_bytes" + }, + { + "Input": "000000000000000000000000000000000123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef00000000000000000000000000000000193fb7cedb32b2c3adc06ec11a96bc0d661869316f5e4a577a9f7c179593987beb4fb2ee424dbb2f5dd891e228b46c4a0000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "g1 point is not on correct subgroup", + "Name": "bls_g1mul_g1_not_in_correct_subgroup" + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-mul_G2_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-mul_G2_bls.json new file mode 100644 index 0000000000..5b4fa8a1f6 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-mul_G2_bls.json @@ -0,0 +1,37 @@ +[ + { + "Input": "", + "ExpectedError": "invalid input length", + "Name": "bls_g2mul_empty_input" + }, + { + "Input": "000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid input length", + "Name": "bls_g2mul_short_input" + }, + { + "Input": "0000000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid input length", + "Name": "bls_g2mul_large_input" + }, + { + "Input": "000000000000000000000000000000001c4bb49d2a0ef12b7123acdd7110bd292b5bc659edc54dc21b81de057194c79b2a5803255959bbef8e7f56c8c12168630000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid fp.Element encoding", + "Name": "bls_g2mul_invalid_field_element" + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb800000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid point: not on curve", + "Name": "bls_g2mul_point_not_on_curve" + }, + { + "Input": "10000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid field element top bytes", + "Name": "bls_g2mul_violate_top_bytes" + }, + { + "Input": "00000000000000000000000000000000197bfd0342bbc8bee2beced2f173e1a87be576379b343e93232d6cef98d84b1d696e5612ff283ce2cfdccb2cfb65fa0c00000000000000000000000000000000184e811f55e6f9d84d77d2f79102fd7ea7422f4759df5bf7f6331d550245e3f1bcf6a30e3b29110d85e0ca16f9f6ae7a000000000000000000000000000000000f10e1eb3c1e53d2ad9cf2d398b2dc22c5842fab0a74b174f691a7e914975da3564d835cd7d2982815b8ac57f507348f000000000000000000000000000000000767d1c453890f1b9110fda82f5815c27281aba3f026ee868e4176a0654feea41a96575e0c4d58a14dbfbcc05b5010b10000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "g2 point is not on correct subgroup", + "Name": "bls_g2mul_g2_not_in_correct_subgroup" + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-multiexp_G1_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-multiexp_G1_bls.json new file mode 100644 index 0000000000..976f28c480 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-multiexp_G1_bls.json @@ -0,0 +1,37 @@ +[ + { + "Input": "", + "ExpectedError": "invalid input length", + "Name": "bls_g1multiexp_empty_input" + }, + { + "Input": "00000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid input length", + "Name": "bls_g1multiexp_short_input" + }, + { + "Input": "000000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid input length", + "Name": "bls_g1multiexp_long_input" + }, + { + "Input": "0000000000000000000000000000000031f2e5916b17be2e71b10b4292f558e727dfd7d48af9cbc5087f0ce00dcca27c8b01e83eaace1aefb539f00adb2271660000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid fp.Element encoding", + "Name": "bls_g1multiexp_invalid_field_element" + }, + { + "Input": "1000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid field element top bytes", + "Name": "bls_g1multiexp_violate_top_bytes" + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb00000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a21000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid point: not on curve", + "Name": "bls_g1multiexp_point_not_on_curve" + }, + { + "Input": "000000000000000000000000000000000123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef00000000000000000000000000000000193fb7cedb32b2c3adc06ec11a96bc0d661869316f5e4a577a9f7c179593987beb4fb2ee424dbb2f5dd891e228b46c4a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "g1 point is not on correct subgroup", + "Name": "bls_g1multiexp_g1_not_in_correct_subgroup" + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-multiexp_G2_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-multiexp_G2_bls.json new file mode 100644 index 0000000000..486138985b --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-multiexp_G2_bls.json @@ -0,0 +1,37 @@ +[ + { + "Input": "", + "ExpectedError": "invalid input length", + "Name": "bls_g2multiexp_empty_input" + }, + { + "Input": "000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid input length", + "Name": "bls_g2multiexp_short_input" + }, + { + "Input": "0000000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid input length", + "Name": "bls_g2multiexp_long_input" + }, + { + "Input": "10000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid field element top bytes", + "Name": "bls_g2multiexp_violate_top_bytes" + }, + { + "Input": "000000000000000000000000000000001c4bb49d2a0ef12b7123acdd7110bd292b5bc659edc54dc21b81de057194c79b2a5803255959bbef8e7f56c8c12168630000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid fp.Element encoding", + "Name": "bls_g2multiexp_invalid_field_element" + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb800000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "invalid point: not on curve", + "Name": "bls_g2multiexp_point_not_on_curve" + }, + { + "Input": "00000000000000000000000000000000197bfd0342bbc8bee2beced2f173e1a87be576379b343e93232d6cef98d84b1d696e5612ff283ce2cfdccb2cfb65fa0c00000000000000000000000000000000184e811f55e6f9d84d77d2f79102fd7ea7422f4759df5bf7f6331d550245e3f1bcf6a30e3b29110d85e0ca16f9f6ae7a000000000000000000000000000000000f10e1eb3c1e53d2ad9cf2d398b2dc22c5842fab0a74b174f691a7e914975da3564d835cd7d2982815b8ac57f507348f000000000000000000000000000000000767d1c453890f1b9110fda82f5815c27281aba3f026ee868e4176a0654feea41a96575e0c4d58a14dbfbcc05b5010b1000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000002", + "ExpectedError": "g2 point is not on correct subgroup", + "Name": "bls_pairing_g2_not_in_correct_subgroup" + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-pairing_check_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-pairing_check_bls.json new file mode 100644 index 0000000000..e14cb8e648 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/fail-pairing_check_bls.json @@ -0,0 +1,47 @@ +[ + { + "Input": "", + "ExpectedError": "invalid input length", + "Name": "bls_pairing_empty_input" + }, + { + "Input": "00000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000d1b3cc2c7027888be51d9ef691d77bcb679afda66c73f17f9ee3837a55024f78c71363275a75d75d86bab79f74782aa0000000000000000000000000000000013fa4d4a0ad8b1ce186ed5061789213d993923066dddaf1040bc3ff59f825c78df74f2d75467e25e0f55f8a00fa030ed", + "ExpectedError": "invalid input length", + "Name": "bls_pairing_missing_data" + }, + { + "Input": "000000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000d1b3cc2c7027888be51d9ef691d77bcb679afda66c73f17f9ee3837a55024f78c71363275a75d75d86bab79f74782aa0000000000000000000000000000000013fa4d4a0ad8b1ce186ed5061789213d993923066dddaf1040bc3ff59f825c78df74f2d75467e25e0f55f8a00fa030ed", + "ExpectedError": "invalid input length", + "Name": "bls_pairing_extra_data" + }, + { + "Input": "1000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000d1b3cc2c7027888be51d9ef691d77bcb679afda66c73f17f9ee3837a55024f78c71363275a75d75d86bab79f74782aa0000000000000000000000000000000013fa4d4a0ad8b1ce186ed5061789213d993923066dddaf1040bc3ff59f825c78df74f2d75467e25e0f55f8a00fa030ed", + "ExpectedError": "invalid field element top bytes", + "Name": "bls_pairing_top_bytes" + }, + { + "Input": "0000000000000000000000000000000031f2e5916b17be2e71b10b4292f558e727dfd7d48af9cbc5087f0ce00dcca27c8b01e83eaace1aefb539f00adb2271660000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000d1b3cc2c7027888be51d9ef691d77bcb679afda66c73f17f9ee3837a55024f78c71363275a75d75d86bab79f74782aa0000000000000000000000000000000013fa4d4a0ad8b1ce186ed5061789213d993923066dddaf1040bc3ff59f825c78df74f2d75467e25e0f55f8a00fa030ed", + "ExpectedError": "invalid fp.Element encoding", + "Name": "bls_pairing_invalid_field_element" + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb00000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a2100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000d1b3cc2c7027888be51d9ef691d77bcb679afda66c73f17f9ee3837a55024f78c71363275a75d75d86bab79f74782aa0000000000000000000000000000000013fa4d4a0ad8b1ce186ed5061789213d993923066dddaf1040bc3ff59f825c78df74f2d75467e25e0f55f8a00fa030ed", + "ExpectedError": "invalid point: not on curve", + "Name": "bls_pairing_g1_not_on_curve" + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb800000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000d1b3cc2c7027888be51d9ef691d77bcb679afda66c73f17f9ee3837a55024f78c71363275a75d75d86bab79f74782aa0000000000000000000000000000000013fa4d4a0ad8b1ce186ed5061789213d993923066dddaf1040bc3ff59f825c78df74f2d75467e25e0f55f8a00fa030ed", + "ExpectedError": "invalid point: not on curve", + "Name": "bls_pairing_g2_not_on_curve" + }, + { + "Input": "000000000000000000000000000000000123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef00000000000000000000000000000000193fb7cedb32b2c3adc06ec11a96bc0d661869316f5e4a577a9f7c179593987beb4fb2ee424dbb2f5dd891e228b46c4a00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000d1b3cc2c7027888be51d9ef691d77bcb679afda66c73f17f9ee3837a55024f78c71363275a75d75d86bab79f74782aa0000000000000000000000000000000013fa4d4a0ad8b1ce186ed5061789213d993923066dddaf1040bc3ff59f825c78df74f2d75467e25e0f55f8a00fa030ed", + "ExpectedError": "g1 point is not on correct subgroup", + "Name": "bls_pairing_g1_not_in_correct_subgroup" + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000197bfd0342bbc8bee2beced2f173e1a87be576379b343e93232d6cef98d84b1d696e5612ff283ce2cfdccb2cfb65fa0c00000000000000000000000000000000184e811f55e6f9d84d77d2f79102fd7ea7422f4759df5bf7f6331d550245e3f1bcf6a30e3b29110d85e0ca16f9f6ae7a000000000000000000000000000000000f10e1eb3c1e53d2ad9cf2d398b2dc22c5842fab0a74b174f691a7e914975da3564d835cd7d2982815b8ac57f507348f000000000000000000000000000000000767d1c453890f1b9110fda82f5815c27281aba3f026ee868e4176a0654feea41a96575e0c4d58a14dbfbcc05b5010b10000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000d1b3cc2c7027888be51d9ef691d77bcb679afda66c73f17f9ee3837a55024f78c71363275a75d75d86bab79f74782aa0000000000000000000000000000000013fa4d4a0ad8b1ce186ed5061789213d993923066dddaf1040bc3ff59f825c78df74f2d75467e25e0f55f8a00fa030ed", + "ExpectedError": "g2 point is not on correct subgroup", + "Name": "bls_pairing_g2_not_in_correct_subgroup" + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/map_fp2_to_G2_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/map_fp2_to_G2_bls.json new file mode 100644 index 0000000000..23c50680ec --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/map_fp2_to_G2_bls.json @@ -0,0 +1,37 @@ +[ + { + "Input": "0000000000000000000000000000000007355d25caf6e7f2f0cb2812ca0e513bd026ed09dda65b177500fa31714e09ea0ded3a078b526bed3307f804d4b93b040000000000000000000000000000000002829ce3c021339ccb5caf3e187f6370e1e2a311dec9b75363117063ab2015603ff52c3d3b98f19c2f65575e99e8b78c", + "Name": "bls_g2map_", + "Expected": "0000000000000000000000000000000000e7f4568a82b4b7dc1f14c6aaa055edf51502319c723c4dc2688c7fe5944c213f510328082396515734b6612c4e7bb700000000000000000000000000000000126b855e9e69b1f691f816e48ac6977664d24d99f8724868a184186469ddfd4617367e94527d4b74fc86413483afb35b000000000000000000000000000000000caead0fd7b6176c01436833c79d305c78be307da5f6af6c133c47311def6ff1e0babf57a0fb5539fce7ee12407b0a42000000000000000000000000000000001498aadcf7ae2b345243e281ae076df6de84455d766ab6fcdaad71fab60abb2e8b980a440043cd305db09d283c895e3d", + "Gas": 75000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000138879a9559e24cecee8697b8b4ad32cced053138ab913b99872772dc753a2967ed50aabc907937aefb2439ba06cc50c000000000000000000000000000000000a1ae7999ea9bab1dcc9ef8887a6cb6e8f1e22566015428d220b7eec90ffa70ad1f624018a9ad11e78d588bd3617f9f2", + "Name": "bls_g2map_616263", + "Expected": "00000000000000000000000000000000108ed59fd9fae381abfd1d6bce2fd2fa220990f0f837fa30e0f27914ed6e1454db0d1ee957b219f61da6ff8be0d6441f000000000000000000000000000000000296238ea82c6d4adb3c838ee3cb2346049c90b96d602d7bb1b469b905c9228be25c627bffee872def773d5b2a2eb57d00000000000000000000000000000000033f90f6057aadacae7963b0a0b379dd46750c1c94a6357c99b65f63b79e321ff50fe3053330911c56b6ceea08fee65600000000000000000000000000000000153606c417e59fb331b7ae6bce4fbf7c5190c33ce9402b5ebe2b70e44fca614f3f1382a3625ed5493843d0b0a652fc3f", + "Gas": 75000, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000018c16fe362b7dbdfa102e42bdfd3e2f4e6191d479437a59db4eb716986bf08ee1f42634db66bde97d6c16bbfd342b3b8000000000000000000000000000000000e37812ce1b146d998d5f92bdd5ada2a31bfd63dfe18311aa91637b5f279dd045763166aa1615e46a50d8d8f475f184e", + "Name": "bls_g2map_6162636465663031", + "Expected": "00000000000000000000000000000000038af300ef34c7759a6caaa4e69363cafeed218a1f207e93b2c70d91a1263d375d6730bd6b6509dcac3ba5b567e85bf3000000000000000000000000000000000da75be60fb6aa0e9e3143e40c42796edf15685cafe0279afd2a67c3dff1c82341f17effd402e4f1af240ea90f4b659b0000000000000000000000000000000019b148cbdf163cf0894f29660d2e7bfb2b68e37d54cc83fd4e6e62c020eaa48709302ef8e746736c0e19342cc1ce3df4000000000000000000000000000000000492f4fed741b073e5a82580f7c663f9b79e036b70ab3e51162359cec4e77c78086fe879b65ca7a47d34374c8315ac5e", + "Gas": 75000, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000008d4a0997b9d52fecf99427abb721f0fa779479963315fe21c6445250de7183e3f63bfdf86570da8929489e421d4ee950000000000000000000000000000000016cb4ccad91ec95aab070f22043916cd6a59c4ca94097f7f510043d48515526dc8eaaea27e586f09151ae613688d5a89", + "Name": "bls_g2map_713132385f717171", + "Expected": "000000000000000000000000000000000c5ae723be00e6c3f0efe184fdc0702b64588fe77dda152ab13099a3bacd3876767fa7bbad6d6fd90b3642e902b208f90000000000000000000000000000000012c8c05c1d5fc7bfa847f4d7d81e294e66b9a78bc9953990c358945e1f042eedafce608b67fdd3ab0cb2e6e263b9b1ad0000000000000000000000000000000004e77ddb3ede41b5ec4396b7421dd916efc68a358a0d7425bddd253547f2fb4830522358491827265dfc5bcc1928a5690000000000000000000000000000000011c624c56dbe154d759d021eec60fab3d8b852395a89de497e48504366feedd4662d023af447d66926a28076813dd646", + "Gas": 75000, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000003f80ce4ff0ca2f576d797a3660e3f65b274285c054feccc3215c879e2c0589d376e83ede13f93c32f05da0f68fd6a1000000000000000000000000000000000006488a837c5413746d868d1efb7232724da10eca410b07d8b505b9363bdccf0a1fc0029bad07d65b15ccfe6dd25e20d", + "Name": "bls_g2map_613531325f616161", + "Expected": "000000000000000000000000000000000ea4e7c33d43e17cc516a72f76437c4bf81d8f4eac69ac355d3bf9b71b8138d55dc10fd458be115afa798b55dac34be1000000000000000000000000000000001565c2f625032d232f13121d3cfb476f45275c303a037faa255f9da62000c2c864ea881e2bcddd111edc4a3c0da3e88d00000000000000000000000000000000043b6f5fe4e52c839148dc66f2b3751e69a0f6ebb3d056d6465d50d4108543ecd956e10fa1640dfd9bc0030cc2558d28000000000000000000000000000000000f8991d2a1ad662e7b6f58ab787947f1fa607fce12dde171bc17903b012091b657e15333e11701edcf5b63ba2a561247", + "Gas": 75000, + "NoBenchmark": false + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/map_fp_to_G1_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/map_fp_to_G1_bls.json new file mode 100644 index 0000000000..80ca454d82 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/map_fp_to_G1_bls.json @@ -0,0 +1,37 @@ +[ + { + "Input": "00000000000000000000000000000000156c8a6a2c184569d69a76be144b5cdc5141d2d2ca4fe341f011e25e3969c55ad9e9b9ce2eb833c81a908e5fa4ac5f03", + "Name": "bls_g1map_", + "Expected": "00000000000000000000000000000000184bb665c37ff561a89ec2122dd343f20e0f4cbcaec84e3c3052ea81d1834e192c426074b02ed3dca4e7676ce4ce48ba0000000000000000000000000000000004407b8d35af4dacc809927071fc0405218f1401a6d15af775810e4e460064bcc9468beeba82fdc751be70476c888bf3", + "Gas": 5500, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000147e1ed29f06e4c5079b9d14fc89d2820d32419b990c1c7bb7dbea2a36a045124b31ffbde7c99329c05c559af1c6cc82", + "Name": "bls_g1map_616263", + "Expected": "00000000000000000000000000000000009769f3ab59bfd551d53a5f846b9984c59b97d6842b20a2c565baa167945e3d026a3755b6345df8ec7e6acb6868ae6d000000000000000000000000000000001532c00cf61aa3d0ce3e5aa20c3b531a2abd2c770a790a2613818303c6b830ffc0ecf6c357af3317b9575c567f11cd2c", + "Gas": 5500, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000004090815ad598a06897dd89bcda860f25837d54e897298ce31e6947378134d3761dc59a572154963e8c954919ecfa82d", + "Name": "bls_g1map_6162636465663031", + "Expected": "000000000000000000000000000000001974dbb8e6b5d20b84df7e625e2fbfecb2cdb5f77d5eae5fb2955e5ce7313cae8364bc2fff520a6c25619739c6bdcb6a0000000000000000000000000000000015f9897e11c6441eaa676de141c8d83c37aab8667173cbe1dfd6de74d11861b961dccebcd9d289ac633455dfcc7013a3", + "Gas": 5500, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000008dccd088ca55b8bfbc96fb50bb25c592faa867a8bb78d4e94a8cc2c92306190244532e91feba2b7fed977e3c3bb5a1f", + "Name": "bls_g1map_713132385f717171", + "Expected": "000000000000000000000000000000000a7a047c4a8397b3446450642c2ac64d7239b61872c9ae7a59707a8f4f950f101e766afe58223b3bff3a19a7f754027c000000000000000000000000000000001383aebba1e4327ccff7cf9912bda0dbc77de048b71ef8c8a81111d71dc33c5e3aa6edee9cf6f5fe525d50cc50b77cc9", + "Gas": 5500, + "NoBenchmark": false + }, + { + "Input": "000000000000000000000000000000000dd824886d2123a96447f6c56e3a3fa992fbfefdba17b6673f9f630ff19e4d326529db37e1c1be43f905bf9202e0278d", + "Name": "bls_g1map_613531325f616161", + "Expected": "000000000000000000000000000000000e7a16a975904f131682edbb03d9560d3e48214c9986bd50417a77108d13dc957500edf96462a3d01e62dc6cd468ef11000000000000000000000000000000000ae89e677711d05c30a48d6d75e76ca9fb70fe06c6dd6ff988683d89ccde29ac7d46c53bb97a59b1901abf1db66052db", + "Gas": 5500, + "NoBenchmark": false + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/mul_G1_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/mul_G1_bls.json new file mode 100644 index 0000000000..72b62ce1e3 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/mul_G1_bls.json @@ -0,0 +1,79 @@ +[ + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000002", + "Name": "bls_g1mul_(g1+g1=2*g1)", + "Expected": "000000000000000000000000000000000572cbea904d67468808c8eb50a9450c9721db309128012543902d0ac358a62ae28f75bb8f1c7c42c39a8c5529bf0f4e00000000000000000000000000000000166a9d8cabc673a322fda673779d8e3822ba3ecb8670e461f73bb9021d5fd76a4c56d9d4cd16bd1bba86881979749d28", + "Gas": 12000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000002", + "Name": "bls_g1mul_(p1+p1=2*p1)", + "Expected": "0000000000000000000000000000000015222cddbabdd764c4bee0b3720322a65ff4712c86fc4b1588d0c209210a0884fa9468e855d261c483091b2bf7de6a630000000000000000000000000000000009f9edb99bc3b75d7489735c98b16ab78b9386c5f7a1f76c7e96ac6eb5bbde30dbca31a74ec6e0f0b12229eecea33c39", + "Gas": 12000, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000001", + "Name": "bls_g1mul_(1*g1=g1)", + "Expected": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1", + "Gas": 12000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000001", + "Name": "bls_g1mul_(1*p1=p1)", + "Expected": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a21", + "Gas": 12000, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g1mul_(0*g1=inf)", + "Expected": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 12000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g1mul_(0*p1=inf)", + "Expected": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 12000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011", + "Name": "bls_g1mul_(x*inf=inf)", + "Expected": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 12000, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e3", + "Name": "bls_g1mul_random*g1", + "Expected": "000000000000000000000000000000000491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a0000000000000000000000000000000017cd7061575d3e8034fcea62adaa1a3bc38dca4b50e4c5c01d04dd78037c9cee914e17944ea99e7ad84278e5d49f36c4", + "Gas": 12000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a21263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e3", + "Name": "bls_g1mul_random*p1", + "Expected": "0000000000000000000000000000000006ee9c9331228753bcb148d0ca8623447701bb0aa6eafb0340aa7f81543923474e00f2a225de65c62dd1d8303270220c0000000000000000000000000000000018dd7be47eb4e80985d7a0d2cc96c8b004250b36a5c3ec0217705d453d3ecc6d0d3d1588722da51b40728baba1e93804", + "Gas": 12000, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e19a2b64cc58f8992cb21237914262ca9ada6cb13dc7b7d3f11c278fe0462040e4", + "Name": "bls_g1mul_random*g1_unnormalized_scalar", + "Expected": "000000000000000000000000000000000491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a0000000000000000000000000000000017cd7061575d3e8034fcea62adaa1a3bc38dca4b50e4c5c01d04dd78037c9cee914e17944ea99e7ad84278e5d49f36c4", + "Gas": 12000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a219a2b64cc58f8992cb21237914262ca9ada6cb13dc7b7d3f11c278fe0462040e4", + "Name": "bls_g1mul_random*p1_unnormalized_scalar", + "Expected": "0000000000000000000000000000000006ee9c9331228753bcb148d0ca8623447701bb0aa6eafb0340aa7f81543923474e00f2a225de65c62dd1d8303270220c0000000000000000000000000000000018dd7be47eb4e80985d7a0d2cc96c8b004250b36a5c3ec0217705d453d3ecc6d0d3d1588722da51b40728baba1e93804", + "Gas": 12000, + "NoBenchmark": false + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/mul_G2_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/mul_G2_bls.json new file mode 100644 index 0000000000..b7ddbcf1ed --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/mul_G2_bls.json @@ -0,0 +1,79 @@ +[ + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000002", + "Name": "bls_g2mul_(g2+g2=2*g2)", + "Expected": "000000000000000000000000000000001638533957d540a9d2370f17cc7ed5863bc0b995b8825e0ee1ea1e1e4d00dbae81f14b0bf3611b78c952aacab827a053000000000000000000000000000000000a4edef9c1ed7f729f520e47730a124fd70662a904ba1074728114d1031e1572c6c886f6b57ec72a6178288c47c33577000000000000000000000000000000000468fb440d82b0630aeb8dca2b5256789a66da69bf91009cbfe6bd221e47aa8ae88dece9764bf3bd999d95d71e4c9899000000000000000000000000000000000f6d4552fa65dd2638b361543f887136a43253d9c66c411697003f7a13c308f5422e1aa0a59c8967acdefd8b6e36ccf3", + "Gas": 45000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000002", + "Name": "bls_g2mul_(p2+p2=2*p2)", + "Expected": "000000000000000000000000000000000b76fcbb604082a4f2d19858a7befd6053fa181c5119a612dfec83832537f644e02454f2b70d40985ebb08042d1620d40000000000000000000000000000000019a4a02c0ae51365d964c73be7babb719db1c69e0ddbf9a8a335b5bed3b0a4b070d2d5df01d2da4a3f1e56aae2ec106d000000000000000000000000000000000d18322f821ac72d3ca92f92b000483cf5b7d9e5d06873a44071c4e7e81efd904f210208fe0b9b4824f01c65bc7e62080000000000000000000000000000000004e563d53609a2d1e216aaaee5fbc14ef460160db8d1fdc5e1bd4e8b54cd2f39abf6f925969fa405efb9e700b01c7085", + "Gas": 45000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000001", + "Name": "bls_g2mul_(1*g2=g2)", + "Expected": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be", + "Gas": 45000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000001", + "Name": "bls_g2mul_(1*p2=p2)", + "Expected": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d878451", + "Gas": 45000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g2mul_(0*g2=inf)", + "Expected": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 45000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g2mul_(0*p2=inf)", + "Expected": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 45000, + "NoBenchmark": false + }, + { + "Input": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011", + "Name": "bls_g2mul_(x*inf=inf)", + "Expected": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 45000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e3", + "Name": "bls_g2mul_random*g2", + "Expected": "0000000000000000000000000000000014856c22d8cdb2967c720e963eedc999e738373b14172f06fc915769d3cc5ab7ae0a1b9c38f48b5585fb09d4bd2733bb000000000000000000000000000000000c400b70f6f8cd35648f5c126cce5417f3be4d8eefbd42ceb4286a14df7e03135313fe5845e3a575faab3e8b949d248800000000000000000000000000000000149a0aacc34beba2beb2f2a19a440166e76e373194714f108e4ab1c3fd331e80f4e73e6b9ea65fe3ec96d7136de81544000000000000000000000000000000000e4622fef26bdb9b1e8ef6591a7cc99f5b73164500c1ee224b6a761e676b8799b09a3fd4fa7e242645cc1a34708285e4", + "Gas": 45000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d878451263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e3", + "Name": "bls_g2mul_random*p2", + "Expected": "00000000000000000000000000000000036074dcbbd0e987531bfe0e45ddfbe09fd015665990ee0c352e8e403fe6af971d8f42141970d9ab14b4dd04874409e600000000000000000000000000000000019705637f24ba2f398f32c3a3e20d6a1cd0fd63e6f8f071cf603a8334f255744927e7bfdfdb18519e019c49ff6e914500000000000000000000000000000000008e74fcff4c4278c9accfb60809ed69bbcbe3d6213ef2304e078d15ec7d6decb4f462b24b8e7cc38cc11b6f2c9e0486000000000000000000000000000000001331d40100f38c1070afd832445881b47cf4d63894666d9907c85ac66604aab5ad329980938cc3c167ccc5b6bc1b8f30", + "Gas": 45000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be9a2b64cc58f8992cb21237914262ca9ada6cb13dc7b7d3f11c278fe0462040e4", + "Name": "bls_g2mul_random*g2_unnormalized_scalar", + "Expected": "0000000000000000000000000000000014856c22d8cdb2967c720e963eedc999e738373b14172f06fc915769d3cc5ab7ae0a1b9c38f48b5585fb09d4bd2733bb000000000000000000000000000000000c400b70f6f8cd35648f5c126cce5417f3be4d8eefbd42ceb4286a14df7e03135313fe5845e3a575faab3e8b949d248800000000000000000000000000000000149a0aacc34beba2beb2f2a19a440166e76e373194714f108e4ab1c3fd331e80f4e73e6b9ea65fe3ec96d7136de81544000000000000000000000000000000000e4622fef26bdb9b1e8ef6591a7cc99f5b73164500c1ee224b6a761e676b8799b09a3fd4fa7e242645cc1a34708285e4", + "Gas": 45000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784519a2b64cc58f8992cb21237914262ca9ada6cb13dc7b7d3f11c278fe0462040e4", + "Name": "bls_g2mul_random*p2_unnormalized_scalar", + "Expected": "00000000000000000000000000000000036074dcbbd0e987531bfe0e45ddfbe09fd015665990ee0c352e8e403fe6af971d8f42141970d9ab14b4dd04874409e600000000000000000000000000000000019705637f24ba2f398f32c3a3e20d6a1cd0fd63e6f8f071cf603a8334f255744927e7bfdfdb18519e019c49ff6e914500000000000000000000000000000000008e74fcff4c4278c9accfb60809ed69bbcbe3d6213ef2304e078d15ec7d6decb4f462b24b8e7cc38cc11b6f2c9e0486000000000000000000000000000000001331d40100f38c1070afd832445881b47cf4d63894666d9907c85ac66604aab5ad329980938cc3c167ccc5b6bc1b8f30", + "Gas": 45000, + "NoBenchmark": false + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/multiexp_G1_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/multiexp_G1_bls.json new file mode 100644 index 0000000000..0a1373782f --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/multiexp_G1_bls.json @@ -0,0 +1,79 @@ +[ + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000002", + "Name": "bls_g1multiexp_(g1+g1=2*g1)", + "Expected": "000000000000000000000000000000000572cbea904d67468808c8eb50a9450c9721db309128012543902d0ac358a62ae28f75bb8f1c7c42c39a8c5529bf0f4e00000000000000000000000000000000166a9d8cabc673a322fda673779d8e3822ba3ecb8670e461f73bb9021d5fd76a4c56d9d4cd16bd1bba86881979749d28", + "Gas": 14400, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000002", + "Name": "bls_g1multiexp_(p1+p1=2*p1)", + "Expected": "0000000000000000000000000000000015222cddbabdd764c4bee0b3720322a65ff4712c86fc4b1588d0c209210a0884fa9468e855d261c483091b2bf7de6a630000000000000000000000000000000009f9edb99bc3b75d7489735c98b16ab78b9386c5f7a1f76c7e96ac6eb5bbde30dbca31a74ec6e0f0b12229eecea33c39", + "Gas": 14400, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000001", + "Name": "bls_g1multiexp_(1*g1=g1)", + "Expected": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1", + "Gas": 14400, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000001", + "Name": "bls_g1multiexp_(1*p1=p1)", + "Expected": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a21", + "Gas": 14400, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g1multiexp_(0*g1=inf)", + "Expected": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 14400, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g1multiexp_(0*p1=inf)", + "Expected": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 14400, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011", + "Name": "bls_g1multiexp_(x*inf=inf)", + "Expected": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 14400, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g1multiexp_(2g1+inf)", + "Expected": "000000000000000000000000000000000572cbea904d67468808c8eb50a9450c9721db309128012543902d0ac358a62ae28f75bb8f1c7c42c39a8c5529bf0f4e00000000000000000000000000000000166a9d8cabc673a322fda673779d8e3822ba3ecb8670e461f73bb9021d5fd76a4c56d9d4cd16bd1bba86881979749d28", + "Gas": 21312, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e10000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g1multiexp_(inf+inf)", + "Expected": "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 21312, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a210000000000000000000000000000000000000000000000000000000000000002", + "Name": "bls_g1multiexp_(2g1+2p1)", + "Expected": "00000000000000000000000000000000148f92dced907361b4782ab542a75281d4b6f71f65c8abf94a5a9082388c64662d30fd6a01ced724feef3e284752038c0000000000000000000000000000000015c3634c3b67bc18e19150e12bfd8a1769306ed010f59be645a0823acb5b38f39e8e0d86e59b6353fdafc59ca971b769", + "Gas": 21312, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e300000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a2147b8192d77bf871b62e87859d653922725724a5c031afeabc60bcef5ff66513800000000000000000000000000000000184bb665c37ff561a89ec2122dd343f20e0f4cbcaec84e3c3052ea81d1834e192c426074b02ed3dca4e7676ce4ce48ba0000000000000000000000000000000004407b8d35af4dacc809927071fc0405218f1401a6d15af775810e4e460064bcc9468beeba82fdc751be70476c888bf3328388aff0d4a5b7dc9205abd374e7e98f3cd9f3418edb4eafda5fb16473d21600000000000000000000000000000000009769f3ab59bfd551d53a5f846b9984c59b97d6842b20a2c565baa167945e3d026a3755b6345df8ec7e6acb6868ae6d000000000000000000000000000000001532c00cf61aa3d0ce3e5aa20c3b531a2abd2c770a790a2613818303c6b830ffc0ecf6c357af3317b9575c567f11cd2c263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e2000000000000000000000000000000001974dbb8e6b5d20b84df7e625e2fbfecb2cdb5f77d5eae5fb2955e5ce7313cae8364bc2fff520a6c25619739c6bdcb6a0000000000000000000000000000000015f9897e11c6441eaa676de141c8d83c37aab8667173cbe1dfd6de74d11861b961dccebcd9d289ac633455dfcc7013a347b8192d77bf871b62e87859d653922725724a5c031afeabc60bcef5ff665131000000000000000000000000000000000a7a047c4a8397b3446450642c2ac64d7239b61872c9ae7a59707a8f4f950f101e766afe58223b3bff3a19a7f754027c000000000000000000000000000000001383aebba1e4327ccff7cf9912bda0dbc77de048b71ef8c8a81111d71dc33c5e3aa6edee9cf6f5fe525d50cc50b77cc9328388aff0d4a5b7dc9205abd374e7e98f3cd9f3418edb4eafda5fb16473d211000000000000000000000000000000000e7a16a975904f131682edbb03d9560d3e48214c9986bd50417a77108d13dc957500edf96462a3d01e62dc6cd468ef11000000000000000000000000000000000ae89e677711d05c30a48d6d75e76ca9fb70fe06c6dd6ff988683d89ccde29ac7d46c53bb97a59b1901abf1db66052db55b53c4669f19f0fc7431929bc0363d7d8fb432435fcde2635fdba334424e9f5", + "Name": "bls_g1multiexp_multiple", + "Expected": "00000000000000000000000000000000053fbdb09b6b5faa08bfe7b7069454247ad4d8bd57e90e2d2ebaa04003dcf110aa83072c07f480ab2107cca2ccff6091000000000000000000000000000000001654537b7c96fe64d13906066679c3d45808cb666452b55d1b909c230cc4b423c3f932c58754b9b762dc49fcc825522c", + "Gas": 42000, + "NoBenchmark": false + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/multiexp_G2_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/multiexp_G2_bls.json new file mode 100644 index 0000000000..bcfa1bbe68 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/multiexp_G2_bls.json @@ -0,0 +1,86 @@ +[ + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000002", + "Name": "bls_g2multiexp_(g2+g2=2*g2)", + "Expected": "000000000000000000000000000000001638533957d540a9d2370f17cc7ed5863bc0b995b8825e0ee1ea1e1e4d00dbae81f14b0bf3611b78c952aacab827a053000000000000000000000000000000000a4edef9c1ed7f729f520e47730a124fd70662a904ba1074728114d1031e1572c6c886f6b57ec72a6178288c47c33577000000000000000000000000000000000468fb440d82b0630aeb8dca2b5256789a66da69bf91009cbfe6bd221e47aa8ae88dece9764bf3bd999d95d71e4c9899000000000000000000000000000000000f6d4552fa65dd2638b361543f887136a43253d9c66c411697003f7a13c308f5422e1aa0a59c8967acdefd8b6e36ccf3", + "Gas": 54000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000002", + "Name": "bls_g2multiexp_(p2+p2=2*p2)", + "Expected": "000000000000000000000000000000000b76fcbb604082a4f2d19858a7befd6053fa181c5119a612dfec83832537f644e02454f2b70d40985ebb08042d1620d40000000000000000000000000000000019a4a02c0ae51365d964c73be7babb719db1c69e0ddbf9a8a335b5bed3b0a4b070d2d5df01d2da4a3f1e56aae2ec106d000000000000000000000000000000000d18322f821ac72d3ca92f92b000483cf5b7d9e5d06873a44071c4e7e81efd904f210208fe0b9b4824f01c65bc7e62080000000000000000000000000000000004e563d53609a2d1e216aaaee5fbc14ef460160db8d1fdc5e1bd4e8b54cd2f39abf6f925969fa405efb9e700b01c7085", + "Gas": 54000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000001", + "Name": "bls_g2multiexp_(1*g2=g2)", + "Expected": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be", + "Gas": 54000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000001", + "Name": "bls_g2multiexp_(1*p2=p2)", + "Expected": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d878451", + "Gas": 54000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g2multiexp_(0*g2=inf)", + "Expected": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 54000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g2multiexp_(0*p2=inf)", + "Expected": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 54000, + "NoBenchmark": false + }, + { + "Input": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011", + "Name": "bls_g2multiexp_(x*inf=inf)", + "Expected": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 54000, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002", + "Name": "bls_g2multiexp_(2g2+inf)", + "Expected": "000000000000000000000000000000001638533957d540a9d2370f17cc7ed5863bc0b995b8825e0ee1ea1e1e4d00dbae81f14b0bf3611b78c952aacab827a053000000000000000000000000000000000a4edef9c1ed7f729f520e47730a124fd70662a904ba1074728114d1031e1572c6c886f6b57ec72a6178288c47c33577000000000000000000000000000000000468fb440d82b0630aeb8dca2b5256789a66da69bf91009cbfe6bd221e47aa8ae88dece9764bf3bd999d95d71e4c9899000000000000000000000000000000000f6d4552fa65dd2638b361543f887136a43253d9c66c411697003f7a13c308f5422e1aa0a59c8967acdefd8b6e36ccf3", + "Gas": 79920, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002", + "Name": "bls_g2multiexp_(2p2+inf)", + "Expected": "000000000000000000000000000000000b76fcbb604082a4f2d19858a7befd6053fa181c5119a612dfec83832537f644e02454f2b70d40985ebb08042d1620d40000000000000000000000000000000019a4a02c0ae51365d964c73be7babb719db1c69e0ddbf9a8a335b5bed3b0a4b070d2d5df01d2da4a3f1e56aae2ec106d000000000000000000000000000000000d18322f821ac72d3ca92f92b000483cf5b7d9e5d06873a44071c4e7e81efd904f210208fe0b9b4824f01c65bc7e62080000000000000000000000000000000004e563d53609a2d1e216aaaee5fbc14ef460160db8d1fdc5e1bd4e8b54cd2f39abf6f925969fa405efb9e700b01c7085", + "Gas": 79920, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d878451000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000000", + "Name": "bls_g1multiexp_(inf+inf)", + "Expected": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "Gas": 79920, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d8784510000000000000000000000000000000000000000000000000000000000000002", + "Name": "bls_g2multiexp_(2g2+2p2)", + "Expected": "00000000000000000000000000000000009cc9ed6635623ba19b340cbc1b0eb05c3a58770623986bb7e041645175b0a38d663d929afb9a949f7524656043bccc000000000000000000000000000000000c0fb19d3f083fd5641d22a861a11979da258003f888c59c33005cb4a2df4df9e5a2868832063ac289dfa3e997f21f8a00000000000000000000000000000000168bf7d87cef37cf1707849e0a6708cb856846f5392d205ae7418dd94d94ef6c8aa5b424af2e99d957567654b9dae1d90000000000000000000000000000000017e0fa3c3b2665d52c26c7d4cea9f35443f4f9007840384163d3aa3c7d4d18b21b65ff4380cf3f3b48e94b5eecb221dd", + "Gas": 79920, + "NoBenchmark": false + }, + { + "Input": "00000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e300000000000000000000000000000000103121a2ceaae586d240843a398967325f8eb5a93e8fea99b62b9f88d8556c80dd726a4b30e84a36eeabaf3592937f2700000000000000000000000000000000086b990f3da2aeac0a36143b7d7c824428215140db1bb859338764cb58458f081d92664f9053b50b3fbd2e4723121b68000000000000000000000000000000000f9e7ba9a86a8f7624aa2b42dcc8772e1af4ae115685e60abc2c9b90242167acef3d0be4050bf935eed7c3b6fc7ba77e000000000000000000000000000000000d22c3652d0dc6f0fc9316e14268477c2049ef772e852108d269d9c38dba1d4802e8dae479818184c08f9a569d87845147b8192d77bf871b62e87859d653922725724a5c031afeabc60bcef5ff66513800000000000000000000000000000000108ed59fd9fae381abfd1d6bce2fd2fa220990f0f837fa30e0f27914ed6e1454db0d1ee957b219f61da6ff8be0d6441f000000000000000000000000000000000296238ea82c6d4adb3c838ee3cb2346049c90b96d602d7bb1b469b905c9228be25c627bffee872def773d5b2a2eb57d00000000000000000000000000000000033f90f6057aadacae7963b0a0b379dd46750c1c94a6357c99b65f63b79e321ff50fe3053330911c56b6ceea08fee65600000000000000000000000000000000153606c417e59fb331b7ae6bce4fbf7c5190c33ce9402b5ebe2b70e44fca614f3f1382a3625ed5493843d0b0a652fc3f328388aff0d4a5b7dc9205abd374e7e98f3cd9f3418edb4eafda5fb16473d21600000000000000000000000000000000038af300ef34c7759a6caaa4e69363cafeed218a1f207e93b2c70d91a1263d375d6730bd6b6509dcac3ba5b567e85bf3000000000000000000000000000000000da75be60fb6aa0e9e3143e40c42796edf15685cafe0279afd2a67c3dff1c82341f17effd402e4f1af240ea90f4b659b0000000000000000000000000000000019b148cbdf163cf0894f29660d2e7bfb2b68e37d54cc83fd4e6e62c020eaa48709302ef8e746736c0e19342cc1ce3df4000000000000000000000000000000000492f4fed741b073e5a82580f7c663f9b79e036b70ab3e51162359cec4e77c78086fe879b65ca7a47d34374c8315ac5e263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e2000000000000000000000000000000000c5ae723be00e6c3f0efe184fdc0702b64588fe77dda152ab13099a3bacd3876767fa7bbad6d6fd90b3642e902b208f90000000000000000000000000000000012c8c05c1d5fc7bfa847f4d7d81e294e66b9a78bc9953990c358945e1f042eedafce608b67fdd3ab0cb2e6e263b9b1ad0000000000000000000000000000000004e77ddb3ede41b5ec4396b7421dd916efc68a358a0d7425bddd253547f2fb4830522358491827265dfc5bcc1928a5690000000000000000000000000000000011c624c56dbe154d759d021eec60fab3d8b852395a89de497e48504366feedd4662d023af447d66926a28076813dd64647b8192d77bf871b62e87859d653922725724a5c031afeabc60bcef5ff665131000000000000000000000000000000000ea4e7c33d43e17cc516a72f76437c4bf81d8f4eac69ac355d3bf9b71b8138d55dc10fd458be115afa798b55dac34be1000000000000000000000000000000001565c2f625032d232f13121d3cfb476f45275c303a037faa255f9da62000c2c864ea881e2bcddd111edc4a3c0da3e88d00000000000000000000000000000000043b6f5fe4e52c839148dc66f2b3751e69a0f6ebb3d056d6465d50d4108543ecd956e10fa1640dfd9bc0030cc2558d28000000000000000000000000000000000f8991d2a1ad662e7b6f58ab787947f1fa607fce12dde171bc17903b012091b657e15333e11701edcf5b63ba2a561247328388aff0d4a5b7dc9205abd374e7e98f3cd9f3418edb4eafda5fb16473d211", + "Name": "bls_g2multiexp_multiple", + "Expected": "0000000000000000000000000000000016cf5fd2c2f1b2e01cc48a6d03e8e6d7f3ad754d6c7d4000f806c18c28d8d559cf529dd159c74946a7713d1906894718000000000000000000000000000000000628d42142df8d620d1f3709ac01f382ba950eaf14c12863885af5838067deec4bb363ffda427fcbdd2b8ec6cc5784ae0000000000000000000000000000000018168dec2441ef462e9a769c782f81acdc7fa49dffebb996764ba9fa96b9200ceb5edd9e96b33c383bd042b4e6af191a000000000000000000000000000000001065aaea2c4aa1d2bee7f1e82a2138ae7016dbbade8383ad912d81eca5fb260086238f95f8cef8f2f491969d4cefa2c3", + "Gas": 147690, + "NoBenchmark": false + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/pairing_check_bls.json b/tests/prague/eip2537_bls_12_381_precompiles/vectors/pairing_check_bls.json new file mode 100644 index 0000000000..48b96ba0c1 --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/pairing_check_bls.json @@ -0,0 +1,44 @@ +[ + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be", + "Name": "bls_pairing_e(G1,0)=e(0,G2)", + "Expected": "0000000000000000000000000000000000000000000000000000000000000001", + "Gas": 151000, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be", + "Name": "bls_pairing_non-degeneracy", + "Expected": "0000000000000000000000000000000000000000000000000000000000000000", + "Gas": 108000, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be00000000000000000000000000000000112b98340eee2777cc3c14163dea3ec97977ac3dc5c70da32e6e87578f44912e902ccef9efe28d4a78b8999dfbca942600000000000000000000000000000000186b28d92356c4dfec4b5201ad099dbdede3781f8998ddf929b4cd7756192185ca7b8f4ef7088f813270ac3d48868a2100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be000000000000000000000000000000000a40300ce2dec9888b60690e9a41d3004fda4886854573974fab73b046d3147ba5b7a5bde85279ffede1b45b3918d82d0000000000000000000000000000000006d3d887e9f53b9ec4eb6cedf5607226754b07c01ace7834f57f3e7315faefb739e59018e22c492006190fba4a87002500000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000d1b3cc2c7027888be51d9ef691d77bcb679afda66c73f17f9ee3837a55024f78c71363275a75d75d86bab79f74782aa0000000000000000000000000000000013fa4d4a0ad8b1ce186ed5061789213d993923066dddaf1040bc3ff59f825c78df74f2d75467e25e0f55f8a00fa030ed", + "Name": "bls_pairing_bilinearity", + "Expected": "0000000000000000000000000000000000000000000000000000000000000001", + "Gas": 194000, + "NoBenchmark": false + }, + { + "Input": "0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000d1b3cc2c7027888be51d9ef691d77bcb679afda66c73f17f9ee3837a55024f78c71363275a75d75d86bab79f74782aa0000000000000000000000000000000013fa4d4a0ad8b1ce186ed5061789213d993923066dddaf1040bc3ff59f825c78df74f2d75467e25e0f55f8a00fa030ed", + "Name": "bls_pairing_e(G1,-G2)=e(-G1,G2)", + "Expected": "0000000000000000000000000000000000000000000000000000000000000001", + "Gas": 151000, + "NoBenchmark": false + }, + { + "Input": "000000000000000000000000000000000491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a0000000000000000000000000000000017cd7061575d3e8034fcea62adaa1a3bc38dca4b50e4c5c01d04dd78037c9cee914e17944ea99e7ad84278e5d49f36c4000000000000000000000000000000000bc2357c6782bbb6a078d9e171fc7a81f7bd8ca73eb485e76317359908bb09bd372fd362a637512a9d48019b383e54890000000000000000000000000000000004b8f49c3bac0247a09487049492b0ed99cf90c56263141daa35f011330d3ced3f3ad78d252c51a3bb42fc7d8f182594000000000000000000000000000000000982d17b17404ac198a0ff5f2dffa56a328d95ec4732d9cca9da420ec7cf716dc63d56d0f5179a8b1ec71fe0328fe88200000000000000000000000000000000147c92cb19e43943bb20c5360a6c4347411eb8ffb3d6f19cc428a8dc0cb3fd1eb3ad02b1c21e21c78f65a7691ee63de90000000000000000000000000000000016cae74dc6523e5273dbd2d9d25c53f1e2c453e6d9ba3f605021cfb514fa0bdf721b05f2200f32591d733e739fabf438000000000000000000000000000000001405df65fb71b738510b3a2fc31c33ef3d884ccc84efb1017341a368bf40727b7ad8cdc8e3fd6b0eb94102488c5cb77000000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000d1b3cc2c7027888be51d9ef691d77bcb679afda66c73f17f9ee3837a55024f78c71363275a75d75d86bab79f74782aa0000000000000000000000000000000013fa4d4a0ad8b1ce186ed5061789213d993923066dddaf1040bc3ff59f825c78df74f2d75467e25e0f55f8a00fa030ed", + "Name": "bls_pairing_e(aG1,bG2)=e(abG1,G2)", + "Expected": "0000000000000000000000000000000000000000000000000000000000000001", + "Gas": 151000, + "NoBenchmark": false + }, + { + "Input": "000000000000000000000000000000000491d1b0ecd9bb917989f0e74f0dea0422eac4a873e5e2644f368dffb9a6e20fd6e10c1b77654d067c0618f6e5a7f79a0000000000000000000000000000000017cd7061575d3e8034fcea62adaa1a3bc38dca4b50e4c5c01d04dd78037c9cee914e17944ea99e7ad84278e5d49f36c4000000000000000000000000000000000bc2357c6782bbb6a078d9e171fc7a81f7bd8ca73eb485e76317359908bb09bd372fd362a637512a9d48019b383e54890000000000000000000000000000000004b8f49c3bac0247a09487049492b0ed99cf90c56263141daa35f011330d3ced3f3ad78d252c51a3bb42fc7d8f182594000000000000000000000000000000000982d17b17404ac198a0ff5f2dffa56a328d95ec4732d9cca9da420ec7cf716dc63d56d0f5179a8b1ec71fe0328fe88200000000000000000000000000000000147c92cb19e43943bb20c5360a6c4347411eb8ffb3d6f19cc428a8dc0cb3fd1eb3ad02b1c21e21c78f65a7691ee63de90000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb00000000000000000000000000000000114d1d6855d545a8aa7d76c8cf2e21f267816aef1db507c96655b9d5caac42364e6f38ba0ecb751bad54dcd6b939c2ca00000000000000000000000000000000166335679f3b3e2617b70c22c48e820e2c6a35149c4f96293035c1494a1ce4591f7a44bce94e9d76def50a71c9e7fa41000000000000000000000000000000000ef11c636091748476331159c8259c064da712ffec033c89299384b4c11b801893026726d992aacdc8e0a28db1a3ab82000000000000000000000000000000000fd8d4944030f480f44ce0d2d4fb67ff6264d30a0f3193cc218b062e5114cf9e4ce847489f7be94b0d4a9fc0c550fdc60000000000000000000000000000000000edba2c166be3d673ea77016163ae5cdf7b3c9bd480e733eb5c08a5f1c798793d339cb503005f5a9e586ea5aabf9695", + "Name": "bls_pairing_e(aG1,bG2)=e(G1,abG2)", + "Expected": "0000000000000000000000000000000000000000000000000000000000000001", + "Gas": 151000, + "NoBenchmark": false + } +] \ No newline at end of file diff --git a/tests/prague/eip2537_bls_12_381_precompiles/vectors/test-vectors.md b/tests/prague/eip2537_bls_12_381_precompiles/vectors/test-vectors.md new file mode 100644 index 0000000000..3b3387225b --- /dev/null +++ b/tests/prague/eip2537_bls_12_381_precompiles/vectors/test-vectors.md @@ -0,0 +1,3 @@ +# Test Vectors for EIP-2537 - Precompile for BLS12-381 curve operations + +These test vectors are derived from [BLS 12-381 tests](https://github.com/ethereum/bls12-381-tests/tree/eip-2537) \ No newline at end of file diff --git a/whitelist.txt b/whitelist.txt index d2b1ada8eb..6a6006df91 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -27,6 +27,7 @@ blockhash blocknum blocktest bls +bls12 blueswen boolean br @@ -128,6 +129,16 @@ formatter fromhex frozenbidict func +fp +fp2 +g1 +g1add +g1mul +g1msm +g2 +g2add +g2mul +g2msm gaslimit gasprice GeneralStateTestsFiller @@ -202,6 +213,7 @@ metaclass mixhash mkdocs mkdocstrings +msm mypy namespace nav @@ -223,6 +235,8 @@ opc oprypin origin ori +P1 +P2 parseable pathlib pdb