MatrixAI / js-id

ID generation for JavaScript & TypeScript Applications
https://polykey.com
Apache License 2.0
10 stars 1 forks source link

Add in a sortable base64 encoding from multibase #9

Open CMCDragonkai opened 3 years ago

CMCDragonkai commented 3 years ago

Is your feature request related to a problem? Please describe.

From this issue https://github.com/multiformats/js-multiformats/issues/124, it is clear that the highest sortable encoding right now in multibase is base32hex.

When using this for IdSortable, from 16 bytes, we get a encoded string length of 27 (v00qnlvl084e15mk9inn1en2gno). A higher base like base64 would be nicer as it could give us 23 characters instead.

There are 2 implementations of sortable base64.

Obviously what we would like is something that looks like base58btc as it is intended that such ids would be presented to the end user, and but get a guarantee that it is sortable.

Describe the solution you'd like

A human-centered readable encoding for IdSortable that is base64 (it has to be double of base32), that is sortable.

There's no existing standard for this except uuencode according to: https://stackoverflow.com/questions/53301280/does-base64-encoding-preserve-alphabetical-ordering#comment101660912_55011262

Describe alternatives you've considered

Additional context

Expect this to be used by notifications, sigchain and all the places we use IdSortable.

CMCDragonkai commented 3 years ago

@tegefaulkes this means base32hex needs to be used everywhere IdSortable is used atm.