From d4c6a691d0ed5be29acfa5d50d25fed802b7e53d Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Thu, 17 Nov 2022 13:17:37 +0000 Subject: [PATCH] use challenge index to generate linear combination challenges and evaluation challenge --- specs/eip4844/polynomial-commitments.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/specs/eip4844/polynomial-commitments.md b/specs/eip4844/polynomial-commitments.md index c19dbc84d1..20d499165f 100644 --- a/specs/eip4844/polynomial-commitments.md +++ b/specs/eip4844/polynomial-commitments.md @@ -161,7 +161,7 @@ def blob_to_polynomial(blob: Blob) -> Polynomial: ```python def hash_to_bls_field(polys: Sequence[Polynomial], - comms: Sequence[KZGCommitment]) -> BLSFieldElement: + comms: Sequence[KZGCommitment], challenge_index : uint8) -> BLSFieldElement: """ Compute 32-byte hash of serialized polynomials and commitments concatenated. This hash is then converted to a BLS field element, where the result is not uniform over the BLS field. @@ -181,6 +181,10 @@ def hash_to_bls_field(polys: Sequence[Polynomial], for commitment in comms: data += commitment + # Append challenge index last so we can cache the data buffer + # in the case of multiple challenges + data += challenge_index + return bytes_to_bls_field(hash(data)) ``` @@ -350,11 +354,10 @@ def compute_aggregated_poly_and_commitment( # Convert blobs to polynomials polynomials = [blob_to_polynomial(blob) for blob in blobs] - # Generate random linear combination challenges - r = hash_to_bls_field(polynomials, kzg_commitments) - all_r_powers = compute_powers(r, len(kzg_commitments) + 1) - evaluation_challenge = all_r_powers[-1] - r_powers = all_r_powers[:-1] + # Generate random linear combination and evaluation challenges + r = hash_to_bls_field(polynomials, kzg_commitments, 0) + r_powers = compute_powers(r, len(kzg_commitments)) + evaluation_challenge = hash_to_bls_field(polynomials, kzg_commitments, 1) # Create aggregated polynomial in evaluation form aggregated_poly = Polynomial(poly_lincomb(polynomials, r_powers))