Package: tinybio
Minimal pure-Python library that implements a basic version of asecure decentralized biometric authenticationfunctionality via asecure multi-party computation protocol.Installation and UsageThis library is available as apackage on PyPI:python-mpipinstalltinybioThe library can be imported in the usual way:importtinybiofromtinybioimport*Basic ExampleSuppose that a workflows is supported by three nodes (parties performing the decentralized registration and authentication functions). The node objects would be instantiated locally by each of these three parties:>>>nodes=[node(),node(),node()]The preprocessing phase that the nodes must execute can be simulated. The second parameter specifies the length of a biometric descriptor (i.e., list of floating point values):>>>preprocess(nodes,length=4)Suppose the client has a biometric descriptor represented as a vector offloatvalues. The client can create a request for masks and then obtain masks from each node. The client can then locally generate a registrationtoken(i.e., a masked descriptor that is computed locally by the registering party):>>>reg_descriptor=[0.5,0.3,0.7,0.1]>>>reg_masks=[node.masks(request.registration(reg_descriptor))fornodeinnodes]>>>reg_token=token.registration(reg_masks,reg_descriptor)At a later point, the client can perform an authentication workflow. After requesting masks for the authentication descriptor in a manner similar to the above, the client can generate an authenticationtoken(i.e., a masked descriptor) locally:>>>auth_descriptor=[0.1,0.4,0.8,0.2]>>>auth_masks=[node.masks(request.authentication(auth_descriptor))fornodeinnodes]>>>auth_token=token.authentication(auth_masks,auth_descriptor)Finally, the party interested in authenticating itself can broadcast its original registration token together with its authentication token. Each node can then compute locally its share of the authentication result. These shares can be reconstructed by the validating party to obtain the result (i.e., the Euclidean distance between the registration and authentication descriptors):>>>shares=[node.authenticate(reg_token,auth_token)fornodeinnodes]>>>reveal(shares)# Floating point results may differ slightly.0.43375208257785347The above result can be compared to that of a calculation that uses the original descriptors. The results are exactly equivalent due to the conversion from floating point values to a fixed-point representation during masking:>>>importmath>>>math.sqrt(sum([(x-y)**2for(x,y)inzip(reg_descriptor,auth_descriptor)]))0.43378989435406744DevelopmentAll 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/tinybio/tinybio.py-vStyle conventions are enforced usingPylint:python-mpipinstall.[lint]python-mpylintsrc/tinybioContributionsIn 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/*