Closed
Description
Specification
It turns out that not all base encodings maintain lexicographic-order. For example base64 and base58 have alphabets that do not preserve order.
After some random testing, I found that the existing test case fails very rarely: encoded multibase strings are lexically sortable
.
I believe this applies to the base encoding but not to the binary string encoding.
Therefore that test doesn't make sense, it makes more sense to identify which base encodings are lexicographic order, and create separate tests for those.
In our README.md it will be important to state that some base encodings will lose the lexicographic order, and provide a selection of the encodings that will maintain order.
Additional context
- https://www.codeproject.com/Articles/5165340/Sortable-Base64-Encoding - demonstrates why base64 is not suitable
- https://en.bitcoin.it/wiki/Base58Check_encoding - the base58btc alphabet - the base58btc alphabet should be in lexicographic order, however this is where the test error occurred
- Which of the multibase formats preserves lexicographic order? multiformats/js-multiformats#124 - question about this in multibase
Tasks
- - Devise a good test to test lexicographic order
- - Identify the base encodings that maintain order
- - Fix README.md
- - Ensure all PK uses of base encoded
IdSortable
should be using lexicographic order preserving base encodings if need be