mirror of
https://github.com/logos-co/nomos-specs.git
synced 2025-02-08 13:33:49 +00:00
7ffb7cc7ed
* Implement generator polynomial and rs encoding * Implement encode/decode+test using fft. Non-working * Use lagrange for interpolation * Remove fft, use evaluations instead * Move and rename kzg and rs test modules * Update docs * Added columns property to chunks matrix Added test for columns * Added chunkify and test * Added compute row commitments Added row commitments size test * Fix poly from evaluations method * Implement encode rows and test * Update encode row test * Implement compute row proofs (not working on extended data) * Use same polynomials for commitment and proof creation after extend * Fix polynomial from/to evaluations * Use chunks for verification * Refactor interpolate * Implement chunks matrix transposed method * Added compute column kzg commitments * Use square size data for encoder tests * Add column type to columns method * Added compute columns aggregated commitment Added aggregated commitment test Fixed and expanded encode test * Use sha3 for hashing * Make encoder hashing method public * Fill up verifier implementation * Added verify column test * Implement verier verify test Fixed small issues * Implement verier verify test Extend verify test for all columns
47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
from unittest import TestCase
|
|
|
|
from da.common import Column
|
|
from da.encoder import DAEncoder
|
|
from da.kzg_rs import kzg
|
|
from da.kzg_rs.common import GLOBAL_PARAMETERS, ROOTS_OF_UNITY
|
|
from da.test_encoder import TestEncoder
|
|
from da.verifier import Attestation, DAVerifier, DABlob
|
|
|
|
|
|
class TestVerifier(TestCase):
|
|
|
|
def setUp(self):
|
|
self.verifier = DAVerifier(b"")
|
|
|
|
def test_verify_column(self):
|
|
column = Column(int.to_bytes(i, length=32) for i in range(8))
|
|
_, column_commitment = kzg.bytes_to_commitment(column.as_bytes(), GLOBAL_PARAMETERS)
|
|
aggregated_poly, aggregated_column_commitment = kzg.bytes_to_commitment(
|
|
DAEncoder.hash_column_and_commitment(column, column_commitment), GLOBAL_PARAMETERS
|
|
)
|
|
aggregated_proof = kzg.generate_element_proof(0, aggregated_poly, GLOBAL_PARAMETERS, ROOTS_OF_UNITY)
|
|
self.assertTrue(
|
|
self.verifier._verify_column(
|
|
column, column_commitment, aggregated_column_commitment, aggregated_proof, 0
|
|
)
|
|
)
|
|
|
|
def test_build_attestation(self):
|
|
pass
|
|
|
|
def test_verify(self):
|
|
_ = TestEncoder()
|
|
_.setUp()
|
|
encoded_data = _.encoder.encode(_.data)
|
|
for i, column in enumerate(encoded_data.chunked_data.columns):
|
|
da_blob = DABlob(
|
|
i,
|
|
Column(column),
|
|
encoded_data.column_commitments[i],
|
|
encoded_data.aggregated_column_commitment,
|
|
encoded_data.aggregated_column_proofs[i],
|
|
encoded_data.row_commitments,
|
|
[row[i] for row in encoded_data.row_proofs],
|
|
)
|
|
self.assertIsNotNone(self.verifier.verify(da_blob))
|