3 ms·
This seems quite convoluted just to avoid the "0 can be represented in more than one way" problem.
by RedShift1 4mo ago
This seems quite convoluted just to avoid the "0 can be represented in more than one way" problem.
- nine_k 4mo agoIt allows finding out the length (and allocating memory) after reading the first byte.
- ahoka 4mo agoI think it's neat.
- ape4 4mo agoComparing a number to zero is something that's done a lot
- Chaosvex 4mo agoTrue but also not particularly relevant?
- bjoli 4mo agoHaving all numbers be valid in only one way is a great idea. So much that I believe webassembly enforced canonical leb128, at the cost of decoding speed. And say you have it as part of some other data. If you want to be able to hash it by the raw memory bytes, many different ways to represent a number becomes a problem.
- matja 4mo ago> canonicality matters — for signatures, content-addressing, or any kind of “two implementations must agree on the bytes” property If you don't do this properly, you end up with things like: - SAML XSW attack due to XML signature wrapping - ASN.1 BER/DER signature forgery - Bitcoin transaction malleability attacks