Code Monkey home page Code Monkey logo

merkletree's Introduction

MerkleTree

Implementation of Merkle Tree as part of CS104 Mathematical Foundations of Computing's project to understand Merkle Tree.

Implementation of Merkle Tree

Given a scenario where we have peer file systems, we need to compare if there are any changes to the files. In this project, we embark on a merkle tree that verifies the data in file systems.

How to use

You may use CL arguments for the following feature:

  1. To get the root hash of a folder path
python merkleTree.py --f1 <folderpath>
  1. To compare two folders
python merkleTree.py --f1 <folderpath> --f2 <folderpath>

Limitations of current file system

  • Slow to verify the data in the files (Running through everything)

What is Merkle Tree?

Merkle tree is a type of full binary tree where each parent node has two children. It maintains data integrity by using hash functions.

Hash provides quick verification

Merkle tree hashes the content of a file, meaning if there are two files with different names but same content, the hash would still be the same. With hash, we can immediately tell if the content of two files are different.

Tree reduces time to search where the difference is at

In a scenario where two merkle trees have differing root hashes, we can speed up the process of searching the different file contents by looking at the left and right children node hashes. In the worst case, it gives O(log2 n) since merkle tree is a full 2-ary tree unlike an old file system where it runs through every content at O(n).

merkletree's People

Contributors

ang-rui-yan avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.