Comments (4)
After thinking about this problem more thoroughly I suspect that you can't do arbitrary base conversions in constant space. For the first character one had to calculate the number represented by the byte string divided by 58^n which doesn't seem doable in constant space (and reasonable time). I spoke with @sipa about that and he shares my doubt, but he also suggested a solution to avoid allocations:
We could just decide on a maximum expected length (which should be possible for our use case) and use a (stack) array of that size.
from rust-bitcoin.
I think that's reasonable. I think the longest thing we might base58-encode are BIP32 xpubs which are 78 bytes.. we could go way past that, to be certain, but probably a couple hundred bytes are fine (and maybe we would fall back to the allocation-based method rather than failing if we exceeded this)
from rust-bitcoin.
If we want to keep our base58 encoding functionality public then we probably should fallback to using a vector, panicking public interfaces aren't nice. And I guess there are downstream users of this API :/ (although I don't really see a use case that would concern our user base since all bitcoin related usages of base58 are implemented in rust-bitcoin).
from rust-bitcoin.
Well, Elements' confidential addresses use base58 encoding for example...it happens that they're shorter (64 bytes) than an xpub, but they just as easily could've been longer.
from rust-bitcoin.
Related Issues (20)
- `master` still has version set to `0.32.0-rc1` HOT 4
- `Script` should have accessors for hashes embedded in scriptpubkeys
- How to recover address from txn witness data? HOT 7
- ci: Consider shellcheck for bash/shell scripts linting HOT 5
- Support for testnet4 HOT 7
- Implement `ZERO_NORMAL` and `ZERO_HARDENED` constants (and variants for `ONE`) for BIP 32
- Implement constants for `PsbtSighashType` HOT 5
- `derive_xpriv` should not return a `Result` HOT 2
- Consider removing `just sane`
- `PartialOrd`/`Ord` on`CompactTarget` (and `block::Header`) are surprising
- Remove shebang from all shell scripts that are not meant to be run HOT 3
- `io::Write` is incompatible with `std::io::Write` HOT 3
- Update `.github/workflows/README.md` to mention shellcheck job
- Silent payments addresses (BIP352) HOT 10
- Make `consensus::encode` private
- `difficulty_float` is hardcoded to mainnet HOT 1
- 0.32 loses a bunch of functionality in `Address` HOT 22
- CI: Schemars job can use `extra_tests.sh` HOT 1
- How to get sighash_type from a transaction? HOT 8
- Are we enforcing the 520 stack element limit for segwit transactions? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-bitcoin.