nomos-specs/da/common.py

45 lines
758 B
Python
Raw Normal View History

from dataclasses import dataclass
2024-03-06 15:02:48 +00:00
from itertools import chain
from typing import List, Generator, Self
from eth2spec.eip7594.mainnet import Bytes32
class NodeId(Bytes32):
pass
class Chunk(Bytes32):
pass
class Column(List[Bytes32]):
2024-03-06 16:53:27 +00:00
def as_bytes(self) -> bytes:
return bytes(chain.from_iterable(self))
class Row(List[Bytes32]):
2024-03-06 15:02:48 +00:00
def as_bytes(self) -> bytes:
return bytes(chain.from_iterable(self))
2024-03-06 16:53:27 +00:00
class ChunksMatrix(List[Row | Column]):
@property
def columns(self) -> Generator[List[Chunk], None, None]:
2024-03-06 16:53:27 +00:00
yield from map(Column, zip(*self))
def transposed(self) -> Self:
return ChunksMatrix(self.columns)
@dataclass
class Attestation:
pass
@dataclass
class Certificate:
pass