# @web3-storage/data-segment

> Implementation of [FRC-0058](https://github.com/filecoin-project/FIPs/blob/master/FRCs/frc-0058.md) verifiable aggregation scheme

Latest version **5.3.0** (published 2024-10-18) · (Apache-2.0 AND MIT) license · 0 weekly downloads

## Install

```sh
npm install @web3-storage/data-segment
pnpm add @web3-storage/data-segment
yarn add @web3-storage/data-segment
bun add @web3-storage/data-segment
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.3.0 |
| Published | 2024-10-18 |
| First published | 2023-05-26 |
| Weekly downloads | 0 |
| License | (Apache-2.0 AND MIT) |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 156.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | it-dag-house, gozala, olizilla, vascosantos, alanshaw |
| Keywords | FRC-0058, CommP, filecoin |

## Links

- npm: https://www.npmjs.com/package/@web3-storage/data-segment
- Repository: https://github.com/web3-storage/data-segment
- Homepage: https://github.com/web3-storage/data-segment.git
- Issues: https://github.com/web3-storage/data-segment/issues
- npm.io page: https://npm.io/package/@web3-storage/data-segment

## Dependencies (3)

- [multiformats](https://npm.io/package/multiformats.md) ^13.3.0
- [@ipld/dag-cbor](https://npm.io/package/@ipld/dag-cbor.md) ^9.2.1
- [sync-multihash-sha2](https://npm.io/package/sync-multihash-sha2.md) ^1.0.0

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 5.3.0 (latest) — 2024-10-18
- 5.2.0 — 2024-09-20
- 5.1.0 — 2024-03-01
- 5.0.0 — 2023-10-26
- 4.0.0 — 2023-10-20
- 3.2.0 — 2023-10-05
- 3.1.0 — 2023-09-26
- 3.0.1 — 2023-08-09
- 3.0.0 — 2023-08-09
- 2.2.0 — 2023-07-25
- 2.1.0 — 2023-07-17
- 2.0.0 — 2023-07-13
- 2.0.0-dev-1 — 2023-06-23
- 2.0.0-dev — 2023-06-23
- 1.0.1 — 2023-06-02
- … 1 more at https://npm.io/package/@web3-storage/data-segment/versions

## README

# @web3-storage/data-segment

Implementation of the [FRC-0058] verifiable aggregation scheme.

## API

```ts
import { Piece, MIN_PAYLOAD_SIZE } from "@web3-storage/data-segment"

// input must be >= 65 bytes
const bytes = new Uint8Array(MIN_PAYLOAD_SIZE)

const piece = Piece.fromPayload(bytes)

// bafkzcibbai3tdo4zvruj6zxo6wlt4suu3imi6to4vzmaojh4n475mdp5jcbtg
const cid = piece.link.toSting()
```

## Prior Art

Started as fork of [js-fil-utils] modernizing it to use ES modules and web crypto APIs in place of node APIs.

However, [js-fil-utils] produces different results from the more widely used go implementation which is why it got some heavy lifting inspired by [go-data-segment] and [go-fil-commp-hashhash] libraries.

[go-data-segment]:https://github.com/filecoin-project/go-fil-commp-hashhash/tree/master
[go-fil-commp-hashhash]:https://github.com/filecoin-project/go-data-segment/tree/master
[js-fil-utils]: https://github.com/rvagg/js-fil-utils/tree/master
[FRC-0058]: https://github.com/filecoin-project/FIPs/blob/master/FRCs/frc-0058.md

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