Shamir Secret Sharing (SSS)

Cryptographically secure secret sharing for humans and machines

๐Ÿ”

High Security

Uses Mersenne prime field (2ยนยฒโท-1) for cryptographic operations. Resistant to brute-force attacks.

๐Ÿ“ฆ

Multi-Format Support

Split text, files, or binary data. Automatic chunking for secrets >1MB.

๐Ÿ› ๏ธ

Multiple Interfaces

Python API, command-line tool, and web interface with Flask.

See It in Action

Demo: Splitting and reconstructing a secret via CLI and Web UI

Shamir secret sharing interfaces

from shamir_ss import generate_text_shares, reconstruct_text_secret

def main():
    secret = "My top secret"

    shares = generate_text_shares(secret, 3, 5)

    reconstructed = reconstruct_text_secret(shares[:3])
    print(reconstructed)

if __name__ == "__main__":
    main()
Python Examples โ†’

Features

  • ๐Ÿ” Interactive secret input with hidden typing
  • ๐Ÿ“ Multiple input formats (files/directories/text)
  • ๐Ÿ›ก๏ธ SHA-256 hash verification
  • ๐Ÿ”„ Automatic share validation

Usage

python -m shamir_ss <command> <...args>

Command list

shamir_ss --help         # Show all commands
shamir_ss split --help   # Split command help
shamir_ss combine --help # Combine command help
shamir_ss help           # Detailed usage examples

Examples

python -m shamir_ss split \
  --secret "My top secret" \
  -t 3 -n 5 \
  --output shares
Split secret to 5 shares with treshold 3 and put output to shares dir
python -m shamir_ss combine \
  -i shares
Reconstruct secret from shares dir w/o hash validation (will be prompted interactively)
shamir_ss combine --text
Reconstruct secret using interactive mode
CLI Reference Guide โ†’
# Launch web client
python -m client

# Access at http://localhost:5000
Web UI Documentation โ†’

How Shard Works

Full API Documentation โ†’
1

Polynomial Generation: Creates a (t-1)-degree polynomial with the secret as the constant term.

2

Share Distribution: Evaluates the polynomial at n distinct points to generate shares.

3

Reconstruction: Uses Lagrange interpolation on any t shares to recover the secret.

Installation

PyPI (Stable)

pip install shamir_ss

GitHub (Latest)

pip install git+https://github.com/Team-Hype/shamir-secret-sharing