py_ecc icon indicating copy to clipboard operation
py_ecc copied to clipboard

Test and bugfix equality testing with different degree polynomials.

Open carver opened this issue 6 years ago • 1 comments

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

carver avatar Jan 21 '19 22:01 carver

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).

Bhargavasomu avatar Mar 04 '19 19:03 Bhargavasomu