mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-05 06:33:08 +00:00
Add case in where verifier data is the same but column is different
This commit is contained in:
parent
1d49de90fc
commit
93b2d59b96
@ -1,6 +1,6 @@
|
||||
from dataclasses import dataclass
|
||||
from hashlib import sha3_256
|
||||
from typing import List, Optional, Sequence, Set
|
||||
from typing import List, Optional, Sequence, Set, Dict
|
||||
|
||||
from eth2spec.deneb.mainnet import BLSFieldElement
|
||||
from eth2spec.eip7594.mainnet import (
|
||||
@ -26,13 +26,16 @@ class DABlob:
|
||||
rows_commitments: List[Commitment]
|
||||
rows_proofs: List[Proof]
|
||||
|
||||
def id(self):
|
||||
def id(self) -> bytes:
|
||||
return da.common.build_attestation_message(self.aggregated_column_commitment, self.rows_commitments)
|
||||
|
||||
def column_id(self) -> bytes:
|
||||
return sha3_256(self.column.as_bytes()).digest()
|
||||
|
||||
|
||||
class DAVerifier:
|
||||
def __init__(self, sk: BLSPrivateKey):
|
||||
self.attested_blobs: Set[bytes] = set()
|
||||
self.attested_blobs: Dict[bytes, (bytes, Attestation)] = dict()
|
||||
self.sk = sk
|
||||
|
||||
@staticmethod
|
||||
@ -84,8 +87,14 @@ class DAVerifier:
|
||||
return Attestation(signature=bls_pop.Sign(self.sk, message))
|
||||
|
||||
def verify(self, blob: DABlob) -> Optional[Attestation]:
|
||||
if (blob_id := blob.id()) in self.attested_blobs:
|
||||
# We already attested for such blob, skip
|
||||
blob_id = blob.id()
|
||||
if previous_attestation := self.attested_blobs.get(blob_id):
|
||||
column_id, attestation = previous_attestation
|
||||
# we already attested, is cached so we return it
|
||||
if column_id == blob.column_id():
|
||||
return attestation
|
||||
# we already attested and they are asking us to attest the same data different column
|
||||
# skip
|
||||
return None
|
||||
is_column_verified = DAVerifier._verify_column(
|
||||
blob.column,
|
||||
@ -101,5 +110,6 @@ class DAVerifier:
|
||||
)
|
||||
if not are_chunks_verified:
|
||||
return
|
||||
self.attested_blobs.add(blob_id)
|
||||
return self._build_attestation(blob)
|
||||
attestation = self._build_attestation(blob)
|
||||
self.attested_blobs[blob_id] = (blob.column_id(), attestation)
|
||||
return attestation
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user