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.
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:
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) # Evaluates to `bytes([255] * 16)`.
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:
python -m pip install sphinx sphinx-rtd-theme cd docs 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 nose (see setup.cfg for configuration details):
python -m pip install nose coverage nosetests
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 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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.