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

test: BMT proof verify tests and additional verify logic #721

Merged
merged 17 commits into from
Apr 15, 2024

Conversation

bvrooman
Copy link
Contributor

@bvrooman bvrooman commented Apr 11, 2024

Closes: #716

This PR:

  • Adds additional logic to the binary::verify function to check the proof index against the length of the proof set. The proof index tells us the minimum size of the tree's leaf set. The provided proof set along the leaf-root path must be compatible with the calculated path length.
  • Adds proptests for binary::verify to ensure correctness of algorithm

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • If performance characteristic of an instruction change, update gas costs as well or make a follow-up PR for that
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

After merging, notify other teams

[Add or remove entries as needed]

@bvrooman bvrooman changed the title Bvrooman/feat/bmt proof verify fix test: BMT proof verify tests and additional verify logic Apr 12, 2024
Clippy

Clippy

Clippy

Clippy

Clippy
@bvrooman bvrooman self-assigned this Apr 12, 2024
@bvrooman bvrooman marked this pull request as ready for review April 12, 2024 23:19
let (root, proof_set) = tree.prove(index as u64).expect("Unable to generate proof");

// When
let verification = verify(&root, &data, &proof_set, index as u64, num_leaves as u64 + 1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice to have random num_leaves here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I made this change locally but proptest is reporting failures. I will need to dig into this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What failures do you have? Is that in cases when num_leaves is more than the real number of leaves?

@xgreenx
Copy link
Collaborator

xgreenx commented Apr 13, 2024

The change looks good=) Waiting for the updated test and I'm ready to approve

@xgreenx xgreenx enabled auto-merge April 15, 2024 13:24
@xgreenx xgreenx added this pull request to the merge queue Apr 15, 2024
Merged via the queue into master with commit cc1f32e Apr 15, 2024
38 checks passed
@xgreenx xgreenx deleted the bvrooman/feat/bmt-proof-verify-fix branch April 15, 2024 13:44
@xgreenx xgreenx mentioned this pull request Apr 15, 2024
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.

The fuel_merkle::binary::verify almost ignores the num_leaves
2 participants