5

I realize that the public address, which is 69 byte, is converted to base 58, but is not converted as a one large number, but rather each 8 bytes are converted separately.
What's the motivation for that?

9

The base58 encoding used in Bitcoin converts all the data to an integer, and then encodes it using divisions by 58. If there is a lot of data, the integer will get very big, which requires having a library dealing with bignums. And usually bignum operations (in this case bignum divisions) are not very fast.

Encoding the data by blocks of 8 bytes at most is much faster because you only have to manage 64-bit integer (a 64-bit integer division will be a single instruction on a 64-bit CPU).

It also allows knowing easily what the size of the encoded string or decoded data will be:

  • 8 bytes of data <=> 11 base58 characters
  • 7 bytes of data <=> 10 base58 characters
  • 6 bytes of data <=> 9 base58 characters
  • 5 bytes of data <=> 7 base58 characters
  • 4 bytes of data <=> 6 base58 characters
  • 3 bytes of data <=> 5 base58 characters
  • 2 bytes of data <=> 3 base58 characters
  • 1 byte of data <=> 2 base58 characters

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.