Ensure safety of ctz_debruijn implementation. #1194

pull roconnor-blockstream wants to merge 1 commits into bitcoin-core:master from roconnor-blockstream:20230116_debruijn changing 1 files +2 −2
  1. roconnor-blockstream commented at 3:21 AM on January 17, 2023: contributor

    Adding U to the magic constants ensures that we are not mixing unsigned and signed value during multiplication, and ensures that the multiplication will not be subject to integer promotion.

    The (uint32_t)/(uint64_t) casts ensure the values are properly truncated no matter the size of an int.

    Prior to this commit, if secp256k1_ctz32_var_debruijn were some how managed to be built on a platform with 64-bit ints, (though this function is specifically only intended to be used on 32-bit platforms) it would perform an out-of-bounds array access.

  2. Ensure safety of ctz_debruijn implementation.
    Adding U to the magic constants ensures that we are not mixing unsigned and signed value during multiplication, and ensures that the multiplication will not be subject to integer promotion.
    
    The (uint32_t)/(uint64_t) casts ensure the values are properly truncated no matter the size of an int.
    
    Prior to this commit, if secp256k1_ctz32_var_debruijn were some how managed to be built on a platform with 64-bit ints, (though this function is specifically only intended to be used on 32-bit platforms) it would perform an out-of-bounds array access.
    d6ff738d5b
  3. roconnor-blockstream force-pushed on Jan 17, 2023
  4. real-or-random approved
  5. real-or-random commented at 8:30 AM on January 17, 2023: contributor

    utACK d6ff738d5bbdf965590fc07efca23b13c0ea3082

    a platform with 64-bit ints

    be aware that our code base will most likely explode in a lot of ways on such a platform

  6. apoelstra approved
  7. apoelstra commented at 7:29 PM on January 17, 2023: contributor

    ACK d6ff738d5bbdf965590fc07efca23b13c0ea3082

  8. real-or-random merged this on Jan 18, 2023
  9. real-or-random closed this on Jan 18, 2023

  10. roconnor-blockstream deleted the branch on Jan 18, 2023
  11. dhruv referenced this in commit 4d33046ce3 on Feb 1, 2023
  12. dhruv referenced this in commit 55e7f2cf2b on Feb 2, 2023
  13. stratospher referenced this in commit 647f63669e on Feb 6, 2023
  14. dhruv referenced this in commit a4351c0df6 on Feb 20, 2023
  15. stratospher referenced this in commit 23f825fc8b on Feb 21, 2023
  16. hebasto referenced this in commit 7c0cc5d976 on Mar 7, 2023
  17. dhruv referenced this in commit a5df79db12 on Mar 7, 2023
  18. dhruv referenced this in commit 77b510d84c on Mar 7, 2023
  19. sipa referenced this in commit 763079a3f1 on Mar 8, 2023
  20. div72 referenced this in commit 945b094575 on Mar 14, 2023
  21. vmta referenced this in commit e1120c94a1 on Jun 4, 2023
  22. vmta referenced this in commit 8f03457eed on Jul 1, 2023

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-04-14 18:15 UTC

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