From 109250b963e7314a78b009985fa99e1bf80eff1f Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Mon, 22 Aug 2022 15:59:39 +0800 Subject: [PATCH] Replace `hash_tree_root(x)` with `hash(ssz_serialize(x))` --- setup.py | 1 + specs/eip4844/validator.md | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 484861b85..72b011f47 100644 --- a/setup.py +++ b/setup.py @@ -586,6 +586,7 @@ class EIP4844SpecBuilder(BellatrixSpecBuilder): return super().imports(preset_name) + f''' from eth2spec.utils import kzg from eth2spec.bellatrix import {preset_name} as bellatrix +from eth2spec.utils.ssz.ssz_impl import serialize as ssz_serialize ''' @classmethod diff --git a/specs/eip4844/validator.md b/specs/eip4844/validator.md index 7d4f0b351..6c4e893f9 100644 --- a/specs/eip4844/validator.md +++ b/specs/eip4844/validator.md @@ -93,9 +93,10 @@ def is_data_available(slot: Slot, beacon_block_root: Root, blob_kzg_commitments: ```python def hash_to_bls_field(x: Container) -> BLSFieldElement: """ - This function is used to generate Fiat-Shamir challenges. The output is not uniform over the BLS field. + Compute 32-byte hash of serialized container and convert it to BLS field. + The output is not uniform over the BLS field. """ - return int.from_bytes(hash_tree_root(x), "little") % BLS_MODULUS + return int.from_bytes(hash(ssz_serialize(x)), "little") % BLS_MODULUS ``` ### `compute_powers`