Varints must be as short as possible to be canonical

This commit is contained in:
Tony Garnock-Jones 2019-10-08 13:43:58 +01:00
parent fe8c766d1e
commit 8aaec11635
2 changed files with 6 additions and 0 deletions

View File

@ -26,6 +26,8 @@ Annotations MUST NOT be present.
Placeholders MUST NOT be used.
Where possible, fixed-length ("format A") MUST be used in preference
to variable-length ("format B") formats.
Lengths in variable-length encodings (base 128 varints) MUST be as
short as possible.
**Signed integers.**
When a `SignedInteger` *n* is greater than or equal to -3 and less

View File

@ -516,6 +516,10 @@ The following table illustrates varint-encoding.
| 300 | `0000010 0101100` | 172 2 |
| 1000000000 | `0000011 1011100 1101011 0010100 0000000` | 128 148 235 220 3 |
It is an error for a varint-encoded `m` in a `Repr` to be anything
other than the unique shortest encoding for that `m`. That is, a
varint-encoding of `m` *MUST NOT* end in `0` unless `m`=0.
#### Streaming data of unknown length (format C).
A `Repr` where the length of the `Value` to be encoded is variable and