Python library that serves as an API for common cryptographic primitives used to implement OPRF, OT, and PSI protocols.
Project description
Python library that serves as an API for common cryptographic primitives used to implement OPRF, OT, and PSI protocols.
Purpose
This library provides native Python implementations, Python libsodium wrappers, and additional utility methods for cryptographic primitives that are often used to implement oblivious pseudorandom function (OPRF), oblivious transfer (OT), and private set intersection (PSI) protocols.
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 oblivious
The library can be imported in the usual ways:
import oblivious from oblivious import *
Examples
This library supports concise construction of elliptic curve points and scalars:
>>> from oblivious import point, scalar >>> p = point.hash('abc'.encode()) # Point derived from a hash of a string. >>> s = scalar() # Random scalar.
Built-in Python operators are overloaded to support point operations (addition, subtraction, negation, and equality) and scalar operations (multiplication by a scalar and inversion of scalars):
>>> q = s * p >>> p == (~s) * q True >>> p == (((~s) * s)) * p True >>> p + q == q + p True
Because the classes point and scalar are derived from bytes, all methods and other operators supported by bytes objects are supported by point and scalar objects:
>>> hex = '35c141f1c2c43543de9d188805a210abca3cd39a1e986304991ceded42b11709' >>> s = scalar.fromhex(hex) >>> s.hex() '35c141f1c2c43543de9d188805a210abca3cd39a1e986304991ceded42b11709'
In addition, Base64 conversion methods are included to support concise encoding and decoding of point and scalar objects:
>>> s.to_base64() 'NcFB8cLENUPenRiIBaIQq8o805oemGMEmRzt7UKxFwk=' >>> s == scalar.from_base64('NcFB8cLENUPenRiIBaIQq8o805oemGMEmRzt7UKxFwk=') True
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 nose (see setup.cfg for configuration details):
python -m pip install nose coverage nosetests
Concise unit tests are implemented with the help of fountains; new reference specifications for these tests can be generated by running the testing module directly:
python test/test_oblivious.py
Style conventions are enforced using Pylint:
python -m pip install pylint pylint oblivious test/test_oblivious
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
Beginning with version 0.1.0, 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for oblivious-4.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | babee160cda8975824aa44be5b422091c9c5c9a8ae85ac8a82f9adc55fe06d78 |
|
MD5 | 7b8ac64f70fd5b44043555fc72f57b22 |
|
BLAKE2b-256 | c621fbbc5578a0e3d5b649685d2314123efaf5204d4b3af025afdc06d75dc40b |