From 65e1371980077390a1c0bdb524242a106c841692 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Mon, 16 Oct 2023 21:11:59 +0800 Subject: [PATCH] Fix tests --- specs/deneb/polynomial-commitments.md | 3 +-- .../polynomial_commitments/test_polynomial_commitments.py | 6 +++--- tests/core/pyspec/eth2spec/test/helpers/sharding.py | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/specs/deneb/polynomial-commitments.md b/specs/deneb/polynomial-commitments.md index e58f2b681..ac5ba5751 100644 --- a/specs/deneb/polynomial-commitments.md +++ b/specs/deneb/polynomial-commitments.md @@ -299,9 +299,8 @@ def compute_roots_of_unity(order: uint64) -> Sequence[BLSFieldElement]: """ Return roots of unity of ``order``. """ - PRIMITIVE_ROOT = 7 assert (BLS_MODULUS - 1) % int(order) == 0 - root_of_unity = BLSFieldElement(pow(PRIMITIVE_ROOT, (BLS_MODULUS - 1) // int(order), BLS_MODULUS)) + root_of_unity = BLSFieldElement(pow(PRIMITIVE_ROOT_OF_UNITY, (BLS_MODULUS - 1) // int(order), BLS_MODULUS)) return compute_powers(root_of_unity, order) ``` diff --git a/tests/core/pyspec/eth2spec/test/deneb/unittests/polynomial_commitments/test_polynomial_commitments.py b/tests/core/pyspec/eth2spec/test/deneb/unittests/polynomial_commitments/test_polynomial_commitments.py index 30b730941..7ee7168d9 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/unittests/polynomial_commitments/test_polynomial_commitments.py +++ b/tests/core/pyspec/eth2spec/test/deneb/unittests/polynomial_commitments/test_polynomial_commitments.py @@ -113,7 +113,7 @@ def test_barycentric_outside_domain(spec): """ rng = random.Random(5566) poly_coeff, poly_eval = get_poly_in_both_forms(spec) - roots_of_unity_brp = spec.bit_reversal_permutation(spec.ROOTS_OF_UNITY) + roots_of_unity_brp = spec.bit_reversal_permutation(spec.compute_roots_of_unity(spec.FIELD_ELEMENTS_PER_BLOB)) assert len(poly_coeff) == len(poly_eval) == len(roots_of_unity_brp) n_samples = 12 @@ -147,7 +147,7 @@ def test_barycentric_within_domain(spec): """ rng = random.Random(5566) poly_coeff, poly_eval = get_poly_in_both_forms(spec) - roots_of_unity_brp = spec.bit_reversal_permutation(spec.ROOTS_OF_UNITY) + roots_of_unity_brp = spec.bit_reversal_permutation(spec.compute_roots_of_unity(spec.FIELD_ELEMENTS_PER_BLOB)) assert len(poly_coeff) == len(poly_eval) == len(roots_of_unity_brp) n = len(poly_coeff) @@ -182,7 +182,7 @@ def test_compute_kzg_proof_within_domain(spec): commitment = spec.blob_to_kzg_commitment(blob) polynomial = spec.blob_to_polynomial(blob) - roots_of_unity_brp = spec.bit_reversal_permutation(spec.ROOTS_OF_UNITY) + roots_of_unity_brp = spec.bit_reversal_permutation(spec.compute_roots_of_unity(spec.FIELD_ELEMENTS_PER_BLOB)) # Let's test some roots of unity for _ in range(6): diff --git a/tests/core/pyspec/eth2spec/test/helpers/sharding.py b/tests/core/pyspec/eth2spec/test/helpers/sharding.py index 69ea0e133..25b4dea59 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/sharding.py +++ b/tests/core/pyspec/eth2spec/test/helpers/sharding.py @@ -80,7 +80,7 @@ def get_poly_in_both_forms(spec, rng=None): if rng is None: rng = random.Random(5566) - roots_of_unity_brp = spec.bit_reversal_permutation(spec.compute_roots_of_unity(spec.compute_roots_of_unity)) + roots_of_unity_brp = spec.bit_reversal_permutation(spec.compute_roots_of_unity(spec.FIELD_ELEMENTS_PER_BLOB)) coeffs = [ rng.randint(0, spec.BLS_MODULUS - 1)