Ethereum protocol fellowship week 9

Updates:

  • this week I mostly focused on verkle EIP and understanding specs of pedersen hash

Here's the small write-up regarding generating trie-key:

So in order to generate trie-key we need to pass 5 elements to wrapper:
1. a constant: "[2 + 256 * len(inp)]" inp is 31bytes so still not sure what number exactly, but it's a constant
2. lower bits of address32 (address is 32bytes -- address20 is prepended with 12 0bytes)
3. higher bits of address32
4. lower bits of treeIndex (32bytes)
5. higher bits of treeIndex (32bytes)

treeIndex is an offset within the section of the contract: https://notes.ethereum.org/@vbuterin/verkle_tree_eip#Tree-embedding

so for VERSION_LEAF_KEY it's 0.

That gets us a pedersen_hash(address and treeIndex) and that is 32 bytes, but we cut the last byte and put the subindex of the value for the key we are creating. in the case of VERSION_LEAF_KEY it is 0.


To give you an example of storage slot trie-key because we disucussed this last 2 meetings:

we do a pedersen_hash over an address and trieIndex. trieIndex in this case is a position of a storage slot in the storage (0,1,2....) and this value is added to HEADER_STORAGE_OFFSET or MAIN_STORAGE_OFFSET depending which storage it is and then we floor divide that with 256(number of leafs in 1 node in VKT) so that way we achieve that similar storage slots have the similar "pedersen_hash" --- which is a "stem" == first 31bytes of the trie-key. Last byte (32nd byte) is a tree_index % 256 which gives locality in that "extension and suffix node"

Write-up on strategy for besu:

1. Besu prepares keys using Verkle Crypto API
2. Verkle Lib trie logic uses wrapper for Crypto API: pedersen commitment, IPA proof, opening multiple polynomials at multiple points, and more crypto things like groupToField (this is needed for example when we commit to 256 values we get a groupElemenet and we need to "hash" that to fieldElement in order to store it to the trie)
3. Rust wrapper itself - there we need good understanding of underlying primitives and expose them to Java


In the end we only need Java to operate with bytes. Send bytes to wrapper, wrapper returns bytes

Next week I expect progress on pedersen hash in rust wrapper for Besu and more things related to project proposal (verkle tries crypto primitives in-circuit).

Select a repo