-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Remove dependency of base58 on OpenSSL #4048
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
|
👍 |
|
@gmaxwell we can be sure about that. DecodeBase58 is only called from two places in base58.h itself:
In general I too prefer APIs that explicitly pass the length of strings (or that use a string type with embedded length field like std::string), but it doesn't look like there is reason to change the API here. |
|
:) Yea the "will" was meant to include all future callers. Communication is hard. |
|
Right. It's especially useful to pass a length - or an begin* and end* pointer - if we want to be able to error out on NULs before the real end of the string (whose presence has triggered many browser bugs). It would also allow using std::string.data() and std::string.size() instead of c_str(), which is theoretically slighty more efficient. Good to keep in mind, but let's not change the API and implementation at the same time, it would interfere with testing :) The code looks straightforward and correct to me. It passes the tests and we have a fairly good testing suite in place for the Base58 functions. |
|
Why reimplement DecodeBase58 and contribute to the current de-modularisation? Seems like a better idea to move libblkmaker's base58.c to its own library and add an encoder... |
|
A library for 74 lines of trivial code? It's kind of an odd duck, in that I don't know what else I'd put in a library with it except 'generic bitcoin stuff'. |
|
We definitely should move the Base58 stuff to a library when we library-ize Bitcoin Core. It's one of the useful functions for other projects. Removing the dependency on OpenSSL helps there, too. However I certainly don't want to add a dependency on an external library for this (trivial) functionality. |
|
@gmaxwell Everything needed to create a raw transaction spending to an address? :) |
src/base58.cpp
Outdated
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.
I'd say 'leading zeroes'
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.
Done.
|
@laanwj: I agree that the interface is dangerous (and inconsistent too... mixing c++ style and c style strings/iteration). I'd like to replace that, but let's do that separately. I've addresses your comments too. |
|
ACK |
|
Needs rebase after #4014 (should be easy as it only affected comments) |
|
Rebased. |
src/base58.cpp
Outdated
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.
std::vector<unsigned char> b256(strlen(psz) * 733 / 1000 + 1)
Would avoid a realloc.
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.
I don't think empty-constructed vector do any allocation. Still, it can be written in one line.
|
Sorry for the late review, I was pinged from one of my PRs so I figured I'd give it a quick look :) |
|
Pushed an update to address @theuni's comments. |
This removes the bignum/OpenSSL dependency. The base58 transformation code is also moved to a separate .cpp file.
|
Thought I ACKed this already. |
Remove dependency of base58 on OpenSSL
|
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/b58be132c994b6f9b25cb4a702186ef96104953f for binaries and test log. |
After bitcoin#4076, bitcoin#3965 and bitcoin#4048 bignum.h is only used for verifying scriptnum.
This completely removes the bignum-based base58 code, and replaces it with an implementation that directly operates on vectors of bytes / base58 numbers.