Package: oprf
Oblivious pseudo-random function (OPRF) protocol functionality implementations based onCurve25519and theRistrettogroup.PurposeThis library provides data structures and methods for a basicoblivious pseudo-random function (OPRF)protocol. Method implementations rely on cryptographic primitives involving theRistrettogroup that are exported by theobliviouslibrary. By default, these are wrappers for functions found in the subset of thelibsodiumlibrary that is bundled with therbcllibrary.Installation and UsageThis library is available as apackage on PyPI:python-mpipinstalloprfBy default, this library indirectly relies onrbcl(which bundles a subset of thelibsodiumlibrary that is compiled for common architectures). However, it is possible to install a fully working pure-Python version of this library by installing only the pure-Python subset of theobliviousdependency (i.e., within an environment whererbclis not a required dependency of other installed packages). This approach makes it possible to use this library for rapid prototyping on exotic architectures (with the caveat that pure-Python implementations of primitives are much slower):python-mpipinstalloblivious~=7.0python-mpipinstalloprf--no-dependenciesThe library can be imported in the usual ways:importoprffromoprfimport*ExamplesThis library makes it possible to concisely prepare binary or string data for masking:>>>fromoprfimportdata,mask>>>d=data.hash('abc')A random mask can be constructed and applied to the data. A number of distinct notations is supported for masking in order to minimize differences between the notation within a protocol definition and its implementation:>>>m=mask()# Create random mask.>>>m.mask(d)==m(d)==m*dTrue>>>m(d)==dFalseMask inversion and unmasking are also supported:>>>c=m(d)>>>m.unmask(c)==(~m)(c)==c/m==dTrueMasks can also be constructed deterministically from a bytes-like object or string:>>>m=mask.hash('123')Because the classesdataandmaskare derived frombytes,all methods and other operatorssupported bybytesobjects are supported bydataandmaskobjects:>>>hex='a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27a03'>>>m=mask.fromhex(hex)>>>m.hex()'a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27a03'In addition, Base64 conversion methods are included to support concise encoding and decoding ofdataandmaskobjects:>>>d.from_base64(d.to_base64())==dTrue>>>m.from_base64(m.to_base64())==mTrueDevelopmentAll 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/oprf/oprf.py-vStyle conventions are enforced usingPylint:python-mpipinstall.[lint]python-mpylintsrc/oprfContributionsIn 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/*