# @chainsafe/hashtree

> Simple NAPI wrapper around https://github.com/prysmaticlabs/hashtree

Latest version **1.0.2** (published 2025-08-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @chainsafe/hashtree
pnpm add @chainsafe/hashtree
yarn add @chainsafe/hashtree
bun add @chainsafe/hashtree
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2025-08-12 |
| First published | 2024-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 18 |
| Dependencies | 0 |
| Unpacked size | 24.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Author | ChainSafe.io |
| Maintainers | wemeetagain, mpetrunic |
| Keywords | hash, hashtree, merkle, NAPI, N-API, sha256 |

## Links

- npm: https://www.npmjs.com/package/@chainsafe/hashtree
- Repository: https://github.com/ChainSafe/hashtree-js
- Homepage: https://github.com/ChainSafe/hashtree-js#readme
- Issues: https://github.com/ChainSafe/hashtree-js/issues
- npm.io page: https://npm.io/package/@chainsafe/hashtree

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2025-08-12
- 1.0.1 — 2024-06-26
- 1.0.0 — 2024-06-07

## README

# @chainsafe/hashtree

Simple NAPI wrapper around https://github.com/prysmaticlabs/hashtree


## Example

```ts
import {hash, hashInto} from "@chainsafe/hashtree"

// input is a Uint8Array of concatenated left-right tuples
const input: Uint8Array = Buffer.concat([
  Buffer.alloc(32), Buffer.alloc(32),
  Buffer.alloc(32, 1), Buffer.alloc(32, 1),
])

// output will be a Uint8Array of concatenated output hashes
const output = hash(input)

// for example, when compared to node:crypto usage:
import {createHash} from "node:crypto"

Buffer.compare(
  createHash("sha256").update(input.slice(0, 64)).digest(),
  output.slice(0, 32)
) === 0
Buffer.compare(
  createHash("sha256").update(input.slice(64)).digest(),
  output.slice(32)
) === 0

// alternative interface with preallocated output
const output2 = new Uint8Array(input.length / 2)
hashInto(input, output2)
```

## License

MIT

---
_Source: https://npm.io/package/@chainsafe/hashtree · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
