2024-02-12 14:35:23 +00:00
|
|
|
from dataclasses import dataclass
|
2024-03-08 13:16:14 +00:00
|
|
|
from itertools import chain, zip_longest
|
|
|
|
from typing import List, Generator, Self
|
2024-02-12 14:35:23 +00:00
|
|
|
|
2024-03-13 13:59:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
from eth2spec.eip7594.mainnet import Bytes32, KZGCommitment as Commitment
|
2024-02-12 14:35:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
class NodeId(Bytes32):
|
|
|
|
pass
|
|
|
|
|
2024-03-13 13:59:27 +00:00
|
|
|
|
2024-02-12 14:35:23 +00:00
|
|
|
class Chunk(Bytes32):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2024-03-08 13:16:14 +00:00
|
|
|
class Column(List[Bytes32]):
|
|
|
|
def as_bytes(self) -> bytes:
|
|
|
|
return bytes(chain.from_iterable(self))
|
2024-02-12 14:35:23 +00:00
|
|
|
|
|
|
|
|
2024-03-08 13:16:14 +00:00
|
|
|
class Row(List[Bytes32]):
|
|
|
|
def as_bytes(self) -> bytes:
|
|
|
|
return bytes(chain.from_iterable(self))
|
2024-02-12 14:35:23 +00:00
|
|
|
|
|
|
|
|
2024-03-08 13:16:14 +00:00
|
|
|
class ChunksMatrix(List[Row | Column]):
|
|
|
|
@property
|
2024-02-12 14:35:23 +00:00
|
|
|
def columns(self) -> Generator[List[Chunk], None, None]:
|
2024-03-08 13:16:14 +00:00
|
|
|
yield from map(Column, zip_longest(*self, fillvalue=b""))
|
|
|
|
|
|
|
|
def transposed(self) -> Self:
|
|
|
|
return ChunksMatrix(self.columns)
|
2024-02-12 14:35:23 +00:00
|
|
|
|
|
|
|
|
2024-03-13 13:59:27 +00:00
|
|
|
BLSPublickey = bytes
|
|
|
|
BLSPrivateKey = int
|
|
|
|
BLSSignature = bytes
|
2024-02-12 14:35:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Attestation:
|
2024-03-13 13:59:27 +00:00
|
|
|
signature: BLSSignature
|
2024-02-12 14:35:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Certificate:
|
2024-03-13 13:59:27 +00:00
|
|
|
aggregated_signatures: BLSSignature
|
|
|
|
aggregated_column_commitment: Commitment
|
|
|
|
row_commitments: List[Commitment]
|
2024-02-12 14:35:23 +00:00
|
|
|
|