Bitcoin full node and query server

Nov 15, 2018

View in context in the libbitcoin Slack #general mirror.

evoskuil12:19
Since “1” is also the zeroth position in the base58 chars array the result of the pack would have to be zero to select it. This is precluded as a leading character by stripping the leading zero bytes. It can occur later in the encoding however.
3 replies · Mlmikael · last Nov 15, 2018
M
Mlmikael12:45
@evoskuil I still don't see why the base58 encoding could not produce a leading "1" character.
M
Mlmikael13:45
@evoskuil https://files.esotericnonsense.com/public/base58.txt I think I see now, base58 is analogous to decimal string serialization, and the "1" character is used as zero. As you go through the input - which is viewed as a number - you're serializing in an order from right to left, and, the definition of reaching the leftmost point is that your DIV 58 and MOD 58 suddenly give ZERO! ..at which point you STOP SERIALIZING So the reason you don't get any leading "1" char as significant base58 data is exactly that, that a leading "1" means "serialization is over".
M
Mlmikael13:46
So it's like doing decimal serialization of the value "000002356" - when you did the DIV 10, MOD 10 work for 2356, what you have left is ZERO, which will give DIV 10 = 0 and MOD 10 = 0 and these will kick you out of the serialization loop.