Implement compute row proofs (not working on extended data)

This commit is contained in:
Daniel Sanchez Quiros 2024-03-05 19:02:19 +01:00
parent 0fa9f5edd2
commit 3fddca075c
3 changed files with 27 additions and 4 deletions

View File

@ -11,11 +11,11 @@ class Chunk(Bytes32):
pass pass
class Column(bytes): class Column(List[Bytes32]):
pass pass
class Row(bytes): class Row(List[Bytes32]):
pass pass

View File

@ -51,7 +51,16 @@ class DAEncoder:
return ChunksMatrix(__rs_encode_row(row) for row in chunks_matrix) return ChunksMatrix(__rs_encode_row(row) for row in chunks_matrix)
def _compute_rows_proofs(self, chunks_matrix: ChunksMatrix, row_commitments: List[Commitment]) -> List[List[Proof]]: def _compute_rows_proofs(self, chunks_matrix: ChunksMatrix, row_commitments: List[Commitment]) -> List[List[Proof]]:
... proofs = []
for row, commitment in zip(chunks_matrix, row_commitments):
poly = kzg.bytes_to_polynomial(row)
proofs.append(
[
kzg.generate_element_proof(i, poly, GLOBAL_PARAMETERS, ROOTS_OF_UNITY)
for i in range(len(row)//self.params.bytes_per_field_element)
]
)
return proofs
def _compute_column_kzg_commitments(self, chunks_matrix: ChunksMatrix) -> List[Commitment]: def _compute_column_kzg_commitments(self, chunks_matrix: ChunksMatrix) -> List[Commitment]:
... ...

View File

@ -57,7 +57,21 @@ class TestEncoder(TestCase):
self.assertEqual(poly_1, poly_2) self.assertEqual(poly_1, poly_2)
def test_compute_rows_proofs(self): def test_compute_rows_proofs(self):
pass chunks_matrix = self.encoder._chunkify_data(self.data)
commitments = self.encoder._compute_row_kzg_commitments(chunks_matrix)
extended_chunks_matrix = self.encoder._rs_encode_rows(chunks_matrix)
original_proofs = self.encoder._compute_rows_proofs(chunks_matrix, commitments)
extended_proofs = self.encoder._compute_rows_proofs(extended_chunks_matrix, commitments)
# check original sized matrix
for row, commitment, proofs in zip(chunks_matrix, commitments, original_proofs):
poly = kzg.bytes_to_polynomial(row)
for i in range(len(proofs)):
self.assertTrue(kzg.verify_element_proof(poly, commitment, proofs[i], i, ROOTS_OF_UNITY))
# check extended matrix
for row, commitment, proofs in zip(extended_chunks_matrix, commitments, extended_proofs):
poly = kzg.bytes_to_polynomial(row)
for i in range(len(proofs)):
self.assertTrue(kzg.verify_element_proof(poly, commitment, proofs[i], i, ROOTS_OF_UNITY))
def test_compute_column_kzg_commitments(self): def test_compute_column_kzg_commitments(self):
pass pass