From b63ed22588854c0822838ff808027e1169e2e124 Mon Sep 17 00:00:00 2001 From: Dankrad Feist Date: Mon, 19 Sep 2022 20:10:48 +0100 Subject: [PATCH 1/2] Fix signature of compute_aggregated_poly_and_commitment --- specs/eip4844/validator.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/eip4844/validator.md b/specs/eip4844/validator.md index 6c4e893f9..0df13aed4 100644 --- a/specs/eip4844/validator.md +++ b/specs/eip4844/validator.md @@ -117,7 +117,7 @@ def compute_powers(x: BLSFieldElement, n: uint64) -> Sequence[BLSFieldElement]: ```python def compute_aggregated_poly_and_commitment( - blobs: Sequence[BLSFieldElement], + blobs: Sequence[Sequence[BLSFieldElement]], kzg_commitments: Sequence[KZGCommitment]) -> Tuple[Polynomial, KZGCommitment]: """ Return the aggregated polynomial and aggregated KZG commitment. From b35155005bd22682a74bc7e1480feb5d843611be Mon Sep 17 00:00:00 2001 From: Dankrad Feist Date: Mon, 19 Sep 2022 20:16:19 +0100 Subject: [PATCH 2/2] Rename matrix_lincomb to vector_lincomb and lincomb to g1_lincomb --- specs/eip4844/polynomial-commitments.md | 16 ++++++++-------- specs/eip4844/validator.md | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/specs/eip4844/polynomial-commitments.md b/specs/eip4844/polynomial-commitments.md index f66e3eb2e..6ebd3fd3a 100644 --- a/specs/eip4844/polynomial-commitments.md +++ b/specs/eip4844/polynomial-commitments.md @@ -15,8 +15,8 @@ - [BLS12-381 helpers](#bls12-381-helpers) - [`bls_modular_inverse`](#bls_modular_inverse) - [`div`](#div) - - [`lincomb`](#lincomb) - - [`matrix_lincomb`](#matrix_lincomb) + - [`g1_lincomb`](#g1_lincomb) + - [`vector_lincomb`](#vector_lincomb) - [KZG](#kzg) - [`blob_to_kzg_commitment`](#blob_to_kzg_commitment) - [`verify_kzg_proof`](#verify_kzg_proof) @@ -85,10 +85,10 @@ def div(x: BLSFieldElement, y: BLSFieldElement) -> BLSFieldElement: return (int(x) * int(bls_modular_inverse(y))) % BLS_MODULUS ``` -#### `lincomb` +#### `g1_lincomb` ```python -def lincomb(points: Sequence[KZGCommitment], scalars: Sequence[BLSFieldElement]) -> KZGCommitment: +def g1_lincomb(points: Sequence[KZGCommitment], scalars: Sequence[BLSFieldElement]) -> KZGCommitment: """ BLS multiscalar multiplication. This function can be optimized using Pippenger's algorithm and variants. """ @@ -99,10 +99,10 @@ def lincomb(points: Sequence[KZGCommitment], scalars: Sequence[BLSFieldElement]) return KZGCommitment(bls.G1_to_bytes48(result)) ``` -#### `matrix_lincomb` +#### `vector_lincomb` ```python -def matrix_lincomb(vectors: Sequence[Sequence[BLSFieldElement]], +def vector_lincomb(vectors: Sequence[Sequence[BLSFieldElement]], scalars: Sequence[BLSFieldElement]) -> Sequence[BLSFieldElement]: """ Given a list of ``vectors``, interpret it as a 2D matrix and compute the linear combination @@ -123,7 +123,7 @@ KZG core functions. These are also defined in EIP-4844 execution specs. ```python def blob_to_kzg_commitment(blob: Blob) -> KZGCommitment: - return lincomb(KZG_SETUP_LAGRANGE, blob) + return g1_lincomb(KZG_SETUP_LAGRANGE, blob) ``` #### `verify_kzg_proof` @@ -165,7 +165,7 @@ def compute_kzg_proof(polynomial: Sequence[BLSFieldElement], z: BLSFieldElement) # Calculate quotient polynomial by doing point-by-point division quotient_polynomial = [div(a, b) for a, b in zip(polynomial_shifted, denominator_poly)] - return KZGProof(lincomb(KZG_SETUP_LAGRANGE, quotient_polynomial)) + return KZGProof(g1_lincomb(KZG_SETUP_LAGRANGE, quotient_polynomial)) ``` ### Polynomials diff --git a/specs/eip4844/validator.md b/specs/eip4844/validator.md index 0df13aed4..f624c5157 100644 --- a/specs/eip4844/validator.md +++ b/specs/eip4844/validator.md @@ -127,10 +127,10 @@ def compute_aggregated_poly_and_commitment( r_powers = compute_powers(r, len(kzg_commitments)) # Create aggregated polynomial in evaluation form - aggregated_poly = Polynomial(matrix_lincomb(blobs, r_powers)) + aggregated_poly = Polynomial(vector_lincomb(blobs, r_powers)) # Compute commitment to aggregated polynomial - aggregated_poly_commitment = KZGCommitment(lincomb(kzg_commitments, r_powers)) + aggregated_poly_commitment = KZGCommitment(g1_lincomb(kzg_commitments, r_powers)) return aggregated_poly, aggregated_poly_commitment ```