Skip to content

Commit

Permalink
Merkleise SSZ container elements (#595)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JustinDrake committed Feb 12, 2019
1 parent f871b9a commit 3459515
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions specs/simple-serialize.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3459515

Please sign in to comment.