Skip to content

Commit fc62e59

Browse files
committed
extend test for eip7594
1 parent ca64850 commit fc62e59

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/core/pyspec/eth2spec/test/eip7594/unittests/polynomial_commitments/test_polynomial_commitments.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,35 @@
1515
@spec_test
1616
@single_phase
1717
def test_fft(spec):
18+
19+
# in this test we sample a random polynomial in coefficient form
20+
# then we apply an FFT to get evaluations over the roots of unity
21+
# we then apply an inverse FFT to the evaluations to get coefficients
22+
23+
# we check two things:
24+
# 1) the original coefficients and the resulting coefficients match
25+
# 2) the evaluations that we got are the same as if we would have evaluated individually
26+
1827
rng = random.Random(5566)
1928

2029
roots_of_unity = spec.compute_roots_of_unity(spec.FIELD_ELEMENTS_PER_BLOB)
2130

31+
# sample a random polynomial
2232
poly_coeff = [rng.randint(0, BLS_MODULUS - 1) for _ in range(spec.FIELD_ELEMENTS_PER_BLOB)]
2333

34+
# do an FFT and then an inverse FFT
2435
poly_eval = spec.fft_field(poly_coeff, roots_of_unity)
2536
poly_coeff_inversed = spec.fft_field(poly_eval, roots_of_unity, inv=True)
2637

38+
# first check: inverse FFT after FFT results in original coefficients
2739
assert len(poly_eval) == len(poly_coeff) == len(poly_coeff_inversed)
2840
assert poly_coeff_inversed == poly_coeff
2941

42+
# second check: result of FFT are really the evaluations
43+
for i, w in enumerate(roots_of_unity):
44+
individual_evaluation = spec.evaluate_polynomialcoeff(poly_coeff, w)
45+
assert individual_evaluation == poly_eval[i]
46+
3047

3148
@with_eip7594_and_later
3249
@spec_test

0 commit comments

Comments
 (0)