Closed nicbus closed 4 months ago
Ok, I have finally figured out what's going on.
It is the only zero string which has significantly shorter Base58 encoding (32 chars instead of 43/44), so it doesn't has a valid chunking and fails to parse.
The issue is not trivial to solve: we need to refactor all the way the chunking works. For v0.11 I think the better way is to leave the things as they are: contract ids containing all-0 (or starting with at least 16 initial zeros to make length short enough to fail chunking) are all invalid anyway and can't be generated in a real-world scenarious.
I agree there's no urgency in fixing this.
After many attempts to fix it I was able to find an ultimate solution: switch from Base58 to Base64.
Base64 has constant size for a given source binary data - unlike Base58. The only disadvantage is the use of "/" and "-" symbols in standard encoding; but I did a modification to use "@" and "$" instead, and it seems to be working great.
I played with it in ssi
for identities and signatures (which we will use in RGB as well) and developed a dedicated baid64
crate to support URL prefixes, parsing, mnemonics etc, like we had in Baid58.
Switching to it in all develop
branches and will see how it will go.
Hi @dr-orlovsky,
May I try this? It is not an urgent issue, I can take this chance to learn more, go through the Contract stuff, and make more test cases.
Fixed by moving in beta-6 to baid64 encoding instead of baid58
Some values come up different after a
ContractId
round-trip.By round-trip I mean:
copy_from_slice
to_string
from_str
Here's an example:
This outputs:
The same error is returned by version
0.10.9
(usingfrom_slice
instead ofcopy_from_slice
).