-
Notifications
You must be signed in to change notification settings - Fork 1.1k
test: introduce group order byte-array constant for deduplication #1745
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
base: master
Are you sure you want to change the base?
test: introduce group order byte-array constant for deduplication #1745
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 0c91c56
@@ -11,6 +11,14 @@ | |||
#include "testrand.h" | |||
#include "util.h" | |||
|
|||
/* group order of the secp256k1 curve in 32-byte big endian representation */ | |||
static const unsigned char secp256k1_group_order_bytes[32] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny q: why not use capital letters for a constant?
It’s usually the convention to distinguish functions vs constants so we don't have to search for its definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair question. It seems that we use capital letters mainly for constants and macros defined with the preprocessor (i.e. #define ...
), where as actual global constant objects are still in lowercase, see e.g.
$ git grep "^static const"
vs.
$ git grep "^#define"
Maybe it's worth it to add that to the style conventions section in CONTRIBUTING.md (and fix the few exceptions that don't follow this conventions, e.g. SECP256K1_SIGNED{30,62}_ONE
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don’t you feel this is one of those things so widely accepted that it’s strange to have to formally state it? It’s like seeing someone write class members in capital letters.
In any case, it was a tiny question anyway. The upside of this change is that we can script any future change, since everything uses the same variable now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 0c91c56
Several tests currently define their own byte arrays containing the secp256k1 group order$n$ (=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141) in 32-byte big endian representation. This PR deduplicates those by introducing a
secp256k1_group_order_bytes
constant intestutil.h
. Noticed while reviewing the sending tests of #1698, which also adds another instance (calledORDERC
there), i.e. including this it would be 5 instances in total (maybe there are even more around that I missed due to insufficientgrep
ing).