mirror of
https://github.com/logos-co/nomos-specs.git
synced 2025-02-08 13:33:49 +00:00
* Added da encoder pipeline draft * Remove unnecessary method * Added verifier module and blob type * Fill verifier skeleton * Add comments on implementation, remove unnecessary intermediary method * Added dispersal skeleton * Added test modules for dispersal and verifier * Added test modules for encoder, implemented basic test * Added missing test cases * Added missing calls to encode method * Use single megabyte test in encoder * Added basic testcases for dispersal * Added basic testcases for verifier * Remove duplicated column proofs from encoding schema * Remove parameters from test functions in encoder * Extract common types to common module * Make test pass * Remove node id dep from mixnet and fix columns access
74 lines
2.4 KiB
Python
74 lines
2.4 KiB
Python
from dataclasses import dataclass
|
|
from typing import List
|
|
from eth2spec.eip7594.mainnet import KZGCommitment as Commitment, KZGProof as Proof
|
|
|
|
from da.common import ChunksMatrix
|
|
|
|
|
|
@dataclass
|
|
class DAEncoderParams:
|
|
column_count: int
|
|
bytes_per_field_element: int
|
|
|
|
|
|
@dataclass
|
|
class EncodedData:
|
|
data: bytearray
|
|
extended_matrix: ChunksMatrix
|
|
row_commitments: List[Commitment]
|
|
row_proofs: List[List[Proof]]
|
|
column_commitments: List[Commitment]
|
|
aggregated_column_commitment: Commitment
|
|
aggregated_column_proofs: List[Proof]
|
|
|
|
|
|
class DAEncoder:
|
|
def __init__(self, params: DAEncoderParams):
|
|
self.params = params
|
|
|
|
def _chunkify_data(self, data: bytearray) -> ChunksMatrix:
|
|
...
|
|
|
|
def _compute_row_kzg_commitments(self, rows: List[bytearray]) -> List[Commitment]:
|
|
...
|
|
|
|
def _rs_encode_rows(self, chunks_matrix: ChunksMatrix) -> ChunksMatrix:
|
|
...
|
|
|
|
def _compute_rows_proofs(self, chunks_matrix: ChunksMatrix, row_commitments: List[Commitment]) -> List[List[Proof]]:
|
|
...
|
|
|
|
def _compute_column_kzg_commitments(self, chunks_matrix: ChunksMatrix) -> List[Commitment]:
|
|
...
|
|
|
|
def _compute_aggregated_column_commitments(
|
|
self, chunks_matrix: ChunksMatrix, column_commitments: List[Commitment]
|
|
) -> Commitment:
|
|
...
|
|
|
|
def _compute_aggregated_column_proofs(
|
|
self,
|
|
chunks_matrix: ChunksMatrix,
|
|
aggregated_column_commitment: Commitment
|
|
) -> List[Proof]:
|
|
...
|
|
|
|
def encode(self, data: bytearray) -> EncodedData:
|
|
chunks_matrix = self._chunkify_data(data)
|
|
row_commitments = self._compute_row_kzg_commitments(chunks_matrix)
|
|
extended_matrix = self._rs_encode_rows(chunks_matrix)
|
|
row_proofs = self._compute_rows_proofs(extended_matrix, row_commitments)
|
|
column_commitments = self._compute_column_kzg_commitments(extended_matrix)
|
|
aggregated_column_commitment = self._compute_aggregated_column_commitments(extended_matrix, column_commitments)
|
|
aggregated_column_proofs = self._compute_aggregated_column_proofs(extended_matrix, aggregated_column_commitment)
|
|
result = EncodedData(
|
|
data,
|
|
extended_matrix,
|
|
row_commitments,
|
|
row_proofs,
|
|
column_commitments,
|
|
aggregated_column_commitment,
|
|
aggregated_column_proofs
|
|
)
|
|
return result
|