Package: xors
Abstractable XOR-based threshold secret sharing implementation in pure-Python.PurposeThis library provides functions and data structures for computing secret shares given an integer input value and for reassembling an integer from its corresponding secret shares.  UnlikeShamir’s Secret Sharing scheme, the XOR-based scheme this library implements does not require any Lagrange interpolation or even finite fields!  Reconstruction is as simple as _t_ group operations - no commutivity necessary!Installation and UsageThis library is available as apackage on PyPI:python -m pip install xorsThe library can be imported in the usual way:import xorsExamplesThe library provides functions for transforming a nonnegative integer value into a number of secret shares and for reassembling those shares back into the value they represent:>>> ss = xors.shares(123, quantity=3)
>>> len(ss)
3
>>> xors.interpolate(ss)
123
>>> ss = xors.shares(456, quantity=20, modulus=15485867, threshold=10)
>>> xors.interpolate(ss[5:15], threshold=10)
456Addition of shares and multiplication of shares by a scalar are both supported:>>> (r, s, t) = xors.shares(123, 3)
>>> (u, v, w) = xors.shares(456, 3)
>>> xors.interpolate([r + u, s + v, t + w])
579
>>> (r, s, t) = xors.shares(123, 3)
>>> r = r * 2
>>> s = s * 2
>>> t = t * 2
>>> xors.interpolate([r, s, t])
246DevelopmentAll installation and development dependencies are fully specified inpyproject.toml. Theproject.optional-dependenciesobject is used tospecify optional requirementsfor various development tasks. This makes it possible to specify additional options (such asdocs,lint, and so on) when performing installation usingpip:python -m pip install .[docs,lint]DocumentationThe documentation can be generated automatically from the source files usingSphinx:python -m pip install .[docs]
cd docs
sphinx-apidoc -f -E --templatedir=_templates -o _source .. && make htmlTesting and ConventionsAll unit tests are executed and their coverage is measured when usingpytest(see thepyproject.tomlfile for configuration details):python -m pip install .[test]
python -m pytest -W ignore::UserWarningAlternatively, all unit tests are included in the module itself and can be executed usingdoctest:python src/xors/xors.py -vStyle conventions are enforced usingPylint:python -m pip install .[lint]
python -m pylint src/xorsContributionsIn order to contribute to the source code, open an issue or submit a pull request on theGitHub pagefor this library.VersioningBeginning with version 1.0.0, the version number format for this library and the changes to the library associated with version number increments conform withSemantic Versioning 2.0.0.PublishingThis library can be published as apackage on PyPIby a package maintainer. First, install the dependencies required for packaging and publishing:python -m pip install .[publish]Ensure that the correct version number appears inpyproject.toml, and that any links in this README document to the Read the Docs documentation of this package (or its dependencies) have appropriate version numbers. Also ensure that the Read the Docs project for this library has anautomation rulethat activates and sets as the default all tagged versions. Create and push a tag for this version (replacing?.?.?with the version number):git tag ?.?.?
git push origin ?.?.?Remove any old build/distribution files. Then, package the source into a distribution archive:rm -rf build dist src/*.egg-info
python -m build --sdist --wheel .Finally, upload the package distribution archive toPyPI:python -m twine upload dist/*