Skip to content

Commit

Permalink
Fix calls
Browse files Browse the repository at this point in the history
  • Loading branch information
danielSanchezQ committed Jan 24, 2025
1 parent 543e054 commit 8b2a708
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions da/encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ def _compute_column_kzg_commitments(self, chunks_matrix: ChunksMatrix) -> List[T

@staticmethod
def _compute_aggregated_column_commitment(
chunks_matrix: ChunksMatrix, column_commitments: Sequence[Commitment]
column_commitments: Sequence[Commitment]
) -> Tuple[Polynomial, Commitment]:
data = bytes(chain.from_iterable(
DAEncoder.hash_commitment_blake2b31(column, commitment)
for column, commitment in zip(chunks_matrix.columns, column_commitments)
DAEncoder.hash_commitment_blake2b31(commitment)
for commitment in column_commitments
))
return kzg.bytes_to_commitment(data, GLOBAL_PARAMETERS)

Expand All @@ -111,7 +111,7 @@ def encode(self, data: bytes) -> EncodedData:
row_proofs = self._compute_rows_proofs(extended_matrix, row_polynomials, row_commitments)
column_polynomials, column_commitments = zip(*self._compute_column_kzg_commitments(extended_matrix))
aggregated_column_polynomial, aggregated_column_commitment = (
self._compute_aggregated_column_commitment(extended_matrix, column_commitments)
self._compute_aggregated_column_commitment(column_commitments)
)
aggregated_column_proofs = self._compute_aggregated_column_proofs(
aggregated_column_polynomial, column_commitments
Expand All @@ -130,4 +130,7 @@ def encode(self, data: bytes) -> EncodedData:

@staticmethod
def hash_commitment_blake2b31(commitment: Commitment) -> bytes:
return blake2b(bytes(commitment), digest_size=31).digest()
return (
# digest size must be 31 bytes as we cannot encode 32 without risking overflowing the BLS_MODULUS
int.from_bytes(blake2b(bytes(commitment), digest_size=31).digest())
).to_bytes(32, byteorder="big") # rewrap into 32 padded bytes for the field elements, EC library dependant
2 changes: 1 addition & 1 deletion da/test_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test_generate_aggregated_column_commitments(self):
def test_generate_aggregated_column_proofs(self):
chunks_matrix = self.encoder._chunkify_data(self.data)
_, column_commitments = zip(*self.encoder._compute_column_kzg_commitments(chunks_matrix))
poly, _ = self.encoder._compute_aggregated_column_commitment(chunks_matrix, column_commitments)
poly, _ = self.encoder._compute_aggregated_column_commitment(column_commitments)
proofs = self.encoder._compute_aggregated_column_proofs(poly, column_commitments)
self.assertEqual(len(proofs), len(column_commitments))

Expand Down

0 comments on commit 8b2a708

Please sign in to comment.