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

fix(lean-imt): After a sequence of updates a proof is invalid. #355

Merged
merged 7 commits into from
Dec 4, 2024

Conversation

Lauman
Copy link
Contributor

@Lauman Lauman commented Dec 2, 2024

Description

When a member is removed from the tree (update a leaf with 0n) and then another member is updated, the root that is saved is not correct, so the proof that is generated is not valid.This was caused by a type validation failure.
This fix the behavior described above.
I detected this when I was testing in Semphore groups.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have run yarn style without getting any errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Collaborator

@0xDatapunk 0xDatapunk left a comment

Choose a reason for hiding this comment

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

what is the expected behavior of poseidon, when one of the inputs is undefined?

I am wondering if this should be fixed there instead

@Lauman
Copy link
Contributor Author

Lauman commented Dec 3, 2024

what is the expected behavior of poseidon, when one of the inputs is undefined?

I am wondering if this should be fixed there instead

Hi 0xDatapunk. The poseidon method accepts bigint|number|string, if you pass an undefined parameter the process crashes with the error TypeError: Cannot convert undefined to a BigInt.
I think if there is no data for that sibiling it is not necessary to perform the hash.

When a member is removed from the tree (update a leaf with 0n) and then another member is updated, the root that is saved is not correct, so the proof that is generated is not valid.This was caused by a type validation failure.
This fix the behavior described above.
I detected this when I was testing in Semphore groups.
due to a bug in type checking, the root is not generated correctly.
due to a bug in type checking, the root is not generated correctly.
@Lauman
Copy link
Contributor Author

Lauman commented Dec 3, 2024

@cedoor I had to rebase my commit because they weren't verified. I've fixed it now.

@Lauman Lauman requested a review from cedoor December 3, 2024 17:20
@cedoor cedoor merged commit 659d728 into privacy-scaling-explorations:main Dec 4, 2024
2 checks passed
Copy link

gitpoap-bot bot commented Dec 4, 2024

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

GitPOAP: 2024 ZK-KIT Contributor:

GitPOAP: 2024 ZK-KIT Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.

github-merge-queue bot pushed a commit to proofcarryingdata/zupass that referenced this pull request Dec 10, 2024
Just a cleanliness update while I check for changes in our various
dependencies. Here's the story behind the updated comment, for
posterity:

I originally planned to use 0 as the hash value for PODNull, but decided
against it because LeanIMT behaved badly. Turns out that behavior was a
bug, fixed here:
privacy-scaling-explorations/zk-kit#355

However, the test for that bug points out that people might assume that
0 has special meaning in many situations (including using it to mean
removal from a Merkle tree), so it's still a good idea to use a unique
non-zero value for PODNull's hash. In this PR I've updated the comment
on the related utest to describe the general reasoning, rather than
point to LeanIMT in particular.
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.

3 participants