Closed acoglio closed 5 years ago
Some examples of the 5 kinds of invalid encodings mentioned above are at https://github.com/ethereum/tests/blob/develop/RLPTests/invalidRLPTest.json, in the "out" fields of the JSON objects with the following names:
Sorry @acoglio this subject is a little beyond my knowledge, I posted to some dev channels and no one has given any feedback. One other option if you feel strongly is to just make the change yourself in the wiki and someone else will likely tell you later if tat was a bad idea. Sometimes that's the best way to get an opinion 😆
@ChrisChinchilla Thanks, I'll make the change. What are the mechanics for making a change to this Wiki? I see no Edit button on the RLP Wiki page. Do I 'Clone it locally', edit RLP.md, and push?
@acoglio Gah, looks like permissions have changed then, we were getting too many unhelpful changes. Wikis work differently from normal repos. If it's OK with you, I'll make your changes then and credit you in the comments.
@ChrisChinchilla That's fine with me, thanks.
Besides the additions to the code above, we could also add the following paragraph just after the code:
Note that the decode_length
function rejects invalid encodings that have "non-optimal" lengths, namely (1) singleton strings whose only byte is below 128 that are encoded with a short (i.e. one-byte) length of 1 instead of as the strings themselves and (2) strings and lists with long (i.e. multi-byte) lengths with leading zeros (which must be absent) or below 56 (which should be encoded using short lengths).
Thanks, @ChrisChinchilla. By the way, the five # ADDED:
comment lines in the new code were only meant to show the added lines in this Issue, but were not meant to be part of the updated code in the Wiki. Would you mind removing them, when you get a chance? (I should have mentioned that earlier, sorry for the extra work.)
Ahhh @acoglio I wasn't sure, sorry. Will remove now.
Thanks, @ChrisChinchilla.
The reference code for RLP decoding in https://github.com/ethereum/wiki/wiki/RLP accepts the following kinds of invalid encodings:
These kinds of invalid encodings have been discussed in various places, e.g.:
I propose to add the lines preceded by
# ADDED:
below to the functiondecode_length
of the reference code for RLP decoding in the Wiki. These lines reject the invalid encodings described above.We could also add a paragraph to that Wiki page, just after the code, to explain that invalid encodings with "sub-optimal" lengths must be rejected.