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

optimization with nodes to keep track the most recent nodes does not work with duplicated nodes #41

Open
0xDatapunk opened this issue Oct 7, 2024 · 0 comments
Labels
audit 🔍 This issue is related to an audit. bug 🐛 Something isn't working

Comments

@0xDatapunk
Copy link

if (nodes[0] == self.lastSubtrees[i][0] || nodes[4] == self.lastSubtrees[i][4]) {
self.lastSubtrees[i][proofPathIndices[i]] = hash;
}

when the updated node is on a path different from the more recently inserted path, which is recorded in self.lastSubtrees, we still might get (nodes[0] == self.lastSubtrees[i][0] || nodes[4] == self.lastSubtrees[i][4])==True, so self.lastSubtrees may be updated in

if (nodes[0] == self.lastSubtrees[i][0] || nodes[4] == self.lastSubtrees[i][4]) {
self.lastSubtrees[i][proofPathIndices[i]] = hash;
}

However, _insert would be using wrong values in

hash = PoseidonT6.hash(self.lastSubtrees[i]);

This optimization with nodes to keep track the most recent nodes does not work even if the tree does not allow for duplicated values, since update/delete may result in duplicated zero values. Also there is no mechanism to enforce always adding unique leaves, if that is the intention.

@cedoor cedoor added bug 🐛 Something isn't working audit 🔍 This issue is related to an audit. labels Oct 14, 2024
@cedoor cedoor added this to ZK-Kit Oct 14, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in ZK-Kit Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audit 🔍 This issue is related to an audit. bug 🐛 Something isn't working
Projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants