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
  1. theStack commented at 3:26 pm on September 12, 2025: 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).
  2. test: introduce group order byte-array constant for deduplication 0c91c56041
  3. real-or-random added the label assurance on Sep 12, 2025
  4. real-or-random added the label tweak/refactor on Sep 12, 2025
  5. real-or-random approved
  6. real-or-random commented at 3:52 pm on September 12, 2025: contributor
    utACK 0c91c5604130a56bb1628fd12c56edf60de966b0
  7. 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.

    0$ git grep "^static const"
    

    vs.

    0$ 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.

  8. furszy commented at 8:03 pm on September 12, 2025: member
    ACK 0c91c5604130a56bb1628fd12c56edf60de966b0
  9. jonasnick approved
  10. jonasnick commented at 7:28 am on September 15, 2025: contributor
    ACK 0c91c5604130a56bb1628fd12c56edf60de966b0
  11. jonasnick merged this on Sep 15, 2025
  12. jonasnick closed this on Sep 15, 2025


github-metadata-mirror

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: 2025-09-18 02:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me