-
Notifications
You must be signed in to change notification settings - Fork 1k
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
secp256k1_fe_set_b32_mod doesn't actually reduce anything #1453
Comments
You're right that the function In short, So the only difference between |
Wouldn't it be better to rename the methods to something like |
Well, bike shedding is always possible, but I think the names are okay. If anything, Perhaps the docs can be marginally improved. I see that this can be misleading.
It's more like this: And the other one:
Perhaps: |
@Coding-Enthusiast I'd be happy to review a PR which implements (variants of) these suggestions. |
3928b7c doc: improve secp256k1_fe_set_b32_mod doc (Coding Enthusiast) Pull request description: As discussed in #1453 This only changes the `secp256k1_fe_impl_set_b32_mod` comment since I think `secp256k1_fe_set_b32_limit` doc is clear enough. ACKs for top commit: sipa: ACK 3928b7c theStack: ACK 3928b7c Tree-SHA512: ad62c1b72d6a487473b182e6aadc7765711385add8c6576bf15c2015db82721f19e3d635f7a29316c2ee7e3c73bc55e2cd4f46ec13180be93d6fe8641f47e7d2
secp256k1_fe_set_b32_mod
method name and comment suggest that it reduces the value mod p and the result is supposed to ber ≡ a (mod p)
secp256k1/src/field.h
Lines 187 to 192 in d3e29db
However looking at the implementations they don't actually perform any reduction. It's just a simple conversion from byte[] to uint[] in radix 26 or 52.
secp256k1/src/field_impl.h
Lines 270 to 277 in d3e29db
secp256k1/src/field_10x26_impl.h
Lines 293 to 304 in d3e29db
secp256k1/src/field_5x52_impl.h
Lines 235 to 270 in d3e29db
After this change the old method (
secp256k1_fe_set_b32_limit
) is still used in most places except something like this5b32602#diff-6f71b0372be086d45b4f2740508c03a21835d87008840032fbb767f419fd988a
And it just assumes
secp256k1_fe_set_b32_mod
reduces the result while it doesn't.@sipa
The text was updated successfully, but these errors were encountered: