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 zktrie Specification #65

Open
frisitano opened this issue Dec 7, 2024 · 3 comments
Open

Update zktrie Specification #65

frisitano opened this issue Dec 7, 2024 · 3 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed

Comments

@frisitano
Copy link
Collaborator

frisitano commented Dec 7, 2024

Describe the feature

In #36 we introduced zktrie and included the specification https://github.com/scroll-tech/reth/blob/feat/scroll-bmpt/crates/scroll/trie/assets/zktrie.md. The specification is outdated and does not include mention of domain separation for node hashing. We should update it to include this.

The constants for domain seperation in node hashing can be found here:

/// The hashing domain for leaf nodes.
pub const LEAF_NODE_DOMAIN: Fr = Fr::from_raw([4, 0, 0, 0]);
/// The hashing domain for a branch node with two terminal children.
pub const BRANCH_NODE_LTRT_DOMAIN: Fr = Fr::from_raw([6, 0, 0, 0]);
/// The hashing domain for a branch node with a left terminal child and a right branch child.
pub const BRANCH_NODE_LTRB_DOMAIN: Fr = Fr::from_raw([7, 0, 0, 0]);
/// The hashing domain for a branch node with a left branch child and a right terminal child.
pub const BRANCH_NODE_LBRT_DOMAIN: Fr = Fr::from_raw([8, 0, 0, 0]);
/// The hashing domain for a branch node with two branch children.
pub const BRANCH_NODE_LBRB_DOMAIN: Fr = Fr::from_raw([9, 0, 0, 0]);

We should also update the part which suggests that the keys are truncated to 248 bits. This is not the case, all 254 bits (bn254 field size) are used in the key space.

Additional context

No response

@frisitano frisitano added documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed labels Dec 7, 2024
@frisitano frisitano added this to Reth Dec 7, 2024
@MukulKolpe
Copy link

Hey @frisitano, can I work on this one?

@frisitano
Copy link
Collaborator Author

Hi @MukulKolpe, thanks for reaching out and showing interest! We are making some modifications to our implementation of the BMPT, and as such this is a moving target. I would appreciate your support on this after implementing those changes so that the spec accurately reflects what we have implemented.

@MukulKolpe
Copy link

@frisitano, Thank you for the update! Happy to assist once the modifications are in place. Let me know when we're ready to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed
Projects
Status: No status
Development

No branches or pull requests

2 participants