DA domain specific tag in bls (#94)
This commit is contained in:
parent
9390d481ba
commit
c9b2c7c5c5
|
@ -4,7 +4,7 @@ from itertools import chain, zip_longest, compress
|
||||||
from typing import List, Generator, Self, Sequence
|
from typing import List, Generator, Self, Sequence
|
||||||
|
|
||||||
from eth2spec.eip7594.mainnet import Bytes32, KZGCommitment as Commitment
|
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):
|
class NodeId(Bytes32):
|
||||||
|
@ -67,7 +67,7 @@ class Certificate:
|
||||||
# we sort them as the signers bitfield is sorted by the public keys as well
|
# 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))
|
signers_keys = list(compress(sorted(nodes_public_keys), self.signers))
|
||||||
message = build_attestation_message(self.aggregated_column_commitment, self.row_commitments)
|
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:
|
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:
|
for c in row_commitments:
|
||||||
hasher.update(bytes(c))
|
hasher.update(bytes(c))
|
||||||
return hasher.digest()
|
return hasher.digest()
|
||||||
|
|
||||||
|
class NomosDaG2ProofOfPossession(G2ProofOfPossession):
|
||||||
|
# Domain specific tag for Nomos DA protocol
|
||||||
|
DST = b"NOMOS_DA_AVAIL"
|
||||||
|
|
|
@ -2,9 +2,7 @@ from dataclasses import dataclass
|
||||||
from hashlib import sha3_256
|
from hashlib import sha3_256
|
||||||
from typing import List, Optional, Generator, Sequence
|
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, NomosDaG2ProofOfPossession as bls_pop
|
||||||
|
|
||||||
from da.common import Certificate, NodeId, BLSPublicKey, Bitfield, build_attestation_message
|
|
||||||
from da.encoder import EncodedData
|
from da.encoder import EncodedData
|
||||||
from da.verifier import DABlob, Attestation
|
from da.verifier import DABlob, Attestation
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,9 @@ from unittest import TestCase
|
||||||
from da.encoder import DAEncoderParams, DAEncoder
|
from da.encoder import DAEncoderParams, DAEncoder
|
||||||
from da.test_encoder import TestEncoder
|
from da.test_encoder import TestEncoder
|
||||||
from da.verifier import DAVerifier, DABlob
|
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 da.dispersal import Dispersal, EncodedData, DispersalSettings
|
||||||
|
|
||||||
from py_ecc.bls import G2ProofOfPossession as bls_pop
|
|
||||||
|
|
||||||
|
|
||||||
class TestDispersal(TestCase):
|
class TestDispersal(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
@ -2,9 +2,7 @@ from itertools import chain
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from py_ecc.bls import G2ProofOfPossession as bls_pop
|
from da.common import NodeId, build_attestation_message, BLSPublicKey, NomosDaG2ProofOfPossession as bls_pop
|
||||||
|
|
||||||
from da.common import NodeId, build_attestation_message, BLSPublicKey
|
|
||||||
from da.api.common import DAApi, VID, Metadata
|
from da.api.common import DAApi, VID, Metadata
|
||||||
from da.verifier import DAVerifier, DABlob
|
from da.verifier import DAVerifier, DABlob
|
||||||
from da.api.test_flow import MockStore
|
from da.api.test_flow import MockStore
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from py_ecc.bls import G2ProofOfPossession as bls_pop
|
from da.common import Column, NomosDaG2ProofOfPossession as bls_pop
|
||||||
|
|
||||||
from da.common import Column
|
|
||||||
from da.encoder import DAEncoder
|
from da.encoder import DAEncoder
|
||||||
from da.kzg_rs import kzg
|
from da.kzg_rs import kzg
|
||||||
from da.kzg_rs.common import GLOBAL_PARAMETERS, ROOTS_OF_UNITY
|
from da.kzg_rs.common import GLOBAL_PARAMETERS, ROOTS_OF_UNITY
|
||||||
|
|
|
@ -7,10 +7,9 @@ from eth2spec.eip7594.mainnet import (
|
||||||
KZGCommitment as Commitment,
|
KZGCommitment as Commitment,
|
||||||
KZGProof as Proof,
|
KZGProof as Proof,
|
||||||
)
|
)
|
||||||
from py_ecc.bls import G2ProofOfPossession as bls_pop
|
|
||||||
|
|
||||||
import da.common
|
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.encoder import DAEncoder
|
||||||
from da.kzg_rs import kzg
|
from da.kzg_rs import kzg
|
||||||
from da.kzg_rs.common import ROOTS_OF_UNITY, GLOBAL_PARAMETERS, BLS_MODULUS
|
from da.kzg_rs.common import ROOTS_OF_UNITY, GLOBAL_PARAMETERS, BLS_MODULUS
|
||||||
|
|
Loading…
Reference in New Issue