py_ecc
py_ecc copied to clipboard
Test and bugfix equality testing with different degree polynomials.
What is wrong?
If I read the current implementation of FQP.__eq__ correctly, it returns True for this test:
FQP([1, 2, 3], ...) == FQP([1, 2], ...)
which seems wrong.
In the current implementation, zip terminates on the shorter list, and there's no explicit length/degree check.
How can it be fixed
Add tests for related scenarios, and make sure implementation is correct.
Also, because of the type checking involved, make sure that the equality test is commutative when the class is different, like:
fq2_a = FQP([2, 3], (1, 0))
fq2_b = FQ2([2, 3], (1, 0))
assert fq2_a == fq2_b
assert fq2_b == fq2_a
As an extension to this issue, it would ideally be better, if all the places in the code where the zip function is used be tested in some way (probably unittests).