add is_zero check
This commit is contained in:
parent
274d013d5c
commit
d28a0164d2
|
@ -133,9 +133,14 @@ def g2_lincomb(points: Sequence[G2Point], scalars: Sequence[BLSFieldElement]) ->
|
|||
BLS multiscalar multiplication in G2. This can be naively implemented using double-and-add.
|
||||
"""
|
||||
assert len(points) == len(scalars)
|
||||
|
||||
if len(points) == 0:
|
||||
return bls.Z2()
|
||||
|
||||
points_g2 = []
|
||||
for point in points:
|
||||
points_g2.append(bls.bytes96_to_G2(point))
|
||||
|
||||
result = bls.multi_exp(points_g2, scalars)
|
||||
return Bytes96(bls.G2_to_bytes96(result))
|
||||
```
|
||||
|
|
|
@ -277,9 +277,14 @@ def g1_lincomb(points: Sequence[KZGCommitment], scalars: Sequence[BLSFieldElemen
|
|||
BLS multiscalar multiplication in G1. This can be naively implemented using double-and-add.
|
||||
"""
|
||||
assert len(points) == len(scalars)
|
||||
|
||||
if len(points) == 0:
|
||||
return bls.Z1()
|
||||
|
||||
points_g1 = []
|
||||
for point in points:
|
||||
points_g1.append(bls.bytes48_to_G1(point))
|
||||
|
||||
result = bls.multi_exp(points_g1, scalars)
|
||||
return KZGCommitment(bls.G1_to_bytes48(result))
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue