Bugfix in bn2vch: avoid excessive padding #18374

pull sipa wants to merge 1 commits into bitcoin:master from sipa:202003_fix_bn2vch changing 1 files +2 −2
  1. sipa commented at 5:46 AM on March 18, 2020: member

    It seems #17319 introduced an (unobserved) bug in the test framework in bn2vch: a zero padding byte was added for every nonzero number, even when the top byte was <= 0x7F. Fix this.

  2. sipa commented at 5:46 AM on March 18, 2020: member

    I'm happy to add a quick test case for this, but I don't see any obvious place to put a test of the test framework itself. Any suggestions?

  3. fanquake added the label Tests on Mar 18, 2020
  4. in test/functional/test_framework/script.py:36 in 812340c395 outdated
      32 | @@ -33,6 +33,7 @@ def bn2vch(v):
      33 |      ext = bytearray()
      34 |      if v.bit_length() > 0:
      35 |          have_ext = (v.bit_length() & 0x07) == 0
      36 | +    if have_ext:
    


    kallewoof commented at 6:00 AM on March 18, 2020:

    Alternative

    if v.bit_length() > 0 and (v.bit_length() & 0x07) == 0:
        have_ext = True
        ext.append(0)
    

    sipa commented at 7:20 AM on March 18, 2020:

    Thanks, much better indeed.

  5. Bugfix in bn2vch: avoid excessive padding f65868baa9
  6. sipa force-pushed on Mar 18, 2020
  7. DrahtBot commented at 7:44 AM on March 18, 2020: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #17977 ([WIP] Implement BIP 340-342 validation (Schnorr/taproot/tapscript) by sipa)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  8. in test/functional/test_framework/script.py:34 in f65868baa9
      30 | @@ -31,8 +31,8 @@ def bn2vch(v):
      31 |      # isn't a spare bit in the bit length, add an extension byte.
      32 |      have_ext = False
      33 |      ext = bytearray()
      34 | -    if v.bit_length() > 0:
      35 | -        have_ext = (v.bit_length() & 0x07) == 0
      36 | +    if v.bit_length() > 0 && (v.bit_length() & 0x07) == 0:
    


    MarcoFalke commented at 1:47 PM on March 18, 2020:
        if v.bit_length() > 0 and (v.bit_length() & 0x07) == 0:
    
  9. sipa commented at 5:23 PM on March 18, 2020: member

    Closing in favor of #18378.

  10. sipa closed this on Mar 18, 2020

  11. laanwj referenced this in commit 67de1ee8bc on Mar 19, 2020
  12. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-19 09:14 UTC

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