From e984d10a0cc3b19fc9c03b9ef731a0ccac5dc6b6 Mon Sep 17 00:00:00 2001 From: protolambda Date: Fri, 25 Oct 2019 12:02:12 +0200 Subject: [PATCH] fix typo, and fix bitlist end-bit description --- specs/simple-serialize.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/simple-serialize.md b/specs/simple-serialize.md index 6e250fd81..fdd5a26ca 100644 --- a/specs/simple-serialize.md +++ b/specs/simple-serialize.md @@ -129,7 +129,7 @@ return bytes(array) ### `Bitlist[N]` -Note that from the offset coding, the length (in bytes) of the bitlist is known. An additional `1` bit is added at position `N` where `N` is the legnth of the bitlist so that the length in bits will also be known. +Note that from the offset coding, the length (in bytes) of the bitlist is known. An additional `1` bit is added to the end, at index `e` where `e` is the length of the bitlist (not the limit), so that the length in bits will also be known. ```python array = [0] * ((len(value) // 8) + 1) @@ -179,7 +179,7 @@ Deserialization can be implemented using a recursive algorithm. The deserializat * Using the first offset, we can compute the length of the list (divide by `BYTES_PER_LENGTH_OFFSET`), as it gives us the total number of bytes in the offset data. * The size of each object in the vector/list can be inferred from the difference of two offsets. To get the size of the last object, the total number of bytes has to be known (it is not generally possible to deserialize an SSZ object of unknown length) * Containers follow the same principles as vectors, with the difference that there may be fixed-size objects in a container as well. This means the `fixed_parts` data will contain offsets as well as fixed-size objects. -* In the case of bitlists, the length in bits cannot be uniquely inferred from the number of bytes in the object. Because of this, they have a bit in position `N` where `N` is the length of the list that is always set. This bit has to be used to infer the size of the bitlist in bits. +* In the case of bitlists, the length in bits cannot be uniquely inferred from the number of bytes in the object. Because of this, they have a bit at the end that is always set. This bit has to be used to infer the size of the bitlist in bits. Note that deserialization requires hardening against invalid inputs. A non-exhaustive list: