mirror of
https://github.com/logos-co/nomos-specs.git
synced 2025-01-23 22:08:57 +00:00
Extract common types to common module
This commit is contained in:
parent
94c18f3cb9
commit
1786d54f57
31
da/common.py
Normal file
31
da/common.py
Normal 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
|
||||||
|
|
@ -1,14 +1,11 @@
|
|||||||
from typing import List, Optional, Generator
|
from typing import List, Optional, Generator
|
||||||
|
|
||||||
|
from da.common import Certificate
|
||||||
from da.encoder import EncodedData
|
from da.encoder import EncodedData
|
||||||
from da.verifier import DABlob, Attestation
|
from da.verifier import DABlob, Attestation
|
||||||
from mixnet.node import NodeId
|
from mixnet.node import NodeId
|
||||||
|
|
||||||
|
|
||||||
class Certificate:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class Dispersal:
|
class Dispersal:
|
||||||
def __init__(self, nodes: List[NodeId], threshold: int):
|
def __init__(self, nodes: List[NodeId], threshold: int):
|
||||||
self.nodes = nodes
|
self.nodes = nodes
|
||||||
|
@ -2,9 +2,7 @@ from dataclasses import dataclass
|
|||||||
from typing import List
|
from typing import List
|
||||||
from eth2spec.eip7594.mainnet import KZGCommitment as Commitment, KZGProof as Proof
|
from eth2spec.eip7594.mainnet import KZGCommitment as Commitment, KZGProof as Proof
|
||||||
|
|
||||||
|
from da.common import ChunksMatrix
|
||||||
class ChunksMatrix(List[bytearray]):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
@ -7,6 +7,8 @@ from eth2spec.eip7594.mainnet import (
|
|||||||
)
|
)
|
||||||
from itertools import batched
|
from itertools import batched
|
||||||
|
|
||||||
|
from da.common import Column, Chunk, Attestation
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class DABlob:
|
class DABlob:
|
||||||
@ -20,18 +22,13 @@ class DABlob:
|
|||||||
rows_proofs: List[Proof]
|
rows_proofs: List[Proof]
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class Attestation:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class DAVerifier:
|
class DAVerifier:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _verify_column(
|
def _verify_column(
|
||||||
column: bytearray,
|
column: Column,
|
||||||
column_commitment: Commitment,
|
column_commitment: Commitment,
|
||||||
aggregated_column_commitment: Commitment,
|
aggregated_column_commitment: Commitment,
|
||||||
aggregated_column_proof: Proof,
|
aggregated_column_proof: Proof,
|
||||||
@ -44,15 +41,15 @@ class DAVerifier:
|
|||||||
# 3. compute column hash
|
# 3. compute column hash
|
||||||
column_hash: bytearray = bytearray(hash(column))
|
column_hash: bytearray = bytearray(hash(column))
|
||||||
# 4. Check proof with commitment and proof over the aggregated column commitment
|
# 4. Check proof with commitment and proof over the aggregated column commitment
|
||||||
pass
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _verify_chunk(chunk: bytearray, commitment: Commitment, proof: Proof) -> bool:
|
def _verify_chunk(chunk: Chunk, commitment: Commitment, proof: Proof) -> bool:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _verify_chunks(
|
def _verify_chunks(
|
||||||
chunks: List[bytearray],
|
chunks: List[Chunk],
|
||||||
commitments: List[Commitment],
|
commitments: List[Commitment],
|
||||||
proofs: List[Proof]
|
proofs: List[Proof]
|
||||||
) -> bool:
|
) -> bool:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user