Make encoder hashing method public

This commit is contained in:
Daniel Sanchez Quiros 2024-03-08 14:57:16 +01:00
parent 0337a12733
commit c416b173d4
2 changed files with 3 additions and 3 deletions

View File

@ -78,7 +78,7 @@ class DAEncoder:
chunks_matrix: ChunksMatrix, column_commitments: Sequence[Commitment]
) -> Tuple[Polynomial, Commitment]:
data = bytes(chain.from_iterable(
DAEncoder._hash_column_and_commitment(column, commitment)
DAEncoder.hash_column_and_commitment(column, commitment)
for column, commitment in zip(chunks_matrix.columns, column_commitments)
))
return kzg.bytes_to_commitment(data, GLOBAL_PARAMETERS)
@ -117,7 +117,7 @@ class DAEncoder:
return result
@staticmethod
def _hash_column_and_commitment(column: Column, commitment: Commitment) -> bytes:
def hash_column_and_commitment(column: Column, commitment: Commitment) -> bytes:
# TODO: Check correctness of bytes to blsfieldelement using modulus over the hash
return (
int.from_bytes(sha3_256(column.as_bytes() + bytes(commitment)).digest()) % BLS_MODULUS

View File

@ -47,7 +47,7 @@ class TestEncoder(TestCase):
# verify column aggregation
for i, (column, proof) in enumerate(zip(encoded_data.extended_matrix.columns, encoded_data.aggregated_column_proofs)):
data = DAEncoder._hash_column_and_commitment(column, commitment)
data = DAEncoder.hash_column_and_commitment(column, commitment)
kzg.verify_element_proof(
bytes_to_bls_field(data),
encoded_data.aggregated_column_commitment,