Skip to content

Conversation

theStack
Copy link
Contributor

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 in testutil.h. Noticed while reviewing the sending tests of #1698, which also adds another instance (called ORDERC there), i.e. including this it would be 5 instances in total (maybe there are even more around that I missed due to insufficient greping).

Copy link
Contributor

@real-or-random real-or-random left a 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] = {
Copy link
Member

@furszy furszy Sep 12, 2025

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.

Copy link
Contributor Author

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).

Copy link
Member

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.

Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 0c91c56

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

Successfully merging this pull request may close these issues.

3 participants