GithubHelp home page GithubHelp logo

Comments (4)

sgeisler avatar sgeisler commented on June 19, 2024

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.

apoelstra avatar apoelstra commented on June 19, 2024

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.

sgeisler avatar sgeisler commented on June 19, 2024

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.

apoelstra avatar apoelstra commented on June 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.