mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-02 21:23:06 +00:00
* 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>
54 lines
1.3 KiB
Python
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"
|