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).
test: introduce group order byte-array constant for deduplication #1745
pull theStack wants to merge 1 commits into bitcoin-core:master from theStack:test-refactor-dedup_scalar_byte_constants changing 3 files +13 −25-
theStack commented at 3:26 PM on September 12, 2025: contributor
-
test: introduce group order byte-array constant for deduplication 0c91c56041
- real-or-random added the label assurance on Sep 12, 2025
- real-or-random added the label tweak/refactor on Sep 12, 2025
- real-or-random approved
-
real-or-random commented at 3:52 PM on September 12, 2025: contributor
utACK 0c91c5604130a56bb1628fd12c56edf60de966b0
-
in src/testutil.h:15 in 0c91c56041
10 | @@ -11,6 +11,14 @@ 11 | #include "testrand.h" 12 | #include "util.h" 13 | 14 | +/* group order of the secp256k1 curve in 32-byte big endian representation */ 15 | +static const unsigned char secp256k1_group_order_bytes[32] = {
furszy commented at 4:41 PM on September 12, 2025: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.
theStack commented at 4:54 PM on September 12, 2025: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).
furszy commented at 7:00 PM on September 12, 2025: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.
furszy commented at 8:03 PM on September 12, 2025: memberACK 0c91c5604130a56bb1628fd12c56edf60de966b0
jonasnick approvedjonasnick commented at 7:28 AM on September 15, 2025: contributorACK 0c91c5604130a56bb1628fd12c56edf60de966b0
jonasnick merged this on Sep 15, 2025jonasnick closed this on Sep 15, 2025ContributorsLabels
This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-18 17:15 UTC
More mirrored repositories can be found on mirror.b10c.me