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.

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

  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

  13. fanquake referenced this in commit 42c7d35d3a on Oct 14, 2025
  14. fanquake referenced this in commit 3cbf7cb3e6 on Oct 15, 2025
  15. Sjors referenced this in commit d5660d3a13 on Feb 16, 2026
  16. github-actions[bot] referenced this in commit c3f80fff5f on Mar 1, 2026
  17. github-actions[bot] referenced this in commit 4aeff8400e on Mar 1, 2026
  18. github-actions[bot] referenced this in commit 5f15eb0c55 on Mar 1, 2026
  19. 0x000000000019d6689c085ae165831e934ff76 referenced this in commit d54574beca on Mar 2, 2026
  20. csjones referenced this in commit fb3e16af04 on Mar 2, 2026
  21. real-or-random referenced this in commit 56751a4cf0 on Mar 2, 2026
  22. 0x000000000019d6689c085ae165831e934ff76 referenced this in commit 924c279a64 on Mar 2, 2026
  23. csjones referenced this in commit bf90997db1 on Mar 2, 2026
  24. vmta referenced this in commit 1ddc2f947f on Apr 26, 2026
  25. vmta referenced this in commit 56c40fe100 on Apr 27, 2026

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: 2026-05-19 06:52 UTC