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

trie: Change the algorithm that converts a trie commitment to 32 bytes #29010

Conversation

kevaundray
Copy link
Contributor

@kevaundray kevaundray commented Feb 17, 2024

Problem

Initially this PR was aiming to move us towards one way of converting a point to a 32 byte slice. Unfortunately, we need the Serialize/Deserialize method when converting the root node to a 32 byte slice. So we only change pedersenHash to use MapToScalarFieldBytes

Rationale

This issue specifies most of the rationale: crate-crypto/rust-verkle#86

As its currently written, this PR is not technically blocked by ethereum/go-verkle#428 -- If that PR gets merged, then we can replace a method that I've temporarily duplicated

cmd/geth/verkle.go Outdated Show resolved Hide resolved
Comment on lines -309 to -313
// The output of Byte() is big endian for banderwagon. This
// introduces an imbalance in the tree, because hashes are
// elements of a 253-bit field. This means more than half the
// tree would be empty. To avoid this problem, use a little
// endian commitment and chop the MSB.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This comment about big endian doesn't apply anymore since MapToScalarFieldBytes returns its output in Little endian

@kevaundray
Copy link
Contributor Author

One thought while modifying the library:

If go-verkle exposes a Commitment type, we could have a tighter abstraction. The Commitment type would implement Bytes and we would go back to roughly what the code looks like now.

The Point type that is re-exported from the underlying cryptography library has a lot of methods which we probably don't want to expose to downstream verkle users.

@kevaundray kevaundray force-pushed the kw/remove-usage-of-dot-bytes-method branch from 6017345 to 2f75c12 Compare February 29, 2024 12:04
@kevaundray kevaundray changed the title cmd, trie: Change the algorithm that converts a trie commitment to 32 bytes trie: Change the algorithm that converts a trie commitment to 32 bytes Feb 29, 2024
@kevaundray
Copy link
Contributor Author

Closing as this has been opened up in guillaumes fork

@kevaundray kevaundray closed this Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant