DA domain specific tag in bls (#94)

This commit is contained in:
gusto 2024-05-27 12:38:18 +03:00 committed by GitHub
parent 9390d481ba
commit c9b2c7c5c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 11 additions and 16 deletions

View File

@ -4,7 +4,7 @@ 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 as bls_pop
from py_ecc.bls import G2ProofOfPossession
class NodeId(Bytes32):
@ -67,7 +67,7 @@ class Certificate:
# we sort them as the signers bitfield is sorted by the public keys as well
signers_keys = list(compress(sorted(nodes_public_keys), self.signers))
message = build_attestation_message(self.aggregated_column_commitment, self.row_commitments)
return bls_pop.AggregateVerify(signers_keys, [message]*len(signers_keys), self.aggregated_signatures)
return NomosDaG2ProofOfPossession.AggregateVerify(signers_keys, [message]*len(signers_keys), self.aggregated_signatures)
def build_attestation_message(aggregated_column_commitment: Commitment, row_commitments: Sequence[Commitment]) -> bytes:
@ -76,3 +76,7 @@ def build_attestation_message(aggregated_column_commitment: Commitment, row_comm
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"

View File

@ -2,9 +2,7 @@ from dataclasses import dataclass
from hashlib import sha3_256
from typing import List, Optional, Generator, Sequence
from py_ecc.bls import G2ProofOfPossession as bls_pop
from da.common import Certificate, NodeId, BLSPublicKey, Bitfield, build_attestation_message
from da.common import Certificate, NodeId, BLSPublicKey, Bitfield, build_attestation_message, NomosDaG2ProofOfPossession as bls_pop
from da.encoder import EncodedData
from da.verifier import DABlob, Attestation

View File

@ -4,11 +4,9 @@ from unittest import TestCase
from da.encoder import DAEncoderParams, DAEncoder
from da.test_encoder import TestEncoder
from da.verifier import DAVerifier, DABlob
from da.common import NodeId, Attestation, Bitfield
from da.common import NodeId, Attestation, Bitfield, NomosDaG2ProofOfPossession as bls_pop
from da.dispersal import Dispersal, EncodedData, DispersalSettings
from py_ecc.bls import G2ProofOfPossession as bls_pop
class TestDispersal(TestCase):
def setUp(self):

View File

@ -2,9 +2,7 @@ from itertools import chain
from unittest import TestCase
from typing import List, Optional
from py_ecc.bls import G2ProofOfPossession as bls_pop
from da.common import NodeId, build_attestation_message, BLSPublicKey
from da.common import NodeId, build_attestation_message, BLSPublicKey, NomosDaG2ProofOfPossession as bls_pop
from da.api.common import DAApi, VID, Metadata
from da.verifier import DAVerifier, DABlob
from da.api.test_flow import MockStore

View File

@ -1,8 +1,6 @@
from unittest import TestCase
from py_ecc.bls import G2ProofOfPossession as bls_pop
from da.common import Column
from da.common import Column, NomosDaG2ProofOfPossession as bls_pop
from da.encoder import DAEncoder
from da.kzg_rs import kzg
from da.kzg_rs.common import GLOBAL_PARAMETERS, ROOTS_OF_UNITY

View File

@ -7,10 +7,9 @@ from eth2spec.eip7594.mainnet import (
KZGCommitment as Commitment,
KZGProof as Proof,
)
from py_ecc.bls import G2ProofOfPossession as bls_pop
import da.common
from da.common import Column, Chunk, Attestation, BLSPrivateKey, BLSPublicKey
from da.common import Column, Chunk, Attestation, BLSPrivateKey, BLSPublicKey, NomosDaG2ProofOfPossession as bls_pop
from da.encoder import DAEncoder
from da.kzg_rs import kzg
from da.kzg_rs.common import ROOTS_OF_UNITY, GLOBAL_PARAMETERS, BLS_MODULUS