mirror of
https://github.com/logos-co/nomos-specs.git
synced 2025-01-10 15:46:03 +00:00
cf899d2384
* Implement generator polynomial and rs encoding * Implement encode/decode+test using fft. Non-working * Use lagrange for interpolation * Remove fft, use evaluations instead * Move and rename kzg and rs test modules * Update docs * Added columns property to chunks matrix Added test for columns * Added chunkify and test * Added compute row commitments Added row commitments size test * Fix poly from evaluations method * Implement encode rows and test * Update encode row test * Implement compute row proofs (not working on extended data) * Use same polynomials for commitment and proof creation after extend * Fix polynomial from/to evaluations * Use chunks for verification * Refactor interpolate * Implement chunks matrix transposed method * Added compute column kzg commitments * Use square size data for encoder tests * Add column type to columns method * Added compute columns aggregated commitment Added aggregated commitment test Fixed and expanded encode test * Use sha3 for hashing
51 lines
2.0 KiB
Python
51 lines
2.0 KiB
Python
from typing import List, Optional, Generator
|
|
|
|
from da.common import Certificate, NodeId
|
|
from da.encoder import EncodedData
|
|
from da.verifier import DABlob, Attestation
|
|
|
|
|
|
class Dispersal:
|
|
def __init__(self, nodes: List[NodeId], threshold: int):
|
|
self.nodes = nodes
|
|
self.threshold = threshold
|
|
|
|
def _prepare_data(self, encoded_data: EncodedData) -> Generator[DABlob, None, None]:
|
|
assert len(encoded_data.row_commitments) == len(self.nodes)
|
|
assert len(encoded_data.row_proofs) == len(self.nodes)
|
|
columns = encoded_data.extended_matrix.columns
|
|
column_commitments = encoded_data.column_commitments
|
|
row_commitments = encoded_data.row_commitments
|
|
rows_proofs = encoded_data.row_proofs
|
|
aggregated_column_commitment = encoded_data.aggregated_column_commitment
|
|
aggregated_column_proof = encoded_data.aggregated_column_proof
|
|
for index, (column, column_commitment, row_proofs) in enumerate(zip(columns, column_commitments, rows_proofs)):
|
|
blob = DABlob(
|
|
index,
|
|
column,
|
|
column_commitment,
|
|
aggregated_column_commitment,
|
|
aggregated_column_proof,
|
|
row_commitments,
|
|
row_proofs
|
|
)
|
|
yield blob
|
|
|
|
def _send_and_await_response(self, node, encoded_data: EncodedData) -> Optional[Attestation]:
|
|
pass
|
|
|
|
def _build_certificate(self, attestations: List[Attestation]):
|
|
pass
|
|
|
|
def _verify_attestation(self, attestation: Attestation) -> bool:
|
|
pass
|
|
|
|
def disperse(self, encoded_data: EncodedData) -> Optional[Certificate]:
|
|
attestations = []
|
|
for node, blob in zip(self.nodes, self._prepare_data(encoded_data)):
|
|
if attestation := self._send_and_await_response(node, blob):
|
|
if self._verify_attestation(attestation):
|
|
attestations.append(attestation)
|
|
if len(attestations) >= self.threshold:
|
|
return self._build_certificate(attestations)
|