Extract common types to common module

This commit is contained in:
Daniel Sanchez Quiros 2024-02-09 18:13:02 +01:00
parent 94c18f3cb9
commit 1786d54f57
4 changed files with 39 additions and 16 deletions

31
da/common.py Normal file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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: