diff --git a/da/common.py b/da/common.py index 8d00f29..af21514 100644 --- a/da/common.py +++ b/da/common.py @@ -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" diff --git a/da/dispersal.py b/da/dispersal.py index 5ef7ff7..4cd1067 100644 --- a/da/dispersal.py +++ b/da/dispersal.py @@ -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 diff --git a/da/test_dispersal.py b/da/test_dispersal.py index 69a8ccd..a4d59b6 100644 --- a/da/test_dispersal.py +++ b/da/test_dispersal.py @@ -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): diff --git a/da/test_full_flow.py b/da/test_full_flow.py index 08e26c0..ad63adf 100644 --- a/da/test_full_flow.py +++ b/da/test_full_flow.py @@ -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 diff --git a/da/test_verifier.py b/da/test_verifier.py index 5216dd1..8d9e763 100644 --- a/da/test_verifier.py +++ b/da/test_verifier.py @@ -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 diff --git a/da/verifier.py b/da/verifier.py index 730024c..3c0cef3 100644 --- a/da/verifier.py +++ b/da/verifier.py @@ -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