Skip to main content

Authenticated local encryption and Shamir threshold recovery with offline workflows.

Project description

shard-core

CI Python 3.9+ License: Apache--2.0 OR MIT--0

shard-core protects sensitive bytes and recovery phrases with authenticated encryption, threshold recovery, and fail-closed file handling.

Security status: 0.2.0 is the first stable release and has not received an independent security audit. Tests and AI-assisted review are not a security audit. Use synthetic material for evaluation and rehearse recovery before protecting production secrets.

What it provides

Capability Status
ChaCha20-Poly1305 authenticated encryption Included
Scrypt passphrase encryption Included
AEAD plus Shamir threshold protection Included
Corrupt-extra-share recovery and ambiguity detection Included
Fordefi Recovery Phrases workflow Included
Optional SLIP-39 support .[slip39] extra
Reproducible, hash-verified offline bundle pipeline Included
Implicit plaintext output or silent overwrite Refused

Architecture

Protect

plaintext
    |
    | encrypt with random 32-byte data-encryption key (DEK)
    v
ChaCha20-Poly1305 --------------------> authenticated ciphertext C
    ^                                               |
    |                                               |
random DEK -- Shamir split --> K1, K2, ... Kn       |
                              |                      |
                              +--> SHRD i = header + Ki + C

Each SHRD artifact contains a unique Shamir key share and the same ciphertext. That duplication is intentional: every valid threshold subset is self-contained. The trade-off is additional storage, not weaker confidentiality.

The plaintext itself is never Shamir-split. A wrong key-share combination fails AEAD authentication instead of returning plausible but incorrect plaintext.

Recover

supplied SHRD files
    |
    v
parse and group candidate sets
    |
    v
try bounded threshold combinations
    |
    v
reconstruct DEK -> verify AEAD tag -> plaintext
                       |
                       +--> fail closed on corruption or ambiguity

See THREAT_MODEL.md for the security properties, assumptions, and non-goals.

Install

Requires Python 3.9 or newer.

Quick install

Use this path for evaluation and normal use on a connected host:

git clone --branch v0.2.0 --depth 1 \
  https://github.com/Protocol-Wealth/shard-core.git
cd shard-core
python3 -m venv .venv
. .venv/bin/activate
python -m pip install .
shard-core --version

This path may obtain dependencies from a package index. To add SLIP-39:

python -m pip install '.[slip39]'

For development:

python -m pip install -e '.[test]'

Advanced verified build

For a hash-locked, network-disabled, rootless Podman build and an installable offline bundle, follow OFFLINE_BUILD.md. The top-level install.sh only dispatches to an already built offline bundle; it is not the quick installer.

Quickstart

Authenticated threshold shares

shard-core protect \
  --threshold 2 \
  --shares 3 \
  --input secret.bin \
  --out-dir shares

shard-core verify-set --require-complete \
  shares/share-01.txt \
  shares/share-02.txt \
  shares/share-03.txt

shard-core recover \
  --output recovered.bin \
  shares/share-01.txt \
  shares/share-03.txt

Passphrase encryption

shard-core encrypt --input secret.bin --output secret.shen
shard-core decrypt --input secret.shen --output recovered.bin

The commands prompt without echo. For controlled automation, use a private regular file with --passphrase-file; environment-variable passphrases emit a warning.

Fordefi backup choice

Fordefi lets the operator choose among Public Key Upload, Recovery Phrases, and managed provider or hardware-backed methods.

Fordefi backup method
    |
    +--> Public Key Upload / native CoinCover / Station70 / YubiKey
    |        +--> public-key recovery path; shard-core is not required
    |
    +--> Recovery Phrases
             +--> phrase -> SHEN plus separate credential
             +--> phrase -> threshold SHRD shares

For the Recovery Phrases path, direct encryption is:

shard-core fordefi encrypt --output protocol-phrase.shen
shard-core fordefi decrypt \
  --input protocol-phrase.shen \
  --output protocol-phrase.txt

Fordefi phrase entry is hidden and confirmed twice. Standard entry requires 12 lowercase ASCII words; whitespace is canonicalized without changing spelling, order, or case. shard-core does not assume a Fordefi phrase is BIP-39.

Follow docs/FORDEFI-DISASTER-RECOVERY.md for method selection, 2-of-2 phrase custody, external-custodian role checks, and the final offline Fordefi recovery boundary.

SLIP-39

Install .[slip39], then use the explicit slip39 command family for material independently confirmed to be compatible:

shard-core slip39 split \
  --threshold 2 \
  --shares 3 \
  --bip39-file mnemonic.txt \
  --out-dir slip39-shares

shard-core slip39 combine \
  --bip39 \
  --output recovered-mnemonic.txt \
  slip39-shares/share-01.txt \
  slip39-shares/share-03.txt

Safety defaults

  • Sensitive recovery and decryption require --output FILE or deliberate --stdout.
  • Existing output files are refused unless --force is explicit.
  • Final-component symlinks are refused even with --force.
  • Multi-file output is fully preflighted before any share is written.
  • New secret files use mode 0600; new private directories use mode 0700.
  • Identical duplicate shares are reported; conflicting duplicates fail.
  • Independent complete sets in one recovery invocation fail as ambiguous.
  • Recovery combinations are bounded to prevent uncontrolled work.
  • Manifests contain artifact hashes and set metadata, never plaintext hashes.

These controls assume a trusted host and controlled parent directories. See THREAT_MODEL.md and CEREMONY.md.

Formats and compatibility

  • SHEN v2 stores scrypt parameters, salt, nonce, tag, and ciphertext.
  • SHRD v2 stores the authenticated common header, one key share, and ciphertext.
  • SHEN v1/v2 and SHRD v1/v2 readers remain supported.
  • Display comments and holder labels are not cryptographically authenticated.

Wire-format changes require a separate compatibility and cryptographic review.

Documentation

Test

PYTHONPATH=src python -m unittest discover -s tests -v
PYTHONPATH=src python -O -m unittest discover -s tests -v

License

Dual-licensed under Apache-2.0 or MIT-0. See LICENSE and LICENSE-MIT-0.

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

shard_core-0.2.0.tar.gz (56.0 kB view details)

Uploaded Source

Built Distribution

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

shard_core-0.2.0-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

Details for the file shard_core-0.2.0.tar.gz.

File metadata

  • Download URL: shard_core-0.2.0.tar.gz
  • Upload date:
  • Size: 56.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for shard_core-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ba424d939391ea1071eb8fd5a2165d854e0e466cc94f967fee5e9e68b5b68995
MD5 b92e4b6abd7b9aebd1bdab9538934d47
BLAKE2b-256 d0c901e1114e221fd79a4751cb19606d17aae22f256e4d1d707d18fc09df1793

See more details on using hashes here.

Provenance

The following attestation bundles were made for shard_core-0.2.0.tar.gz:

Publisher: publish-pypi.yml on Protocol-Wealth/shard-core

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

File details

Details for the file shard_core-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: shard_core-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 34.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for shard_core-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3bc0c9c3be888e567eb693fed542c154ffa7c21aae64b4c6e8c0b268b766bbdc
MD5 d23488792ac482c0610309853a67217f
BLAKE2b-256 8de66ac1766ebc8625a2eb038fa5cf8b2a77c7c2c39e506c877128e1fb8f2a40

See more details on using hashes here.

Provenance

The following attestation bundles were made for shard_core-0.2.0-py3-none-any.whl:

Publisher: publish-pypi.yml on Protocol-Wealth/shard-core

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