Skip to content

Commit

Permalink
eip6800: change tree key hashing
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
  • Loading branch information
jsign committed Mar 11, 2024
1 parent af04410 commit 5e4ccb4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions EIPS/eip-6800.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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).

Check failure on line 305 in EIPS/eip-6800.md

View workflow job for this annotation

GitHub Actions / Markdown Linter

Files should end with a single newline character

EIPS/eip-6800.md:305:61 MD047/single-trailing-newline Files should end with a single newline character

0 comments on commit 5e4ccb4

Please sign in to comment.