Skip to content

DiXap/ShamirsSecretSharing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shamir's Secret Sharing

Generic badge Open Source Love png1 Generic badge
forthebadge made-with-python

Table of contents

About the Project

A basic cli app to encrypt and decrypt files using Shamir's Secret Sharing Scheme and AES.
Already been tested with the following file type:

  • .pdf
  • .tex
  • .txt
  • .py
  • .jpg

But it should work with any type of file

Getting Started

Since this app is all made with Python you're going to need some python-libraries and utilities listed below.

Prerequisites

  • First check that your current Python version is Python 3.6 or above, by running the following command on your terminal:

    $ python --version

    Python 3.8+ is recommended

    Note that in some linux distros you'll need to run it as:

    $ python3 --version
  • You migth as well check if you have PyPI as your Python package installer:
    Since this process vary for every Linux distro, I'll link you to an article explanning how to set PyPI up.

Instalation

  1. Clone the repo

    $ git clone https://github.com/DiXap/ShamirsSecretSharing.git
  2. Move to project's dir and run the following

    $ pip install -r requirements.txt
  3. The step above is going to automatically install packages needed for this project.
    If you want to install them manually, here's a list with the packages:

    • pycryptodome
    • pytest
    • numpy

You should have the following modules already in your python library, but here's a list of them if you want to check them:
* sys * getpass * pathlib * functools * random * time * sys * os * platform * unittest

Usage

Since this is a cli app, you're need to know the syntaxis:

$ python main.py <COMMAND> [COMMANDS ARGS]

where:

  • <COMMAND>, could be one of the following:

    Command Description
    -c Enable encryption mode
    -d Enable decryption mode
  • [COMMANDS ARGS], once a mode is enabled, proced with the corresponding arguments:

    Encrypt Description
    <share's destinaton file> File where the n evaluations of the polynomial will be stored
    <n> Total number of evaluations such as n>2
    <k> Minimun required evaluations to decrypt such as 1<k<=n
    <file to encrypt> File to encrypt

    Encryption example:

     $ python main.py -c /PATH/TO/shares.frg 13 7 /PATH/TO/very-secret-doc.pdf

    Note that you can grab the to-encrypt file from wherever place you have it stored, same goes for the shares' file, as they'll be dropped inside this project directory .

    You can use relative paths only if the file is inside project's dir

    You can specify the extension for the shares' file, altough if you leave it without one, it won't affect further decryption. 1

    Decrypt Description
    <file to decrypt> File to decrypt
    <file with shares> File containing all or at least the minimum evaluations to decrypt

    Decryption example:

     $ python main.py -d /PATH/TO/very-secret-doc.pdf.aes /PATH/TO/shares.frg

    Note that you can grab the encrypted file from wherever place you have it stored, same goes for the shares' file.

    You can use relative paths only if the file is inside project's dir

    No need to have your shares stored in a file with a specific extension. 1

    At any given time you can pass --help or -h to show help:

    $ python main.py --help

Shares File

Shares will be written as it follows:

XXXXXXXXXXXXXXXXXXXX,YYYYYYYYYYYYYYYYYYYYYY
XXXXXXXXXXXXXXXXXXXX,YYYYYYYYYYYYYYYYYYYYYY

As long as they're formatted as the above, shares' file extension shouldn't be a problem.
Already tested with the following extensions:

  • .txt
  • .frg
  • plain text (without extension)

You can even write your own file with the shares throwed by the encryption process

Tests

These test cases were coded to demostrate functions' error handling.
Feel free to play around with them at tests/. To run them you'll need to excecute the following from project's directory:

$ python -m pytest -v

Documentation

All documentation was generated using pdoc. You'll find it inside docs.
I personaly recommend switching to docs/ and then starting a local server to visualize them:

$ python -m http.server

Contact

Diego J. Padilla

Acknowledgements


forthebadge biult-with-love forthebadge powered-by-electricity


Go up

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages