Canonical Base64 in SSB data types
When decoding base64 data, in some cases the last few bits don't encode any data. The rfc mandates those to be zero bits. Node helpfully decodes noncanonical data anyways:
> Buffer.from("iYW=", "base64") // Not canonical, last bits are `10` rather than `00`
<Buffer 89 85>
> Buffer.from("iYU=", "base64") // Canonical representation of the data
<Buffer 89 85>
Ssb-ref doesn't check for canonicity either.
As a result, ssb currently accepts multiple encodings for a single public key/hash/signature/encrypted message content. This means that implementations can't just parse incoming messages and handle the actual data. For correct signature-and-hash-preserving re-serialization, they also need to store details about the possibly noncanonical encoding. It's not that bad (only a single byte of data) per base64 encoded chunk, but it's definitely weird.
So instead I'd like to specify that all the base64 used in the ssb protocols MUST be canonical and invalid base64 MUST be rejected. @Dominic, is that ok?