using ParseBase58 as an example, values should round-trip properly back to their original value, or error.
ok := "npL6MjP8Qfc" //0x7fffffffffffffff
bad1 := "npL6MjP8Qfd" //0x7fffffffffffffff + 1 // overflows int64 and becomes negative
bad2 := "JPwcyDCgEuq" //0xffffffffffffffff + 1 // overflows uint64 and wraps back to 1
in the case of bad1 it parses "successfully" and returns a negative value, which later panics when Base58() cannot convert it back to a string (it doesn't handle negative cases). It should error on parsing, or negatives should be supported throughout (or the base type should be uint64).
in the case of bad2 it parses "successfully" and returns a value of 1, which base58() does not encode back to the original number, obviously. it should probably error because the original number is not valid.
These issues can come up when accepting requests with bad IDs from clients, and they should not be accepted as valid ids.
using
ParseBase58
as an example, values should round-trip properly back to their original value, or error.These issues can come up when accepting requests with bad IDs from clients, and they should not be accepted as valid ids.