Skip to content

Commit eb7cd5e

Browse files
committed
hoist constant
1 parent e368dce commit eb7cd5e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

eth/precompiles/bls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
FP2_SIZE_IN_BYTES = 128
2323
G1_SIZE_IN_BYTES = 128
2424
G2_SIZE_IN_BYTES = 256
25+
# Constant for parsing pairs of points during pairing check
26+
G1_TO_G2_OFFSET = G1_SIZE_IN_BYTES + G2_SIZE_IN_BYTES
2527

2628
G1Point = Tuple[bls12_381.FQ, bls12_381.FQ]
2729
G2Point = Tuple[bls12_381.FQ2, bls12_381.FQ2]
@@ -149,12 +151,10 @@ def g2_multiexp(computation: BaseComputation) -> BaseComputation:
149151

150152
def _pairing(input_data: bytes) -> bool:
151153
field_element = bls12_381.FQ12.one()
152-
g1_to_g2_offset = G1_SIZE_IN_BYTES + G2_SIZE_IN_BYTES
153154
for next_index in range(0, len(input_data), 384):
154155
p = _parse_g1_point(input_data[next_index:next_index + G1_SIZE_IN_BYTES])
155-
156156
q = _parse_g2_point(
157-
input_data[next_index + G1_SIZE_IN_BYTES:next_index + g1_to_g2_offset]
157+
input_data[next_index + G1_SIZE_IN_BYTES:next_index + G1_TO_G2_OFFSET]
158158
)
159159
projective_p = (p[0], p[1], bls12_381.FQ.one())
160160
projective_q = (q[0], q[1], bls12_381.FQ2.one())

0 commit comments

Comments
 (0)