Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EIP-6800: change tree key hashing #8302

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
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')
Comment on lines +142 to +143
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that group_to_scalar_field is defined on L38.



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 @@

## 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
Loading