Package: otc
Oblivious transfer (OT) communications protocol message/response functionality implementations based onCurve25519and theRistrettogroup.PurposeThis library provides data structures and methods for a basicoblivious transfer (OT)communications protocol defined inwork by Chou and Orlandi. Thanks to the underlyingobliviouslibrary, method implementations rely on cryptographic primitives found within thelibsodiumlibrary.For more information and background about the underlying mathematical structures and primitives, consult materials aboutCurve25519, theRistrettogroup, and the relatedEd25519system.Installation and UsageThis library is available as apackage on PyPI:python -m pip install otcThe library can be imported in the usual manner:import otc
from otc import *ExampleSuppose that a sender wants to send exactly one of two payloads to a receiver (such as one of two decryption keys). Furthermore, the receiver does not want to reveal to the sender which of the two payloads they chose to receive. To begin, the sender can create asendobjects. The sender can then send the public keys.publicto the receiver (via some communication channel):>>> import otc
>>> s = otc.send()
>>> s.public.to_base64()
'LJKN1DmNwGiCGWl4O5DsJMIEnlJm6yhb1o2hYS8A4Hg='The receiver can create areceiveobject. Once they receives.publicfrom the sender (via some communications channel), they can use thereceiveobject’squerymethod to create an encrypted selection that the sender cannot decrypt. In the example below, the receiver is choosing the second message by supplying the integer1(where the two valid options are0or1):>>> r = otc.receive()
>>> selection = r.query(s.public, 1)The sender can then use itssendobject’sreplymethod to create two encrypted replies based on the receiver’s selection; the receiver willonly be able to decrypt the pre-selected payload, and the senderdoes not knowwhich of the two payloads can be decrypted by the receiver:>>> replies = s.reply(selection, bytes([0] * 16), bytes([255] * 16))Finally, the receiver can decrypt their chosen payload using thereceiveobject’selectmethod. The example below confirms that the receiver has indeed received an encrypted version of the second message:>>> r.elect(s.public, 1, *replies) == bytes([255] * 16)
TrueSee the articlePrivacy-Preserving Information Exchange Using Pythonfor a more detailed presentation of this example.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 -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 pytestAlternatively, all unit tests are included in the module itself and can be executed usingdoctest:python src/otc/otc.py -vStyle conventions are enforced usingPylint:python -m pip install .[lint]
python -m pylint src/otcContributionsIn 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 -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/*