Package: exclusive
Data structure for representing secret shares of byte vectors based on bitwise XOR, designed for use within secure multi-party computation (MPC) protocol implementations.PurposeThis library provides a data structure and methods that make it possible to work withn-out-of-nXOR-basedsecret sharesof bytes-like objects within secure multi-party computation (MPC) protocol implementations. Secret shares are represented using instances of class derived frombytes, and functions are provided both for splitting bytes-like objects into shares and for reconstructingbytesobjects from shares.Installation and UsageThis library is available as apackage on PyPI:python-mpipinstallexclusiveThe library can be imported in the usual ways:importexclusivefromexclusiveimport*ExamplesThis library makes it possible to concisely construct multiple XOR-based secret shares from a bytes-like object:>>>fromexclusiveimportshares,xor>>>(a,b)=shares(bytes([1,2,3]))>>>(c,d)=shares(bytes([4,5,6]))>>>((a^c)^(b^d))==xor([bytes([1,2,3]),bytes([4,5,6])])TrueThe number of shares can be specified explicitly (the default is two shares):>>>(r,s,t)=shares(bytes([1,2,3]),quantity=3)For convenience, anxoroperator that is analogous to Python’s built-insumfunction is provided:>>>xor([bytes([1,2,3]),bytes([4,5,6])]).hex()'050705Theshareclass is derived from thebytesclass. Thus, all methods, operators, and functions that operate on bytes-like objects are supported forshareobjects. Thexoroperator provided by the library relies on Python’sbuilt-in exclusive or operatorand can be used for concise reconstruction of values from a collection of secret shares:>>>xor([r,s,t])==bytes([1,2,3])TrueIn addition, conversion methods for Base64 strings are included to support encoding and decoding ofshareobjects:>>>share.from_base64('HgEA').hex()'1e0100'>>>[s.to_base64()forsinshares(bytes([1,2,3]))]['mB6G','mRyF']DevelopmentAll 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-mpipinstall.[docs,lint]DocumentationThe documentation can be generated automatically from the source files usingSphinx:python-mpipinstall.[docs]cddocssphinx-apidoc-f-E--templatedir=_templates-o_source..&&makehtmlTesting and ConventionsAll unit tests are executed and their coverage is measured when usingpytest(see thepyproject.tomlfile for configuration details):python-mpipinstall.[test]python-mpytestAlternatively, all unit tests are included in the module itself and can be executed usingdoctest:pythonsrc/exclusive/exclusive.py-vStyle conventions are enforced usingPylint:python-mpipinstall.[lint]python-mpylintsrc/exclusiveContributionsIn order to contribute to the source code, open an issue or submit a pull request on theGitHub pagefor this library.VersioningThe 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-mpipinstall.[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):gittag?.?.?gitpushorigin?.?.?Remove any old build/distribution files. Then, package the source into a distribution archive:rm-rfbuilddistsrc/*.egg-infopython-mbuild--sdist--wheel.Finally, upload the package distribution archive toPyPI:python-mtwineuploaddist/*