Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌳 Merkle Tree Implementation (JavaScript)

This project demonstrates a simple implementation of a Merkle Tree using JavaScript and SHA-256 hashing.

📌 Underlying Logic

  • Transactions used are hardcoded to build logic and merkle leaf,
  • Each transaction is first serialized and hashed to form the leaf nodes of the tree.
  • Pairs of hashes are then concatenated and re-hashed repeatedly until a single Merkle Root is produced.

📌 Transactions Used

The following hardcoded transactions were used as input:

  • Temu → Raphael (100)
  • Jane → Jumia (200)
  • Taiwo → Kehinde (300)
  • Mohammed → Abubakar (400)
  • Buddy → Tom (500)
  • Peter → Jesus (600)

⚙️ How It Works

  1. Transactions are converted into deterministic strings.
  2. Each string is hashed using SHA-256 to create leaf nodes.
  3. Leaf hashes are paired, concatenated, and hashed again.
  4. The process repeats until one hash remains — the Merkle Root.

🖥️ Program Output

Below is a screenshot showing the generated Merkle Tree levels and final Merkle Root:

Merkle Tree Output


🚀 How to Run

node index.js

About

A JavaScript/TypeScript implementation of a Merkle Tree, demonstrating how to compute and verify cryptographic hashes for secure and efficient data integrity checks

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages