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

Added docs about Merkle Tree #10

Merged
merged 1 commit into from
Jun 1, 2023
Merged

Added docs about Merkle Tree #10

merged 1 commit into from
Jun 1, 2023

Conversation

magestrio
Copy link
Contributor

Feature type

  • UI
  • Implementation
  • Specification
  • CI/CD
  • Other

Feature description

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Your code builds clean without any errors or warnings.
  • Tests for changes have been added (for bug fixes / features). If no, why?

Sparse Merkle Trees (SMTs) offer several benefits:

1) **Efficiency**: They allow efficient storage of large, sparse datasets with minimal memory overhead.
2) **Security**: Like traditional Merkle trees, they provide tamper-proof data structure and enable cryptographic verification of data integrity.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does Sparse Merkle Tree have the same security issue with Merkle Tree?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it does. It means if any unauthorized changes are made, they will be detected in the root.

Copy link
Contributor

Choose a reason for hiding this comment

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

When I mentioned security issue, I meant Sparse Merkle Tree have the same Merkle Tree vulnerability that would lead to a false proof.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

### Ways to store Merkle Tree on IPFS
Here are different ways you could store a Merkle Tree on IPFS:

1) **JSON Serialization**: One of the simplest ways to store a Merkle Tree in IPFS is to convert the Merkle Tree to a JSON structure and then save that to IPFS. This is a straightforward method but can be inefficient for large trees, as the entire tree needs to be retrieved even if you're only interested in certain parts of it.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we consider BSON and define a structure to store Merkle tree?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

All standart merkle tree functions can be implemented along with these 'key' functions.

#### Zero nodes
For each level, zero nodes remain constant and can be generated during the initialization of the Merkle Tree.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
For each level, zero nodes remain constant and can be generated during the initialization of the Merkle Tree.
For each level, zero nodes remain constant and can be generated during the initialization of the Merkle Tree.

Please format the code with MD formatter first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@chiro-hiro
Copy link
Contributor

Over all LGTM, just some minor issues need to be fixed and the security concern.

@magestrio magestrio force-pushed the specs/merkle-tree branch from 000c56b to 573a515 Compare May 30, 2023 14:23
@chiro-hiro chiro-hiro merged commit 2459bfe into main Jun 1, 2023
@chiro-hiro chiro-hiro deleted the specs/merkle-tree branch June 1, 2023 04:40
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