From 5e4ccb42950a27fe9156564b0f04c5794be9a2b7 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Mon, 11 Mar 2024 09:15:33 -0300 Subject: [PATCH 1/2] eip6800: change tree key hashing Signed-off-by: Ignacio Hagopian --- EIPS/eip-6800.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/EIPS/eip-6800.md b/EIPS/eip-6800.md index 9e2ea69f065ecf..677cf59bf6ada9 100644 --- a/EIPS/eip-6800.md +++ b/EIPS/eip-6800.md @@ -42,7 +42,7 @@ def group_to_scalar_field(point: Point) -> int: if point == bandersnatch.Z: return 0 else: - return int.from_bytes(point.map_to_base_field().to_bytes(32, 'little'), 'little') % BANDERSNATCH_MODULUS + return point.map_to_base_field() % BANDERSNATCH_MODULUS def compute_commitment_root(children: Sequence[int]) -> Point: o = bandersnatch.Z @@ -139,13 +139,17 @@ def old_style_address_to_address32(address: Address) -> Address32: These are the positions in the tree at which block header fields of an account are stored. ``` +def hash_point_to_bytes(point: Point) -> int: + return group_to_scalar_field(point).to_bytes(32, 'little') + + def pedersen_hash(inp: bytes) -> bytes32: assert len(inp) <= 255 * 16 # Interpret input as list of 128 bit (16 byte) integers ext_input = inp + b"\0" * (255 * 16 - len(inp)) ints = [2 + 256 * len(inp)] + \ [int.from_bytes(ext_input[16 * i:16 * (i + 1)], 'little') for i in range(255)] - return compute_commitment_root(ints).serialize() + return compute_commitment_root(ints).hash_point_to_bytes() def get_tree_key(address: Address32, tree_index: int, sub_index: int): # Asssumes VERKLE_NODE_WIDTH = 256 @@ -298,4 +302,4 @@ Needs discussion. ## Copyright -Copyright and related rights waived via [CC0](../LICENSE.md). +Copyright and related rights waived via [CC0](../LICENSE.md). \ No newline at end of file From 0fe4bc4f8c5a603a2359c87aa03b56cefd52791e Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Mon, 11 Mar 2024 09:20:08 -0300 Subject: [PATCH 2/2] nits Signed-off-by: Ignacio Hagopian --- EIPS/eip-6800.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/EIPS/eip-6800.md b/EIPS/eip-6800.md index 677cf59bf6ada9..6e74f718ae77d5 100644 --- a/EIPS/eip-6800.md +++ b/EIPS/eip-6800.md @@ -141,7 +141,6 @@ These are the positions in the tree at which block header fields of an account a ``` def hash_point_to_bytes(point: Point) -> int: return group_to_scalar_field(point).to_bytes(32, 'little') - def pedersen_hash(inp: bytes) -> bytes32: assert len(inp) <= 255 * 16 @@ -302,4 +301,4 @@ Needs discussion. ## Copyright -Copyright and related rights waived via [CC0](../LICENSE.md). \ No newline at end of file +Copyright and related rights waived via [CC0](../LICENSE.md).