diff --git a/da/common.py b/da/common.py new file mode 100644 index 0000000..507e6b5 --- /dev/null +++ b/da/common.py @@ -0,0 +1,31 @@ +from dataclasses import dataclass +from typing import List + +from eth2spec.eip7594.mainnet import Bytes32 + + +class Chunk(Bytes32): + pass + + +class Column(List[Chunk]): + pass + + +class Row(List[Chunk]): + pass + + +class ChunksMatrix(List[Row]): + pass + + +@dataclass +class Attestation: + pass + + +@dataclass +class Certificate: + pass + diff --git a/da/dispersal.py b/da/dispersal.py index b9cfd67..9c71751 100644 --- a/da/dispersal.py +++ b/da/dispersal.py @@ -1,14 +1,11 @@ from typing import List, Optional, Generator +from da.common import Certificate from da.encoder import EncodedData from da.verifier import DABlob, Attestation from mixnet.node import NodeId -class Certificate: - pass - - class Dispersal: def __init__(self, nodes: List[NodeId], threshold: int): self.nodes = nodes diff --git a/da/encoder.py b/da/encoder.py index fe32245..97380e9 100644 --- a/da/encoder.py +++ b/da/encoder.py @@ -2,9 +2,7 @@ from dataclasses import dataclass from typing import List from eth2spec.eip7594.mainnet import KZGCommitment as Commitment, KZGProof as Proof - -class ChunksMatrix(List[bytearray]): - pass +from da.common import ChunksMatrix @dataclass diff --git a/da/verifier.py b/da/verifier.py index 58ad5ea..12f9727 100644 --- a/da/verifier.py +++ b/da/verifier.py @@ -7,6 +7,8 @@ from eth2spec.eip7594.mainnet import ( ) from itertools import batched +from da.common import Column, Chunk, Attestation + @dataclass class DABlob: @@ -20,18 +22,13 @@ class DABlob: rows_proofs: List[Proof] -@dataclass -class Attestation: - pass - - class DAVerifier: def __init__(self): pass @staticmethod def _verify_column( - column: bytearray, + column: Column, column_commitment: Commitment, aggregated_column_commitment: Commitment, aggregated_column_proof: Proof, @@ -44,15 +41,15 @@ class DAVerifier: # 3. compute column hash column_hash: bytearray = bytearray(hash(column)) # 4. Check proof with commitment and proof over the aggregated column commitment - pass + return False @staticmethod - def _verify_chunk(chunk: bytearray, commitment: Commitment, proof: Proof) -> bool: + def _verify_chunk(chunk: Chunk, commitment: Commitment, proof: Proof) -> bool: pass @staticmethod def _verify_chunks( - chunks: List[bytearray], + chunks: List[Chunk], commitments: List[Commitment], proofs: List[Proof] ) -> bool: