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

✨ Merkle tree generation #178

Merged

Conversation

bal7hazar
Copy link
Contributor

@bal7hazar bal7hazar commented Sep 8, 2023

  • Add poseidon version of the merkle tree
  • Add proof computation
  • Clean and add corresponding tests

Pull Request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: #169
Issue Number: #170

What is the new behavior?

  • A new implementation of the MerkleTree using poseidon hash method
  • Add a compute_proof method to the MerkleTreeTrait to generate a proof based on leaves and an index
  • Rename the previous merkle tree type from MerkleTree to MerkleTreeLegacy
  • Merkle tree tests refactoring to clarify tests and add tests according to the new feature

Does this introduce a breaking change?

  • Yes
  • No

Before the change you could just have:

use alexandria_data_structures::merkle_tree::MerkleTreeTrait;
let mut merkle_tree = MerkleTreeTrait::new();

Now you must specify which kind of merkle tree you want (the legacy version or the new one):

// The new version, using the poseidon hash method
use alexandria_data_structures::merkle_tree::{MerkleTree, HashMethod, MerkleTreeTrait};
let hash_method = HashMethod::Poseidon(());
let mut merkle_tree = MerkleTreeTrait::new(hash_method);
// The legacy version, using the pedersen hash method
use alexandria_data_structures::merkle_tree::{MerkleTree, HashMethod, MerkleTreeTrait};
let hash_method = HashMethod::Poseidon(());
let mut merkle_tree = MerkleTreeTrait::new(hash_method);

Other information

Work load: ~ 8 hours

- Add poseidon version of the merkle tree
- Add proof computation
- Clean and add corresponding tests
@bal7hazar
Copy link
Contributor Author

@LucasLvy could you take the lead on this review please to move forward?

src/data_structures/src/merkle_tree.cairo Outdated Show resolved Hide resolved
src/data_structures/src/merkle_tree.cairo Show resolved Hide resolved
src/data_structures/src/merkle_tree.cairo Show resolved Hide resolved
src/data_structures/src/merkle_tree.cairo Outdated Show resolved Hide resolved
src/data_structures/src/merkle_tree.cairo Outdated Show resolved Hide resolved
src/data_structures/src/merkle_tree.cairo Outdated Show resolved Hide resolved
src/data_structures/src/merkle_tree.cairo Show resolved Hide resolved
Co-authored-by: Lucas @ StarkWare <70894690+LucasLvy@users.noreply.github.com>
@0xLucqs 0xLucqs merged commit eb93e9b into keep-starknet-strange:main Sep 18, 2023
3 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants