@@ -47,6 +47,27 @@ When decoding Base64, implementations SHOULD accept input with or
4747without padding characters wherever possible, to ensure maximum
4848interoperability.
4949
50+ ## Binary data
51+
52+ In some cases it is necessary to encapsulate binary data, for example,
53+ public keys or signatures. Given that JSON cannot safely represent raw
54+ binary data, all binary values should be encoded and represented in
55+ JSON as unpadded Base64 strings as described above.
56+
57+ In cases where the Matrix specification refers to either opaque byte
58+ or opaque Base64 values, the value is considered to be opaque AFTER
59+ Base64 decoding, rather than the encoded representation itself.
60+
61+ It is safe for a client or homeserver implementation to check for
62+ correctness of a Base64-encoded value at any point, and to altogether
63+ reject a value which is not encoded properly. However, this is optional
64+ and is considered to be an implementation detail.
65+
66+ Special consideration is given for future protocol transformations,
67+ such as those which do not use JSON, where Base64 encoding may not be
68+ necessary in order to represent a binary value safely. In these cases,
69+ Base64 encoding of binary values may be skipped altogether.
70+
5071## Signing JSON
5172
5273Various points in the Matrix specification require JSON objects to be
0 commit comments