Fix `zpad`

This commit is contained in:
Hsiao-Wei Wang 2019-02-01 22:31:00 +08:00
parent 8ffd9adcaf
commit dd197e46a6
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
1 changed files with 2 additions and 2 deletions

View File

@ -373,9 +373,9 @@ return typ(**values), item_index
The below `hash_tree_root_internal` algorithm is defined recursively in the case of lists and containers, and it outputs a value equal to or less than 32 bytes in size. For use as a "final output" (eg. for signing), use `hash_tree_root(x) = zpad(hash_tree_root_internal(x), 32)`, where `zpad` is a helper that extends the given `bytes` value to the desired `length` by adding zero bytes on the right:
```
```python
def zpad(input: bytes, length: int) -> bytes:
return input + b'\x00' * (length - len(input))`
return input + b'\x00' * (length - len(input))
```
Refer to [the helper function `hash`](https://github.com/ethereum/eth2.0-specs/blob/master/specs/core/0_beacon-chain.md#hash) of Phase 0 of the [Eth2.0 specs](https://github.com/ethereum/eth2.0-specs) for a definition of the hash function used below, `hash(x)`.