-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Bugfix in bn2vch: avoid excessive padding #18374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
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? |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
| ext = bytearray() | ||
| if v.bit_length() > 0: | ||
| have_ext = (v.bit_length() & 0x07) == 0 | ||
| if v.bit_length() > 0 && (v.bit_length() & 0x07) == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if v.bit_length() > 0 && (v.bit_length() & 0x07) == 0: | |
| if v.bit_length() > 0 and (v.bit_length() & 0x07) == 0: |
|
Closing in favor of #18378. |
a733ad5 Add bn2vch test to functional tests (Pieter Wuille) a3ad645 Simplify bn2vch using int.to_bytes (Pieter Wuille) Pull request description: Alternative to #18374, fixing the incorrect padding added sometimes in `bn2vch`. Since we're using Python 3.2+, a much simpler implementation of `bn2vch` is possible using `int.to_bytes`. This also adds a "functional" test for bn2vch, in a new "framework_test_script.py", where the "framework_test_" prefix is intended for tests of the framework itself. ACKs for top commit: laanwj: nice, ACK a733ad5 jnewbery: Tested ACK a733ad5. Tree-SHA512: aeacc4e7fd84279023d38e8b4a5175fb16d7b3a7f93c61b9dcb59cd9927547732983c76f28564b62e37088399fc0121b38a514d73b0ea38b3983836539e9ca90
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.