Skip to content

MerkleTree insertion proofs#344

Merged
arnaucube merged 13 commits intomainfrom
tree-insertion-proofs
Jul 24, 2025
Merged

MerkleTree insertion proofs#344
arnaucube merged 13 commits intomainfrom
tree-insertion-proofs

Conversation

@arnaucube
Copy link
Collaborator

@arnaucube arnaucube commented Jul 16, 2025

  • implement tree.insert method to add new leaves to the tree (till now we could only add leaves at tree initial creation, not after), which returns a proof of correct insertion (proof of correct state transition)
  • implement verification of proofs of correct insertion of leaves
  • implement circuit that verifies proofs of correct insertion
  • fix graphviz method after endianness change

Update: thanks @ax0 for pointing out the tampering proofs case, which required adding the check 5.3.

Related to #335 (insertion).

Note: I've implemented also an alternative version which instead of
inputting a witness value 'divergence_level' it inputs a bitmask. Both
approaches (divergence_level and divergence_bitmask) take the same
amount of constraints (336 constraints for a tree of 32 levels, and for
an hybrid approach it takes 331 constraints but the code gets a bit less
readable). So I've kept with the current implementation (using
divergence_level) which is more easy to follow.
@arnaucube arnaucube requested review from ax0 and ed255 July 16, 2025 12:23
@arnaucube arnaucube force-pushed the tree-insertion-proofs branch 3 times, most recently from 1a0c40c to 2da2e82 Compare July 17, 2025 10:30
Copy link
Collaborator

@ax0 ax0 left a comment

Choose a reason for hiding this comment

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

LGTM!

@arnaucube arnaucube force-pushed the tree-insertion-proofs branch 2 times, most recently from c275f69 to d263245 Compare July 22, 2025 13:58
Copy link
Collaborator

@ed255 ed255 left a comment

Choose a reason for hiding this comment

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

First review round. I've left some small suggestions, and an open question. I'll do another round.

Copy link
Collaborator

@ed255 ed255 left a comment

Choose a reason for hiding this comment

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

LGTM!

@arnaucube arnaucube merged commit 745d654 into main Jul 24, 2025
8 checks passed
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