Hello,
I started to dig deeper into the implementation and stumbled over a small issue with the magnitudes.
From field_10x26_impl.h
, the function secp256k1_fe_verify
0 r &= (a->magnitude >= 0);
1 r &= (a->magnitude <= 32);
while in field_5x52_impl.h
the function is
0 r &= (a->magnitude >= 0);
1 r &= (a->magnitude <= 2048);
This means that multiplying a number with the constant value 100 is totally fine on a 64-bit machine, but will lead to an error on 32-bit machines, which IMHO is bad. The two implementation should have the same external interface.
Finally, is there a good reason for the 2 *
in the second line of secp256k1_fe_verify
? Why is the magnitude given in multiple of 2’s? Doesn’t the code work with odd magnitudes? This also means that one cannot express that magnitude should be 1 without having a fully normalized number.