All Projects → adjoint-io → Merkle Tree

adjoint-io / Merkle Tree

Licence: mit
Merkle Trees and Merkle Inclusion Proofs

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to Merkle Tree

Containers
This library provides various containers. Each container has utility functions to manipulate the data it holds. This is an abstraction as to not have to manually manage and reallocate memory.
Stars: ✭ 125 (-3.85%)
Mutual labels:  data-structures, tree
Buckets Js
A complete, fully tested and documented data structure library written in pure JavaScript.
Stars: ✭ 1,128 (+767.69%)
Mutual labels:  data-structures, tree
Coniks Java
A CONIKS implementation in Java
Stars: ✭ 58 (-55.38%)
Mutual labels:  merkle-tree, cryptography
Algorithms
Study cases for Algorithms and Data Structures.
Stars: ✭ 32 (-75.38%)
Mutual labels:  data-structures, tree
Javascript
A repository for All algorithms implemented in Javascript (for educational purposes only)
Stars: ✭ 16,117 (+12297.69%)
Mutual labels:  data-structures, cryptography
Geeksforgeeks Dsa 2
This repository contains all the assignments and practice questions solved during the Data Structures and Algorithms course in C++ taught by the Geeks For Geeks team.
Stars: ✭ 53 (-59.23%)
Mutual labels:  data-structures, tree
Exonum Client
JavaScript client for Exonum blockchain
Stars: ✭ 62 (-52.31%)
Mutual labels:  merkle-tree, cryptography
Algorithms and data structures
180+ Algorithm & Data Structure Problems using C++
Stars: ✭ 4,667 (+3490%)
Mutual labels:  data-structures, tree
Merkle.rs
🎄 Merkle tree in Rust
Stars: ✭ 98 (-24.62%)
Mutual labels:  data-structures, merkle-tree
Data Structures
This repository contains some data structures implementation in C programming language. I wrote the tutorial posts about these data structures on my personal blog site in Bengali language. If you know Bengali then visit my site
Stars: ✭ 82 (-36.92%)
Mutual labels:  data-structures, tree
Claimchain Core
A core and experimental implementation of ClaimChain
Stars: ✭ 30 (-76.92%)
Mutual labels:  merkle-tree, cryptography
Leetcode
LeetCode Solutions: A Record of My Problem Solving Journey.( leetcode题解,记录自己的leetcode解题之路。)
Stars: ✭ 45,650 (+35015.38%)
Mutual labels:  data-structures, tree
Dsa.js Data Structures Algorithms Javascript
🥞Data Structures and Algorithms explained and implemented in JavaScript + eBook
Stars: ✭ 6,251 (+4708.46%)
Mutual labels:  data-structures, tree
Merkle Tools
Tools for creating Merkle trees, generating merkle proofs, and verification of merkle proofs.
Stars: ✭ 54 (-58.46%)
Mutual labels:  merkle-tree, cryptography
Firo
The privacy-focused cryptocurrency
Stars: ✭ 528 (+306.15%)
Mutual labels:  merkle-tree, cryptography
Ki
Go language (golang) full strength tree structures (ki in Japanese)
Stars: ✭ 61 (-53.08%)
Mutual labels:  data-structures, tree
Algodeck
An Open-Source Collection of 200+ Algorithmic Flash Cards to Help you Preparing your Algorithm & Data Structure Interview 💯
Stars: ✭ 4,441 (+3316.15%)
Mutual labels:  data-structures, tree
C Sharp Algorithms
📚 📈 Plug-and-play class-library project of standard Data Structures and Algorithms in C#
Stars: ✭ 4,684 (+3503.08%)
Mutual labels:  data-structures, tree
Splay Tree
Fast splay-tree data structure
Stars: ✭ 80 (-38.46%)
Mutual labels:  data-structures, tree
Coniks Go
A CONIKS implementation in Golang
Stars: ✭ 102 (-21.54%)
Mutual labels:  merkle-tree, cryptography

CircleCI Hackage

merkle-tree

This library implements a merkle-tree data structure, for representing a list of hashed data as a binary tree of pairs of hashes converging to a single hash, the merkle root. SHA3_256 is used as the hashing algorithm.

Description

A Merkle tree is a tamper-resistant data structure that allows a large amount of data to be compressed into a single hash and can be queried for the presence of specific elements in the data with a proof constructed in logarithmic space.

Construction

A Merkle tree is a binary tree of hashes, in which all the leaf nodes are the individual data elements in the block. To construct a merkle tree, the initial data elements are first hashed using the merkle tree hash function to generate the leaf nodes of the tree. The resulting hashed data are subsequently hashed together in pairs to create the parent nodes of the leaf nodes. This process continues until it results in a single hash known as the merkle root.

-- | Constructs a Merkle Tree from a list of ByteStrings
mkMerkleTree :: [ByteString] -> MerkleTree ByteString

-- | Generates the hash of a piece of data existing as a leaf node in the Tree
mkLeafRootHash :: ByteString -> MerkleRoot ByteString

Merkle Inclusion Proof

Perhaps the most important reason to use a merkle tree to represent the block data is the ability to construct a merkle proof (O(n)) that verifies the inclusion of a transaction t in a specific block b (O(log(n))).

Merkle proofs are an important part in creating decentralized block chain networks as nodes or client programs (aka "light-weight nodes") that do not store blocks in memory or on disk regularly need to verify that a transaction has been included on the chain or not. This can be accomplished by the lightweight node supplying the transaction hash and a block index, querying a full node for a merkle inclusion proof of the transaction's inclusion in the block with the index supplied. If the full node finds the transaction in that block and responds with the inclusion proof and the block's merkle root. With this information, it takes O(log(n)) for the lightweight node to validate the inclusion proof.

-- | Constructs a Merkle Inclusion Proof 
merkleProof 
  :: MerkleTree a   -- ^ Tree to which data may belong 
  -> MerkleRoot a   -- ^ Leaf root hash, data to query inclusion of 
  -> MerkleProof a  -- ^ A list of hashes to verify data inclusion 

-- | Validates a Merkle Inclusion Proof
validateMerkleProof 
 :: MerkleProof a  -- ^ Inclusion proof constructed by the prover  
 -> MerkleRoot a   -- ^ Root of the merkle tree from which the proof was constructed
 -> MerkleRoot a   -- ^ Leaf root hash for which the proof was constructed 
 -> Bool           -- ^ Leaf root inclusion

Example

import Crypto.Hash.MerkleTree

example :: Bool
example = 
    -- Does the proof prove that `mleaf` exists in `mtree`? 
    validateMerkleProof proof (mtRoot mtree) mleaf 
  where
    -- Build a merkle tree from a list of data
    mtree = mkMerkleTree ["tx1", "tx2", "tx3"] 
    -- Construct merkle proof that a leaf exists in `merkleTree`
    mleaf = mkLeafRootHash "tx2"
    proof = merkleProof mtree mleaf

License

Copyright 2017-2018 Adjoint Inc

Released under MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].