Skip to content

Commit

Permalink
fix(smt): fix verify proof membership (#60)
Browse files Browse the repository at this point in the history
<!-- Please refer to our CONTRIBUTING documentation for any questions on
submitting a pull request. -->
<!-- Provide a general summary of your changes in the Title above. -->

## Description

<!-- Describe your changes in detail. -->
<!-- You may want to answer some of the following questions: -->
<!-- What kind of change does this PR introduce?** (Bug fix, feature,
docs update, ...) -->
<!-- What is the current behavior?** (You can also link to an open issue
here) -->
<!-- What is the new behavior (if this is a feature change)? -->
<!-- Does this PR introduce a breaking change?** (What changes might
users need to make in their application due to this PR?) -->

This PR fixes the issue of membership is not explicitly being used in
`verify_proof`.

The solution was suggested by @0xDatapunk.

## Related Issue(s)

<!-- This project accepts pull requests related to open issues. -->
<!-- If suggesting a new feature or change, please discuss it in an
issue first. -->
<!-- If fixing a bug, there should be an issue describing it with steps
to reproduce. -->
<!-- Please link to the issue(s) here -->

<!-- Closes # -->

Closes #58 
Closes #59 

<!-- Fixes # -->

## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
<!-- Feel free to remove this section if you will not use it. -->

## Checklist

<!-- Please check if the PR fulfills these requirements. -->

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [x] My changes generate no new warnings
- [x] I have run `make lint` and `cargo build --release` without getting
any errors
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
  • Loading branch information
waddaboo authored Oct 18, 2024
1 parent 21de535 commit f68f6e4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions crates/smt/src/smt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ impl SMT {
let root =
self.calculate_root(node, &matching_path, &merkle_proof.entry_response.siblings);

if root == merkle_proof.root {
if merkle_proof.membership == (root == merkle_proof.root) {
let path = key_to_path(&merkle_proof.entry_response.entry[0].to_string());
// Returns the first common bits of the two keys: the non-member key and the matching key.
let first_matching_bits = get_first_common_elements(&path, &matching_path);
Expand Down Expand Up @@ -616,7 +616,6 @@ mod tests {
let value = Value::Str("bbb".to_string());
let _ = smt.add(key.clone(), value.clone());
let result = smt.get(key.clone());
println!("{:?}", result);
assert_eq!(result, Some(value));

let key2 = Key::Str("ccc".to_string());
Expand Down

0 comments on commit f68f6e4

Please sign in to comment.