Skip to content

Commit

Permalink
remove MUL pre-compiles from BLS
Browse files Browse the repository at this point in the history
  • Loading branch information
gurukamath committed Dec 20, 2024
1 parent 48215dc commit af33227
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 72 deletions.
16 changes: 6 additions & 10 deletions src/ethereum/prague/vm/precompiled_contracts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@
"BLAKE2F_ADDRESS",
"POINT_EVALUATION_ADDRESS",
"BLS12_G1_ADD_ADDRESS",
"BLS12_G1_MULTIPLY_ADDRESS",
"BLS12_G1_MSM_ADDRESS",
"BLS12_G2_ADD_ADDRESS",
"BLS12_G2_MULTIPLY_ADDRESS",
"BLS12_G2_MSM_ADDRESS",
"BLS12_PAIRING_ADDRESS",
"BLS12_MAP_FP_TO_G1_ADDRESS",
Expand All @@ -48,11 +46,9 @@
BLAKE2F_ADDRESS = hex_to_address("0x09")
POINT_EVALUATION_ADDRESS = hex_to_address("0x0a")
BLS12_G1_ADD_ADDRESS = hex_to_address("0x0b")
BLS12_G1_MULTIPLY_ADDRESS = hex_to_address("0x0c")
BLS12_G1_MSM_ADDRESS = hex_to_address("0x0d")
BLS12_G2_ADD_ADDRESS = hex_to_address("0x0e")
BLS12_G2_MULTIPLY_ADDRESS = hex_to_address("0x0f")
BLS12_G2_MSM_ADDRESS = hex_to_address("0x10")
BLS12_PAIRING_ADDRESS = hex_to_address("0x11")
BLS12_MAP_FP_TO_G1_ADDRESS = hex_to_address("0x12")
BLS12_MAP_FP2_TO_G2_ADDRESS = hex_to_address("0x13")
BLS12_G1_MSM_ADDRESS = hex_to_address("0x0c")
BLS12_G2_ADD_ADDRESS = hex_to_address("0x0d")
BLS12_G2_MSM_ADDRESS = hex_to_address("0x0e")
BLS12_PAIRING_ADDRESS = hex_to_address("0x0f")
BLS12_MAP_FP_TO_G1_ADDRESS = hex_to_address("0x10")
BLS12_MAP_FP2_TO_G2_ADDRESS = hex_to_address("0x11")
Original file line number Diff line number Diff line change
Expand Up @@ -65,34 +65,6 @@ def bls12_g1_add(evm: Evm) -> None:
evm.output = G1_to_bytes(result)


def bls12_g1_multiply(evm: Evm) -> None:
"""
The bls12_381 G1 multiplication precompile.
Parameters
----------
evm :
The current EVM frame.
Raises
------
InvalidParameter
If the input length is invalid.
"""
data = evm.message.data
if len(data) != LENGTH_PER_PAIR:
raise InvalidParameter("Invalid Input Length")

# GAS
charge_gas(evm, Uint(12000))

# OPERATION
p, m = decode_G1_scalar_pair(data)
result = multiply(p, m)

evm.output = G1_to_bytes(result)


def bls12_g1_msm(evm: Evm) -> None:
"""
The bls12_381 G1 multi-scalar multiplication precompile.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,34 +65,6 @@ def bls12_g2_add(evm: Evm) -> None:
evm.output = G2_to_bytes(result)


def bls12_g2_multiply(evm: Evm) -> None:
"""
The bls12_381 G2 multiplication precompile.
Parameters
----------
evm :
The current EVM frame.
Raises
------
InvalidParameter
If the input length is invalid.
"""
data = evm.message.data
if len(data) != LENGTH_PER_PAIR:
raise InvalidParameter("Invalid Input Length")

# GAS
charge_gas(evm, Uint(45000))

# OPERATION
p, m = decode_G2_scalar_pair(data)
result = multiply(p, m)

evm.output = G2_to_bytes(result)


def bls12_g2_msm(evm: Evm) -> None:
"""
The bls12_381 G2 multi-scalar multiplication precompile.
Expand Down
6 changes: 0 additions & 6 deletions src/ethereum/prague/vm/precompiled_contracts/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
BLAKE2F_ADDRESS,
BLS12_G1_ADD_ADDRESS,
BLS12_G1_MSM_ADDRESS,
BLS12_G1_MULTIPLY_ADDRESS,
BLS12_G2_ADD_ADDRESS,
BLS12_G2_MSM_ADDRESS,
BLS12_G2_MULTIPLY_ADDRESS,
BLS12_MAP_FP2_TO_G2_ADDRESS,
BLS12_MAP_FP_TO_G1_ADDRESS,
BLS12_PAIRING_ADDRESS,
Expand All @@ -40,13 +38,11 @@
from .bls12_381.bls12_381_g1 import (
bls12_g1_add,
bls12_g1_msm,
bls12_g1_multiply,
bls12_map_fp_to_g1,
)
from .bls12_381.bls12_381_g2 import (
bls12_g2_add,
bls12_g2_msm,
bls12_g2_multiply,
bls12_map_fp2_to_g2,
)
from .bls12_381.bls12_381_pairing import bls12_pairing
Expand All @@ -69,10 +65,8 @@
BLAKE2F_ADDRESS: blake2f,
POINT_EVALUATION_ADDRESS: point_evaluation,
BLS12_G1_ADD_ADDRESS: bls12_g1_add,
BLS12_G1_MULTIPLY_ADDRESS: bls12_g1_multiply,
BLS12_G1_MSM_ADDRESS: bls12_g1_msm,
BLS12_G2_ADD_ADDRESS: bls12_g2_add,
BLS12_G2_MULTIPLY_ADDRESS: bls12_g2_multiply,
BLS12_G2_MSM_ADDRESS: bls12_g2_msm,
BLS12_PAIRING_ADDRESS: bls12_pairing,
BLS12_MAP_FP_TO_G1_ADDRESS: bls12_map_fp_to_g1,
Expand Down

0 comments on commit af33227

Please sign in to comment.