Skip to content

Magnitude in field implementation #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jhoenicke opened this issue Apr 15, 2015 · 1 comment
Closed

Magnitude in field implementation #240

jhoenicke opened this issue Apr 15, 2015 · 1 comment

Comments

@jhoenicke
Copy link

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

    r &= (a->magnitude >= 0);
    r &= (a->magnitude <= 32);

while in field_5x52_impl.h the function is

    r &= (a->magnitude >= 0);
    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.

@real-or-random
Copy link
Contributor

The first part is tracked in #1060, the second is now answered by comments in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants