Skip to main content

Oblivious transfer (OT) communications protocol message/response functionality implementations based on Curve25519 primitives.

Project description

Oblivious transfer (OT) communications protocol message/response functionality implementations based on Curve25519 primitives, including both pure-Python and libsodium-based variants.

PyPI version and link. Read the Docs documentation status. GitHub Actions status. Coveralls test coverage summary.

Purpose

This library provides data structures and methods for a basic oblivious transfer (OT) communications protocol defined in work by Chou and Orlandi. Thanks to the underlying oblivious library, users of this library have the option of relying either on pure Python implementations of cryptographic primitives or on wrappers for libsodium.

For more information and background about the underlying mathematical structures and primitives, consult materials about Curve25519, the Ristretto group, and the related Ed25519 system.

Package Installation and Usage

The package is available on PyPI:

python -m pip install otc

The library can be imported in the usual manner:

import otc
from otc import *

Example

Suppose 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 creates a sender object s with a public key s.public that should be sent to the receiver:

>>> import otc
>>> s = otc.send()

The receiver can then create a receiver object and use s.public to make an encrypted selection that the sender cannot decrypt:

>>> r = otc.receive()
>>> selection = r.query(s.public, 1)

The sender can then send two encrypted replies based on the receiver’s selection; the receiver will only be able to decrypt the pre-selected payload, and the sender does not know which 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:

>>> r.elect(s.public, 1, *replies) == bytes([255] * 16) # Second message.
True

See the article Privacy-Preserving Information Exchange Using Python for a more detailed presentation of the this example.

Documentation

The documentation can be generated automatically from the source files using Sphinx:

cd docs
python -m pip install -r requirements.txt
sphinx-apidoc -f -E --templatedir=_templates -o _source .. ../setup.py && make html

Testing and Conventions

All unit tests are executed and their coverage is measured when using pytest (see setup.cfg for configuration details):

python -m pip install pytest pytest-cov
python -m pytest

Alternatively, all unit tests are included in the module itself and can be executed using doctest:

python otc/otc.py -v

Style conventions are enforced using Pylint:

python -m pip install pylint
python -m pylint otc

Contributions

In order to contribute to the source code, open an issue or submit a pull request on the GitHub page for this library.

Versioning

The version number format for this library and the changes to the library associated with version number increments conform with Semantic Versioning 2.0.0.

Publishing

This library can be published as a package on PyPI by a package maintainer. Install the wheel package, remove any old build/distribution files, and package the source into a distribution archive:

python -m pip install wheel
rm -rf dist *.egg-info
python setup.py sdist bdist_wheel

Next, install the twine package and upload the package distribution archive to PyPI:

python -m pip install twine
python -m twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

otc-3.0.0.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

otc-3.0.0-py3-none-any.whl (5.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page