How to handle leading 0's (b58 1's) when base58check encoding I'm trying to more fully understand the base58check encoding algorithm.
Unfortunately, I keep running into a problem with how to handle a situation where the base58 value of an input would have leading 0's (1's in base58).
Everywhere I find any information about this online, it simply states that &quot;the data is encoded to avoid having leading 0s, except to represent full '0' bytes in then input.&quot;
What I need to understand is:
What is changed in the data (input or output) to avoid/correct this situation in the output string?
Iterate from the beginning until you reach a non-zero byte. Base58 encode the non-zero byte and the following, and add 1s before the base58 string you made for each initial one zero byte (0x00) you counted.
Zero bytes after the first non-zero byte don't need special treatment.
For example, [0, 13, 36], is encoded as 1211 since the value is 1*58^2 and 1 in base58 alphabet is 2. From here, you see that if it's a multiple of 58, no special treatment is needed since the encoding is big endian and the 1s caused by 58's powers are automatically appended to the back