Generalize ConvertBits a bit to also be usable for the existing Base32 and Base64 convertions (rather than just for Bech32).
Simplify Base32 and Base64 conversions #11630
pull sipa wants to merge 2 commits into bitcoin:master from sipa:201711_simpleconvert changing 5 files +69 −254-
sipa commented at 10:26 PM on November 7, 2017: member
-
meshcollider commented at 10:46 PM on November 7, 2017: contributor
Impressive simplification, Concept ACK
- fanquake added the label Refactoring on Nov 7, 2017
-
fanquake commented at 12:33 AM on November 8, 2017: member
All Travis failures seem to be the same issue in signmessages.py
self.run_test() File "/home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-unknown-linux-gnu/test/functional/signmessages.py", line 24, in run_test assert(self.nodes[0].verifymessage(address, signature, message)) File "/home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-unknown-linux-gnu/test/functional/test_framework/coverage.py", line 47, in __call__ return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs) File "/home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-unknown-linux-gnu/test/functional/test_framework/authproxy.py", line 138, in __call__ raise JSONRPCException(response['error']) test_framework.authproxy.JSONRPCException: Malformed base64 encoding (-5) 2017-11-07 23:50:01.876000 TestFramework (INFO): Stopping nodes 2017-11-07 23:50:01.877000 TestFramework.node0 (DEBUG): Stopping node - sipa force-pushed on Nov 8, 2017
-
in src/utilstrencodings.cpp:231 in 8059735f50 outdated
286 | - vchRet.push_back((left<<5) | dec); 287 | - mode = 0; 288 | - break; 289 | - } 290 | + const char* e = p; 291 | + std::vector<uint8_t> val;
promag commented at 8:40 PM on November 8, 2017:Any reason to not reserve? Doesn't pay off?
in src/utilstrencodings.cpp:252 in 8059735f50 outdated
336 | + valid = false; 337 | + break; 338 | } 339 | + ++p; 340 | + } 341 | + valid = valid && (p - e) % 8 == 0 && p - q < 8;
promag commented at 10:53 PM on November 8, 2017:Not sure but isn't
(p - e) & 7 == 0faster? Or does the compiler optimise this case?
sipa commented at 2:04 AM on November 17, 2017:Strength reduction will do that for you at -O1 and higher.
sipa force-pushed on Nov 23, 2017TheBlueMatt commented at 5:18 PM on December 8, 2017: memberutACK 16a01bf1a2a318effbbac4a22f1092fee1924dc8. Would be nice to add these folks to test_bitcoin_fuzzy.cpp!
laanwj commented at 10:59 PM on March 1, 2018: memberutACK. Needs rebase in src/utilstrencodings.cpp.
laanwj added this to the milestone 0.17.0 on Mar 5, 2018sipa force-pushed on Mar 5, 2018sipa commented at 9:57 PM on March 5, 2018: memberRebased.
in src/utilstrencodings.cpp:165 in eb59db5a30 outdated
197 | - break; 198 | - } 199 | + const char* e = p; 200 | + std::vector<uint8_t> val; 201 | + while (*p != 0) { 202 | + int x = decode64_table[(unsigned char)*p];
laanwj commented at 10:19 PM on March 5, 2018:It seems a bit of a pity to allocate and fill an intermediate vector here, which is just the contents of the string mapped through
decode64_table. Could we maybe wrap the iterator to weave this into ConvertBits? (to be clear, this could be done later, no need to do so in this PR, but as the rest of the changes is so elegant it just jumped out)
Generalize ConvertBits 3296a3bb7fsipa force-pushed on Mar 7, 2018sipa commented at 4:30 AM on March 7, 2018: memberRebased.
sipa force-pushed on Mar 7, 2018sipa commented at 2:58 PM on March 7, 2018: memberAdded reserves in several places.
Simplify Base32 and Base64 conversions b3ea8ccb7asipa force-pushed on Mar 7, 2018laanwj commented at 3:23 PM on March 7, 2018: memberAdded reserves in several places.
Thanks!
utACK b3ea8ccb7af475703b97246a2baf2e105d24d6f9
laanwj merged this on Mar 7, 2018laanwj closed this on Mar 7, 2018laanwj referenced this in commit da9a2f5cd9 on Mar 7, 2018zkbot referenced this in commit 771aee5d88 on Jun 11, 2018zkbot referenced this in commit 2ebde5860e on Jun 19, 2018deadalnix referenced this in commit c8254da60e on Apr 16, 2020deadalnix referenced this in commit 9fa8a6f08e on Apr 16, 2020ftrader referenced this in commit 89c22648bc on Aug 17, 2020ftrader referenced this in commit e37bdbcc06 on Aug 17, 2020UdjinM6 referenced this in commit ae0d180ef5 on Dec 25, 2020UdjinM6 referenced this in commit fbb40717b4 on Jan 8, 2021MarcoFalke locked this on Sep 8, 2021
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:15 UTC
More mirrored repositories can be found on mirror.b10c.me