From 3459515c2c96f3da06594e04e82920a47fa68b06 Mon Sep 17 00:00:00 2001 From: Justin Date: Tue, 12 Feb 2019 21:57:54 +0000 Subject: [PATCH] Merkleise SSZ container elements (#595) Reasons to use `merkle_hash` instead of `hash` for containers: 1) **Smaller witnesses**: `BeaconState` is a somewhat wide container (26 fields as of now, likely 30+ in phase 2). With concatenation and plain concatenation the size of the Merkle witnesses for the top level are ~32 bytes per field element. 2) **Faster incremental hashing** 3) **Consistency**: Consistent with `merkle_hash` for lists/vectors. --- 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 d4bd9e78d..c71654b67 100644 --- a/specs/simple-serialize.md +++ b/specs/simple-serialize.md @@ -390,10 +390,10 @@ Where the inner `hash_tree_root_internal` is a recursive application of the tree #### Container -Recursively tree hash the values in the container in the same order as the fields, and return the hash of the concatenation of the results. +Recursively tree hash the values in the container in the same order as the fields, and Merkle hash the results. ```python -return hash(b''.join([hash_tree_root_internal(getattr(x, field)) for field in value.fields])) +return merkle_hash([hash_tree_root_internal(getattr(x, field)) for field in value.fields]) ``` ## Implementations