From d28a0164d207a6e02794aa0138feb1ec830abed8 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Tue, 23 Apr 2024 14:55:37 +0100 Subject: [PATCH] add is_zero check --- specs/_features/eip7594/polynomial-commitments-sampling.md | 5 +++++ specs/deneb/polynomial-commitments.md | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/specs/_features/eip7594/polynomial-commitments-sampling.md b/specs/_features/eip7594/polynomial-commitments-sampling.md index 8dceb3ebe..b93a694c5 100644 --- a/specs/_features/eip7594/polynomial-commitments-sampling.md +++ b/specs/_features/eip7594/polynomial-commitments-sampling.md @@ -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)) ``` diff --git a/specs/deneb/polynomial-commitments.md b/specs/deneb/polynomial-commitments.md index 26db0df93..4009aab64 100644 --- a/specs/deneb/polynomial-commitments.md +++ b/specs/deneb/polynomial-commitments.md @@ -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)) ```