mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-07 15:43:07 +00:00
Fix calls
This commit is contained in:
parent
96f661f591
commit
5ecbb60e9f
@ -86,11 +86,11 @@ class DAEncoder:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _compute_aggregated_column_commitment(
|
def _compute_aggregated_column_commitment(
|
||||||
chunks_matrix: ChunksMatrix, column_commitments: Sequence[Commitment]
|
column_commitments: Sequence[Commitment]
|
||||||
) -> Tuple[Polynomial, Commitment]:
|
) -> Tuple[Polynomial, Commitment]:
|
||||||
data = bytes(chain.from_iterable(
|
data = bytes(chain.from_iterable(
|
||||||
DAEncoder.hash_commitment_blake2b31(column, commitment)
|
DAEncoder.hash_commitment_blake2b31(commitment)
|
||||||
for column, commitment in zip(chunks_matrix.columns, column_commitments)
|
for commitment in column_commitments
|
||||||
))
|
))
|
||||||
return kzg.bytes_to_commitment(data, GLOBAL_PARAMETERS)
|
return kzg.bytes_to_commitment(data, GLOBAL_PARAMETERS)
|
||||||
|
|
||||||
@ -108,9 +108,14 @@ class DAEncoder:
|
|||||||
chunks_matrix = self._chunkify_data(data)
|
chunks_matrix = self._chunkify_data(data)
|
||||||
row_polynomials, row_commitments = zip(*self._compute_row_kzg_commitments(chunks_matrix))
|
row_polynomials, row_commitments = zip(*self._compute_row_kzg_commitments(chunks_matrix))
|
||||||
extended_matrix = self._rs_encode_rows(chunks_matrix)
|
extended_matrix = self._rs_encode_rows(chunks_matrix)
|
||||||
h = derive_challenge(row_commitments)
|
row_proofs = self._compute_rows_proofs(extended_matrix, row_polynomials, row_commitments)
|
||||||
combined_poly = compute_combined_polynomial(row_polynomials, h)
|
column_polynomials, column_commitments = zip(*self._compute_column_kzg_commitments(extended_matrix))
|
||||||
combined_column_proofs = self._compute_combined_column_proofs(combined_poly)
|
aggregated_column_polynomial, aggregated_column_commitment = (
|
||||||
|
self._compute_aggregated_column_commitment(column_commitments)
|
||||||
|
)
|
||||||
|
aggregated_column_proofs = self._compute_aggregated_column_proofs(
|
||||||
|
aggregated_column_polynomial, column_commitments
|
||||||
|
)
|
||||||
result = EncodedData(
|
result = EncodedData(
|
||||||
data,
|
data,
|
||||||
chunks_matrix,
|
chunks_matrix,
|
||||||
@ -122,4 +127,7 @@ class DAEncoder:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def hash_commitment_blake2b31(commitment: Commitment) -> bytes:
|
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
|
||||||
@ -87,12 +87,23 @@ class TestEncoder(TestCase):
|
|||||||
|
|
||||||
def test_generate_combined_column_proofs(self):
|
def test_generate_combined_column_proofs(self):
|
||||||
chunks_matrix = self.encoder._chunkify_data(self.data)
|
chunks_matrix = self.encoder._chunkify_data(self.data)
|
||||||
row_polynomials, row_commitments = zip(*self.encoder._compute_row_kzg_commitments(chunks_matrix))
|
polynomials, commitments = zip(*self.encoder._compute_column_kzg_commitments(chunks_matrix))
|
||||||
h = derive_challenge(row_commitments)
|
self.assertEqual(len(commitments), len(chunks_matrix[0]))
|
||||||
combined_poly = compute_combined_polynomial(row_polynomials, h)
|
self.assertEqual(len(polynomials), len(chunks_matrix[0]))
|
||||||
proofs = self.encoder._compute_combined_column_proofs(combined_poly)
|
|
||||||
expected_extended_columns = self.params.column_count * 2
|
def test_generate_aggregated_column_commitments(self):
|
||||||
self.assertEqual(len(proofs), expected_extended_columns)
|
chunks_matrix = self.encoder._chunkify_data(self.data)
|
||||||
|
_, column_commitments = zip(*self.encoder._compute_column_kzg_commitments(chunks_matrix))
|
||||||
|
poly, commitment = self.encoder._compute_aggregated_column_commitment(column_commitments)
|
||||||
|
self.assertIsNotNone(poly)
|
||||||
|
self.assertIsNotNone(commitment)
|
||||||
|
|
||||||
|
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(column_commitments)
|
||||||
|
proofs = self.encoder._compute_aggregated_column_proofs(poly, column_commitments)
|
||||||
|
self.assertEqual(len(proofs), len(column_commitments))
|
||||||
|
|
||||||
def test_encode(self):
|
def test_encode(self):
|
||||||
from random import randbytes
|
from random import randbytes
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user