diff --git a/BinaryEncoding.md b/BinaryEncoding.md index 57bd1a8f..342df9c7 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -53,6 +53,15 @@ represented by _at most_ ceil(_N_/7) bytes that may contain padding `0x80` or `0 Note: Currently, the only sizes used are `varint7`, `varint32` and `varint64`. +### Non-canonical LEB128 + +Both `varuintN` and `varintN` can be encoded with *non-canonical* LEB128 values where: + +* non-relevant zero `0x80` bytes are present in an over-large encoding; and / or +* non-relevant LEB128 bits (bits past the size) are ignored. + +The total number of bytes used to encode the `varuintN` / `varintN` cannot exceed the largest *canonical* encoding for that `varuintN` / `varintN`. + ## Language Types All types are distinguished by a negative `varint7` values that is the first byte of their encoding (representing a type constructor):