Daniel Sanchez 3f3427ee9f
NomosDA spec v1 updates (#117)
* Modify and rename hash_commitment method. Now we just hash the column commitment itself.

* Fix calls

* Remove certificate from verifier

* Update verifier

* Fix tests

* Fix verifier imports

* Fix more imports

* Fix dispersal

* Fix more imports

* Fix missing parameter in dispersal

* Fix tests

* Full flow renaming

* Disperse encoded data in full flow test

* Make da verification indempotent (#118)

---------

Co-authored-by: Gusto <bacvinka@gmail.com>
Co-authored-by: gusto <bacv@users.noreply.github.com>
2025-01-29 10:42:53 +00:00

54 lines
1.3 KiB
Python

from dataclasses import dataclass
from hashlib import sha3_256
from itertools import chain, zip_longest, compress
from typing import List, Generator, Self, Sequence
from eth2spec.eip7594.mainnet import Bytes32, KZGCommitment as Commitment
from py_ecc.bls import G2ProofOfPossession
type BlobId = bytes
class NodeId(Bytes32):
pass
class Chunk(bytes):
pass
class Column(List[Bytes32]):
def as_bytes(self) -> bytes:
return bytes(chain.from_iterable(self))
class Row(List[Bytes32]):
def as_bytes(self) -> bytes:
return bytes(chain.from_iterable(self))
class ChunksMatrix(List[Row | Column]):
@property
def columns(self) -> Generator[List[Chunk], None, None]:
yield from map(Column, zip_longest(*self, fillvalue=b""))
def transposed(self) -> Self:
return ChunksMatrix(self.columns)
class Bitfield(List[bool]):
pass
def build_blob_id(aggregated_column_commitment: Commitment, row_commitments: Sequence[Commitment]) -> BlobId:
hasher = sha3_256()
hasher.update(bytes(aggregated_column_commitment))
for c in row_commitments:
hasher.update(bytes(c))
return hasher.digest()
class NomosDaG2ProofOfPossession(G2ProofOfPossession):
# Domain specific tag for Nomos DA protocol
DST = b"NOMOS_DA_AVAIL"