From 8176cc4cf0c9eaee68abbf24ca4344dd1fac90e1 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Wed, 27 Feb 2019 22:23:42 +0100 Subject: [PATCH] Apply suggestions from code review Co-Authored-By: JustinDrake --- specs/simple-serialize.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/specs/simple-serialize.md b/specs/simple-serialize.md index e2ce4f208..221a48144 100644 --- a/specs/simple-serialize.md +++ b/specs/simple-serialize.md @@ -43,23 +43,23 @@ For convenience we alias: ## Serialization -We reccursively define the `serialize` function which consumes an object `value` (of the type specified) and returns a byte string of type `bytes`. +We recursively define the `serialize` function which consumes an object `value` (of the type specified) and returns a byte string of type `bytes`. -#### `uintN` +### `uintN` ```python assert N in [8, 16, 32, 64, 128, 256] return value.to_bytes(N // 8, 'little') ``` -#### `bool` +### `bool` ```python assert value in (True, False) return b'\x01' if value is True else b'\x00' ``` -#### Containers, tuples, lists +### Containers, tuples, lists ```python serialized_bytes = ''.join([serialize(element) for element in value]) @@ -79,7 +79,7 @@ We first define helper functions: * `pack`: Given ordered objects of the same basic type, serialize them, pack them into 32-byte chunks, right-pad the last chunk with zero bytes, and return the chunks. * `merkleize`: Given ordered 32-byte chunks, right-pad them with zero chunks to the next power of two, Merkleize the chunks, and return the root. -* `mix_in_length`: Given a Merkle root `root` and a length `length` (32-byte little-endian serialization) return `hash(root + length)`. +* `mix_in_length`: Given a Merkle root `root` and a length `length` (`uint256` little-endian serialization) return `hash(root + length)`. We now define Merkleization `hash_tree_root(value)` of an object `value` recursively: