Skip to main content

Reed-Solomon erasure coding for files: split into shards, rebuild from whatever survives.

Project description

kintsugi

Split a file into n shards so that any k of them are enough to rebuild it. Lose disks, lose nodes, lose packets, lose whole shard files — as long as k survive, the original comes back byte for byte.

The name comes from kintsugi, the craft of repairing broken pottery: the object is whole again even after pieces are lost.

  • Pure Python, no dependencies, fully offline.
  • Real Reed-Solomon over GF(2⁸) with a Cauchy generator matrix, so recovery works for any combination of lost shards, not just a lucky few.
  • A small CLI for splitting and rebuilding actual files.

Install

pip install kintsugi

Or from a checkout:

pip install -e .

How it works

You pick k data shards and m parity shards (n = k + m total).

Layout Storage overhead Shards you can lose
4 + 2 +50% any 2
10 + 4 +40% any 4
6 + 3 +50% any 3

Recovery is all-or-nothing per file: with at least k shards you get an exact rebuild; with fewer than k it is information-theoretically impossible (and the library tells you so instead of guessing).

CLI

Split a file into 6 data + 3 parity shards:

kintsugi split report.pdf -d 6 -p 3 -o shards/

Delete any 3 of the 9 .ktsg files, then rebuild from whatever is left:

kintsugi join shards/report.pdf.*.ktsg -o report.pdf

Each shard carries a CRC, so a corrupted shard is dropped and treated as missing rather than poisoning the output.

Library

from kintsugi import Codec

codec = Codec(data=4, parity=2)

shards = codec.encode([b"....", b"....", b"....", b"...."])  # 6 shards back

shards[1] = None   # a shard goes missing
shards[4] = None   # and another

rebuilt = codec.reconstruct(shards)   # all 6 shards, whole again

For files there are two helpers:

from kintsugi import split_bytes, join_shards

What it does not do

  • It assumes a shard is either intact or gone. Silent bit-rot inside a shard is caught by the CLI's per-shard CRC; the core codec works on the erasure model.
  • It is not a backup scheduler or a network transport — just the coding layer.

Tests

pip install pytest
pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kintsugiv01-0.1.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kintsugiv01-0.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file kintsugiv01-0.1.0.tar.gz.

File metadata

  • Download URL: kintsugiv01-0.1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kintsugiv01-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8e956845ea35000797cce4b6a0baf68fa531c2af2888b1865b75b31e5936a298
MD5 f742c714b81aca77f68562a4c47c5a90
BLAKE2b-256 15d3a3fda3bf6577a181b68b61ff0f3e455b7308b829f853dd2c980f5df1c4aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for kintsugiv01-0.1.0.tar.gz:

Publisher: publish.yml on nkkb/kintsugi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kintsugiv01-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kintsugiv01-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kintsugiv01-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e22a124f37fd8de99eb5053eafb026aed05217692ffb2192f477f699b7ec570
MD5 319d21721dfc068da842e4946061cbd8
BLAKE2b-256 491048b411c3efd024a7656aee789e26680a1a741c24e389ca20ae003c67383d

See more details on using hashes here.

Provenance

The following attestation bundles were made for kintsugiv01-0.1.0-py3-none-any.whl:

Publisher: publish.yml on nkkb/kintsugi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page