As pointed out in issue #1472, currently the run_sqr
test doesn’t do anything with the result of the fe_sqr
call. Improve that by checking that the equation (x+y)*(x-y) = x^2 - y^2
holds for some random values y, as suggested by real-or-random in #1472 (comment). The existing loop for generating the x values is kept as-is, the sqr call on x is still included in each iteration on the course of calulating the RHS of the equation (secp256k1_fe_sqr(&rhs, &x);
).
The suggestion says “for random values y != 0
”, but I couldn’t see a good reason to exclude zero. Happy to apply s/random_fe_test/random_fe_non_zero_test/ if needed.