{ "info": { "author": "HacKan", "author_email": "hackan@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Other Environment", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Natural Language :: English", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Security :: Cryptography", "Topic :: Utilities", "Typing :: Typed" ], "description": "[![GitHub license](https://img.shields.io/github/license/hackancuba/secretshare-py.svg)](https://github.com/HacKanCuBa/secretshare-py/blob/master/LICENSE) \n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/secretshare-py.svg)](https://pypi.python.org/pypi/secretshare/) \n[![PyPI version](https://badge.fury.io/py/secretshare.svg)](https://badge.fury.io/py/secretshare-py) \n[![GitHub release](https://img.shields.io/github/release/hackancuba/secretshare-py.svg)](https://github.com/hackancuba/secretshare-py/releases/) \n[![GitHub version](https://badge.fury.io/gh/hackancuba%2Fsecretshare-py.svg)](https://badge.fury.io/gh/hackancuba%2Fsecretshare-py) \n[![Updates](https://pyup.io/repos/github/HacKanCuBa/secretshare-py/shield.svg)](https://pyup.io/repos/github/HacKanCuBa/secretshare-py/) \n[![Build Status](https://travis-ci.org/HacKanCuBa/secretshare-py.svg?branch=master)](https://travis-ci.org/HacKanCuBa/secretshare-py) \n\n# SecretShare\n\nA simple library implementing Adi Shamir's \"How to share a secret\" algorithm. It is currently very limited since it uses integer arithmetic with primes, thus limiting the size of the shared secret to 8192 bits (1024 bytes). A future version might implement some form of unlimited stream share, but it is not its current goal, which is being used on cryptographic applications.\n\nThis library is part of the [Dungeon Password Manager](https://git.rlab.be/hackan/dungeon) project.\n\n## Requirements\n\n* Python 3.6+\n* [Passphrase](http://github.com/hackancuba/passphrase-py)\n\n## Installation\n\nClone the repo an run `make package-install` or, for development purposes, `make devenvironment`. Install dependencies with `pipenv install` or `pip install -r requirements.txt`.\n\n## Usage\n\n```python\nfrom secretshare import Secret, SecretShare, Share\n\n\ndef email(recipient, body):\n \"\"\"Simulate sending an email.\"\"\"\n print(f'Recipient: {recipient} - Body: {body}')\n\n\n# Generate a new random secret\nsecret = Secret()\n# Or use an existing one\nsecret.value = 12345267890\n# Or directly: secret = Secret(1234567890)\n# If your secret is not an integer, you can use these methods\n# from_bytes()\n# from_base64()\n# from_hex()\n\n# Share the secret\nshare_count = 5 # How many pieces will the secret be split into?\nthreshold = 3 # How many pieces are required to recover the secret?\nshamir = SecretShare(threshold, share_count, secret=secret)\nshares = shamir.split()\nprint(shamir.shares) # [Share(point=1, value=110014556089737955654312725615756332615), Share(point=2, value=270561733948920165984210681299343881767), Share(point=3, value=141359166656608167526319259631339703839), Share(point=4, value=62689221133740423744013068043512010338), Share(point=5, value=34551897380316934637292106535860801264)]\n# shamir.shares are the same as `shares`, returned by the split() method\n\n# Now deliver the shares to each recipient\nrecipients = ('r1@email.com', 'r2@email.com', 'r3@email.com', 'r4@email.com',\n 'r5@email.com')\nfor i, share in enumerate(shares):\n email(recipients[i], str(share)) # Send in base64\n# A Share can be converted to several convenient formats:\n# bytes(share), share.to_bytes()\n# str(share)\n# share.to_hex(), hexlify(bytes(share))\n# share.to_base64()\n# Note: a Secret can be converted the very same way\n\n# To recover the secret, get the share from each holder \n# Each Share has a point and a value\ns1 = Share(1, 335597737083070970356431407479895583486)\ns2 = Share(2, 138424231339574140617068979728677909704)\ns4 = Share()\n# They are both encoded together for convenience\ns4.from_base64('BQBGQMaGiRzWb0gO3gGEotVL')\n# The share count and threshold information is NOT saved anywhere\n# so the developer must save it somewhere as it is public\n# information and there's no risk in storing it.\n# As a matter of fact, those parameters are not really needed to recover a\n# secret. If you provide less shares than the threshold then you will get a\n# secret value that will be incorrect. There's no way to tell from the result\n# whether the amount of shares are actually correct or not.\nshamir = SecretShare(threshold, share_count, shares=[s1, s2, s4])\nsecret = shamir.combine()\nprint(secret) # At/V1rI=\nprint(int(secret)) # 1234567890\n# If the wrong number of shares is provided, an incorrect result\n# is obtained. This is because this algorithm can't validate the result.\n# The developer should verify the secret obtained by comparing into\n# a hash, preferably using a secure KDF such as Argon2.\n# Alternatively, it might be more convenient to verify each share\n# against a hash: if the provided shares are valid the result\n# will be correct.\n```\n\n## Developing\n\nInstall the development requirements, run tests with `make test` and lint with `make lint`. Check for tests coverage with `make coverage` (must be 100%).\n\n## License\n\n**SecretShare** is made by [HacKan](https://hackan.net) under GNU GPL v3.0+. You are free to use, share, modify and share modifications under the terms of that [license](LICENSE).\n\n Copyright (C) 2018 HacKan (https://hackan.net)\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see .\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/HacKanCuBa/secretshare-py/releases", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/hackancuba/secretshare-py", "keywords": "cryptography shamir secret share security", "license": "GPLv3+", "maintainer": "", "maintainer_email": "", "name": "secretshare", "package_url": "https://pypi.org/project/secretshare/", "platform": "POSIX :: Linux", "project_url": "https://pypi.org/project/secretshare/", "project_urls": { "Download": "https://github.com/HacKanCuBa/secretshare-py/releases", "Homepage": "http://github.com/hackancuba/secretshare-py" }, "release_url": "https://pypi.org/project/secretshare/0.6.0/", "requires_dist": [ "hc-passphrase" ], "requires_python": ">=3.6", "summary": "Share a secret securely implementing Shamir's secret share", "version": "0.6.0" }, "last_serial": 5466751, "releases": { "0.2.5": [ { "comment_text": "", "digests": { "md5": "ae983dea3f5db33f226d0a99647ba153", "sha256": "ffeccd68d0aafc6480264f6a73f5fbe05404bec5f5d7de8f215bc3ed71a16e9a" }, "downloads": -1, "filename": "secretshare-0.2.5-py3-none-any.whl", "has_sig": true, "md5_digest": "ae983dea3f5db33f226d0a99647ba153", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 21195, "upload_time": "2018-12-18T03:19:19", "url": "https://files.pythonhosted.org/packages/2e/42/2b4861cc562d6bbfb88ee9d06f1a7291d45293f81b9869733df1eeeff777/secretshare-0.2.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2033e64c000dfbc2540418475bcb46f8", "sha256": "acfcfa7a6e6ae815bc91b075efa315579d47874fe2db00359d7186eda4edba16" }, "downloads": -1, "filename": "secretshare-0.2.5.tar.gz", "has_sig": true, "md5_digest": "2033e64c000dfbc2540418475bcb46f8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 20365, "upload_time": "2018-12-18T03:19:21", "url": "https://files.pythonhosted.org/packages/05/c5/3ce206be5dc3a57cb9b79de7978eb2b74cf59d9576a9f288328dec73da25/secretshare-0.2.5.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "e3deb9e427f500f6590b511a93b36ac9", "sha256": "6ec93518742e849aa4fe7c0f4d11faf72aa6798dee84aea9606ffdcf9f5eca2b" }, "downloads": -1, "filename": "secretshare-0.4.2-py3-none-any.whl", "has_sig": false, "md5_digest": "e3deb9e427f500f6590b511a93b36ac9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 21863, "upload_time": "2018-12-19T04:54:55", "url": "https://files.pythonhosted.org/packages/5e/0f/98c16084f7e09b56bcc10460abfe8a7e9bfc69a24584e63e7f96262a9ab5/secretshare-0.4.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d52bd014f1652f333c98041438f5ded4", "sha256": "146c870ee8dc397a07ab851c2ec4b9f9e6bc1af1531918d09b684723ffdf1f14" }, "downloads": -1, "filename": "secretshare-0.4.2.tar.gz", "has_sig": false, "md5_digest": "d52bd014f1652f333c98041438f5ded4", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 21007, "upload_time": "2018-12-19T04:54:57", "url": "https://files.pythonhosted.org/packages/e2/74/f0f3d29bf801a4f1ad4e9677c9da05d0fa38839c987ec21097bbb474ae48/secretshare-0.4.2.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "7da33f078fdd477551616c6a7ec2a07c", "sha256": "936e77d38048d2ef46e8422ffd4ddd9bccf02e2dac9925822a79526662bcd7db" }, "downloads": -1, "filename": "secretshare-0.5.0-py3-none-any.whl", "has_sig": true, "md5_digest": "7da33f078fdd477551616c6a7ec2a07c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 22944, "upload_time": "2019-06-25T01:44:41", "url": "https://files.pythonhosted.org/packages/80/56/6746e244a85795794adce34ee44d55419aeedf72d7727252ddb2f58981f1/secretshare-0.5.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "122a9a245ffbc262ed51f228b0c09d18", "sha256": "fd4d51fd775178e1b74fa684c82567aed7a1c5f9f7b09e30242453b07f97d82c" }, "downloads": -1, "filename": "secretshare-0.5.0.tar.gz", "has_sig": true, "md5_digest": "122a9a245ffbc262ed51f228b0c09d18", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 22552, "upload_time": "2019-06-25T01:44:44", "url": "https://files.pythonhosted.org/packages/34/d6/7d6c7122b581dcf0480c72c82341188a1d5c569aef4ac52969aed9fc1add/secretshare-0.5.0.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "adcccd5ca453614c5c87d9f8d1028efd", "sha256": "9a36e860663a57f0065d27846bf1a0402fae7968e1bee369dcccc69cbf93cc18" }, "downloads": -1, "filename": "secretshare-0.6.0-py3-none-any.whl", "has_sig": true, "md5_digest": "adcccd5ca453614c5c87d9f8d1028efd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 27315, "upload_time": "2019-06-30T01:34:44", "url": "https://files.pythonhosted.org/packages/56/9e/ab83237a0d7532803483529f236a31db1cab7f9496197509d5cb7e3c3688/secretshare-0.6.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "34a334150696b81037b187b828bac79b", "sha256": "b02b3c0b325f05123c220ae49c876c228f42e1b6ce8409a7ef701e903517c130" }, "downloads": -1, "filename": "secretshare-0.6.0.tar.gz", "has_sig": true, "md5_digest": "34a334150696b81037b187b828bac79b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 27587, "upload_time": "2019-06-30T01:34:46", "url": "https://files.pythonhosted.org/packages/03/f9/0991014000e222ef636b2c81f3bd481691778e1059b9d215a119b5cef7bd/secretshare-0.6.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "adcccd5ca453614c5c87d9f8d1028efd", "sha256": "9a36e860663a57f0065d27846bf1a0402fae7968e1bee369dcccc69cbf93cc18" }, "downloads": -1, "filename": "secretshare-0.6.0-py3-none-any.whl", "has_sig": true, "md5_digest": "adcccd5ca453614c5c87d9f8d1028efd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 27315, "upload_time": "2019-06-30T01:34:44", "url": "https://files.pythonhosted.org/packages/56/9e/ab83237a0d7532803483529f236a31db1cab7f9496197509d5cb7e3c3688/secretshare-0.6.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "34a334150696b81037b187b828bac79b", "sha256": "b02b3c0b325f05123c220ae49c876c228f42e1b6ce8409a7ef701e903517c130" }, "downloads": -1, "filename": "secretshare-0.6.0.tar.gz", "has_sig": true, "md5_digest": "34a334150696b81037b187b828bac79b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 27587, "upload_time": "2019-06-30T01:34:46", "url": "https://files.pythonhosted.org/packages/03/f9/0991014000e222ef636b2c81f3bd481691778e1059b9d215a119b5cef7bd/secretshare-0.6.0.tar.gz" } ] }