@variablesoftware/ts-merkle
Version:
๐ณ๐๐ก๏ธ A TypeScript library for creating and verifying Merkle trees.
77 lines (56 loc) โข 3.02 kB
Markdown
# @variablesoftware/ts-merkle ๐ณ๐๐ก๏ธ
[](https://github.com/variablesoftware/ts-merkle/actions)
[](https://www.npmjs.com/package/@variablesoftware/ts-merkle)
[](https://github.com/variablesoftware/ts-merkle/blob/main/LICENSE.txt)
[](https://coveralls.io/github/variablesoftware/ts-merkle)
[](https://bundlephobia.com/package/@variablesoftware/ts-merkle)
[](https://www.npmjs.com/package/@variablesoftware/ts-merkle)
[](https://github.com/variablesoftware/ts-merkle/pulls)
> ๐ณ๐๐ก๏ธ A lightweight, fast, and auditable TypeScript library for creating and verifying Merkle trees.
- โก **Fast**: Minimal dependencies, optimized for performance
- ๐งฉ **Interoperable**: Compatible with popular libraries like `merkletreejs`
- ๐ **Secure**: Uses SHA-256 and strong cryptographic primitives
- ๐งช **Well-tested**: Robust test suite with edge cases, stress, and cross-library checks
## Install
```sh
pnpm add @variablesoftware/ts-merkle
# or
npm install @variablesoftware/ts-merkle
```
## Usage
```ts
import { computeMerkleRoot, computeMerkleProof, verifyMerkleProof } from '@variablesoftware/ts-merkle';
const leaves = [
new Uint8Array([1]),
new Uint8Array([2]),
new Uint8Array([3]),
new Uint8Array([4])
];
const root = computeMerkleRoot(leaves);
const proof = computeMerkleProof(leaves, 2);
const isValid = verifyMerkleProof(leaves[2], proof, root);
console.log('Proof valid?', isValid); // true
```
## Features
- Merkle root computation (with/without padding, sorting)
- Proof generation and verification
- Cross-library compatibility (see docs/)
- Fully typed, TSDoc documented
## See Also
- [docs/](./docs/) for advanced usage, benchmarks, and comparisons
- [tests/](./tests/) for robust test coverage
## ๐ License
MIT ยฉ Rob Friedman / Variable Software
> Built with โค๏ธ by [@variablesoftware](https://github.com/variablesoftware)
> Thank you for downloading and using this project. Pull requests are warmly welcomed!
## ๐ Inclusive & Accessible Design
- Naming, logging, error messages, and tests avoid cultural or ableist bias
- Avoids assumptions about input/output formats or encodings
- Faithfully reflects user data โ no coercion or silent transformations
- Designed for clarity, predictability, and parity with underlying platforms (e.g., Cloudflare APIs)
- Works well in diverse, multilingual, and inclusive developer environments
Made with โค๏ธ by Variable Software