merklehashts
v1.0.5
Published
The typescript implementation of the merkle hash algorythm with asn1.der encoding
Readme
🌳 Functional Merkle Tree with GTV Support (TypeScript)
A modular, fully functional (no classes) implementation of a Merkle Tree based on Generic Typed Values (GTV). Designed for flexibility, correctness, and clarity, this project supports nested arrays, dictionaries, and primitives for use in cryptographic hashing, blockchain systems, and data integrity verification.
✨ Features
- 🔁 Purely functional: no classes, mutable state, or OOP.
- 🧩 Recursive tree construction: from primitive values, arrays, or key-value maps.
- 🔒 Cryptographically secure: uses
SHA-256for hashing. - 📦 Pluggable GTV structure: easily integrate your own encoder or type logic.
- ✅ Comprehensive tests using Jest, covering edge cases and nested inputs.
🚀 Usage
Install dependencies:
npm installHash a value:
import { gtv_hash } from './merkle-tree';
const value = [[1]];
const hash = gtv_hash(value);
console.log('Merkle Root Hash:', hash.toString('hex')); 🧪 Running Tests
npm testTODO: Hashing ASN1/DER summary - separate file
