From 8b380253e2707ab9e996feb380e07916e616a9a7 Mon Sep 17 00:00:00 2001 From: Guruprasad Kamath Date: Fri, 2 Aug 2024 11:51:37 +0200 Subject: [PATCH] post-review update 1 --- .../precompiled_contracts/point_evaluation.py | 2 -- .../precompiled_contracts/bls12_381/__init__.py | 17 ++++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/ethereum/cancun/vm/precompiled_contracts/point_evaluation.py b/src/ethereum/cancun/vm/precompiled_contracts/point_evaluation.py index ccb9340fb2..d4413e883d 100644 --- a/src/ethereum/cancun/vm/precompiled_contracts/point_evaluation.py +++ b/src/ethereum/cancun/vm/precompiled_contracts/point_evaluation.py @@ -18,8 +18,6 @@ verify_kzg_proof, ) -from ethereum.base_types import U256, Bytes - from ...vm import Evm from ...vm.exceptions import KZGProofError from ...vm.gas import GAS_POINT_EVALUATION, charge_gas diff --git a/src/ethereum/prague/vm/precompiled_contracts/bls12_381/__init__.py b/src/ethereum/prague/vm/precompiled_contracts/bls12_381/__init__.py index 616289ee56..fbd317e735 100644 --- a/src/ethereum/prague/vm/precompiled_contracts/bls12_381/__init__.py +++ b/src/ethereum/prague/vm/precompiled_contracts/bls12_381/__init__.py @@ -32,7 +32,6 @@ from ...exceptions import InvalidParameter P = FQ.field_modulus -P2 = FQ2.field_modulus K_DISCOUNT = { 1: 1200, @@ -265,21 +264,21 @@ def decode_G1_scalar_pair(data: Bytes) -> Tuple[Point2D, int]: def bytes_to_FQ( data: Bytes, optimized: bool = False -) -> Union[FQ2, OPTIMIZED_FQ2]: +) -> Union[FQ, OPTIMIZED_FQ]: """ - Decode 64 bytes to a FQ2 element. + Decode 64 bytes to a FQ element. Parameters ---------- data : The bytes data to decode. optimized : - Whether to use the optimized FQ2 implementation. + Whether to use the optimized FQ implementation. Returns ------- - fq : FQ - The FQ2 element. + fq : Union[FQ, OPTIMIZED_FQ] + The FQ element. Raises ------ @@ -313,7 +312,7 @@ def bytes_to_FQ2( Returns ------- - fq2 : FQ2 + fq2 : Union[FQ2, OPTIMIZED_FQ2] The FQ2 element. Raises @@ -325,9 +324,9 @@ def bytes_to_FQ2( c_0 = int.from_bytes(data[:64], "big") c_1 = int.from_bytes(data[64:], "big") - if c_0 >= P2: + if c_0 >= P: raise InvalidParameter("Invalid field element") - if c_1 >= P2: + if c_1 >= P: raise InvalidParameter("Invalid field element") if optimized: