g2_lincomb uses g2_multi_exp

This commit is contained in:
Kevaundray Wedderburn 2024-04-23 13:38:27 +01:00
parent e7e49ec71a
commit 5a74f40442
1 changed files with 4 additions and 3 deletions

View File

@ -133,9 +133,10 @@ def g2_lincomb(points: Sequence[G2Point], scalars: Sequence[BLSFieldElement]) ->
BLS multiscalar multiplication in G2. This function can be optimized using Pippenger's algorithm and variants.
"""
assert len(points) == len(scalars)
result = bls.Z2()
for x, a in zip(points, scalars):
result = bls.add(result, bls.multiply(bls.bytes96_to_G2(x), a))
points_g2 = []
for point in points:
points_g2.append(bls.bytes96_to_G2(point))
result = bls.g2_multi_exp(points_g2, scalars)
return Bytes96(bls.G2_to_bytes96(result))
```