Package: tinyvote
Minimal pure-Python library that demonstrates a basic encrypted voting workflow by leveraging a secure multi-party computation (MPC)protocol.PurposeThis library demonstrates how a functionality can be implemented using asecure multi-party computation (MPC) protocolfor evaluating arithmetic sum-of-products expressions (as implemented intinynmc). The approach used in this library can serve as a template for any workflow that relies on multiple simultaneous instances of such a protocol.Installation and UsageThis library is available as apackage on PyPI:python-mpipinstalltinyvoteThe library can be imported in the usual way:importtinyvotefromtinyvoteimport*Basic ExampleSuppose that a secure decentralized voting workflow is supported by three parties. Thenodeobjects would be instantiated locally by each of these three parties:>>>nodes=[node(),node(),node()]The preprocessing workflow that the nodes must execute can be simulated. The number of voters that the workflow supports must be known, and it is assumed that all permitted choices are integers greater than or equal to0and strictly less than a fixed maximum value. The number of voters and the number of distinct choices can be supplied to the preprocessing simulation:>>>preprocess(nodes,votes=4,choices=2)Each voter must submit a request for the opportunity to submit a vote. Below, each of the four voters creates such a request:>>>request_zero=request(identifier=0)>>>request_one=request(identifier=1)>>>request_two=request(identifier=2)>>>request_three=request(identifier=3)Each voter can deliver a request to each node, and each node can then locally generate masks that can be returned to the requesting voter:>>>masks_zero=[node.masks(request_zero)fornodeinnodes]>>>masks_one=[node.masks(request_one)fornodeinnodes]>>>masks_two=[node.masks(request_two)fornodeinnodes]>>>masks_three=[node.masks(request_three)fornodeinnodes]Each voter can then generate locally avoteinstance (i.e., a masked vote choice):>>>vote_zero=vote(masks_zero,0)>>>vote_one=vote(masks_one,1)>>>vote_two=vote(masks_two,1)>>>vote_three=vote(masks_three,1)Every voter can broadcast its masked vote choice to all the nodes. Each node can locally assemble these as they arrive. Once a node has received all masked votes, it can determine its shares of the overall tally of the votes:>>>shares=[...node.outcome([vote_zero,vote_one,vote_two,vote_three])...fornodeinnodes...]The overall outcome can be reconstructed from the shares by the voting workflow operator. The outcome is represented as alistin which each entry contains the tally for the choice corresponding to the entry’s index:>>>reveal(shares)[1,3]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/tinyvote/tinyvote.py-vStyle conventions are enforced usingPylint:python-mpipinstall.[lint]python-mpylintsrc/tinyvoteContributionsIn 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/*