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

Implement domain separation for compact sparse Merkle tree #35

Closed
Tracked by #7 ...
Al-Kindi-0 opened this issue Jan 12, 2023 · 5 comments
Closed
Tracked by #7 ...

Implement domain separation for compact sparse Merkle tree #35

Al-Kindi-0 opened this issue Jan 12, 2023 · 5 comments
Assignees

Comments

@Al-Kindi-0
Copy link
Collaborator

As part of the design in #22 for a tiered compact SMT, we need to create domain separation between internal nodes and leaf nodes i.e. each type of node should be hashed differently.
The rule that was proposed by @bobbinth is the following:

  1. Internal nodes are hashed as hash(left,right) where right and left are the left and right child, respectively.
  2. Leaf nodes are hashed as hash(r,v) where r is the remaining key (i.e. with the prefix leading to the current position removed) and v is the values associated with key. Further, we set one of the capacity registers to the depth i.e. 16, 32, 48 or 64.

At the moment, accessing the capacity registers externally is not possible to realize point 2. The following issue aims at exposing some methods from RPO so that point 2 above can be implemented in the final implementation of our compact SMT #22 .

@Al-Kindi-0 Al-Kindi-0 changed the title Implement domain seperation for compact sparse Merkle tree Implement domain separation for compact sparse Merkle tree Jan 12, 2023
@bobbinth
Copy link
Contributor

I think the only method we need to support this for (at least for now) is merge(). This would cover the SMT use case as well as the program hashing use case in the VM (where we need to differentiate between JOIN and SPLIT blocks etc.).

I'm thinking the new function could look like this:

pub fn merge_in_domain(values: &[RpoDigest; 2], domain: Felt) -> RpoDigest

The domain element could go into the second element of the capacity section (since the first element is used for padding purposes).

@grjte
Copy link
Contributor

grjte commented Jan 24, 2023

Closed by #40

@grjte grjte closed this as completed Jan 24, 2023
@grjte grjte mentioned this issue Feb 6, 2023
2 tasks
@hackaugusto
Copy link
Contributor

sorry to hijack the closed issue. can we document why we didn't implement the domain separation in for the compact SMT?

@bobbinth
Copy link
Contributor

bobbinth commented Mar 9, 2023

We do use it in compact SMT but only for computing leaf nodes, which are computed using merge_in_domain() function.

@hackaugusto
Copy link
Contributor

hackaugusto commented Mar 9, 2023

Aha, I assume you mean for PR #45 , I only checked #27 , thanks! (hahhaa, I mixed this two PRs up because #27 was sitting on next for a while, and in my mind we didn't have a SMT in january, sorry for the confusion!)

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

No branches or pull requests

5 participants