Python library that bundles libsodium and provides wrappers for its Ristretto group functions.
Project description
Python library that bundles libsodium and provides wrappers for its Ristretto group functions.
Installation and Usage
This library is available as a package on PyPI:
python -m pip install rbcl
The library can be imported in the usual ways:
import rbcl
from rbcl import *
Examples
A few usage examples are presented below:
>>> from rbcl import *
>>> x = crypto_core_ristretto255_random()
>>> assert crypto_core_ristretto255_is_valid_point(x)
>>> y = crypto_core_ristretto255_from_hash(b'\xF0' * 64)
>>> assert crypto_core_ristretto255_is_valid_point(y)
>>> z1 = crypto_core_ristretto255_add(x, y)
>>> z2 = crypto_core_ristretto255_add(y, x)
>>> assert z1 == z2 # Point addition commutes.
>>> s1 = crypto_core_ristretto255_scalar_random()
>>> s2 = crypto_core_ristretto255_scalar_random()
>>> w1 = crypto_scalarmult_ristretto255(s1, crypto_scalarmult_ristretto255(s2, x))
>>> w2 = crypto_scalarmult_ristretto255(s2, crypto_scalarmult_ristretto255(s1, x))
>>> assert w1 == w2 # Multiplication of a point by a scalar is repeated addition.
This library exports Python wrappers for constructors, point arithmetic functions, and scalar arithmetic functions.
Development, Build, and Manual Installation Instructions
All development and installation dependencies are managed using setuptools and are fully specified in setup.cfg. The extras_require option is used to specify optional requirements for various development tasks. This makes it possible to specify additional options (such as docs, lint, and so on) when performing installation using pip (assuming that the library has already been built successfully):
python -m pip install .[docs,lint]
Building from Source
The library can be built manually from source within Linux and macOS using the sequence of commands below:
python -m pip install .[build]
python -m build --sdist --wheel .
Developing the library further in a local environment and/or building the library from source requires libsodium. The step python -m build --sdist --wheel . in the above attempts to automatically locate a copy of the libsodium source archive src/rbcl/libsodium.tar.gz. If the archive corresponding to the operating system is not found, the build process attempts to download it. To support building offline, it is necessary to first download the appropriate libsodium archive to its designated location:
wget -O src/rbcl/libsodium.tar.gz https://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gz
The process for building manually from source within a Windows environment is not currently documented, but an example of one sequence of steps can be found in the Windows job entry within the GitHub Actions workflow defined in the file .github/workflows/lint-test-cover-docs-build-upload.yml.
Preparation for Local Development
Before documentation can be generated or tests can be executed, it is necessary to run the build process and then to use the command below to move the compiled libsodium shared/dynamic library file into its designated location (so that the module file src/rbcl/rbcl.py is able to import it):
cp build/lib*/rbcl/_sodium.py src/rbcl
Manual Installation
Once the package is built, it can be installed manually using the command below:
python -m pip install -f dist . --upgrade
Documentation
Once the libsodium shared library file is compiled and moved into its designated location (as described in the relevant subsection above), the documentation can be generated automatically from the source files using Sphinx:
python -m pip install .[docs]
cd docs
sphinx-apidoc -f -E --templatedir=_templates -o _source .. ../src/rbcl/_sodium_build.py && make html
Testing and Conventions
Before unit tests can be executed, it is first necessary to prepare for local development by compiling and moving into its designated location the libsodium shared library file (as described in the relevant subsection above).
All unit tests are executed and their coverage is measured when using pytest (see pyproject.toml for configuration details):
python -m pip install .[test]
python -m pytest
Alternatively, all unit tests are included in the module itself and can be executed using doctest:
python src/rbcl/rbcl.py -v
Style conventions are enforced using Pylint:
python -m pip install .[lint]
python -m pylint src/rbcl src/rbcl/_sodium.tmpl src/rbcl/_sodium_build.py --disable=duplicate-code
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. First, install the dependencies required for packaging and publishing:
python -m pip install .[publish]
Ensure that the correct version number appears in setup.cfg, 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 an automation rule that 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 .
Next, navigate to the appropriate GitHub Actions run of the workflow defined in lint-test-cover-docs-build-upload.yml. Click on the workflow and scroll down to the Artifacts panel. Download the archive files to the dist directory. Unzip all the archive files so that only the *.whl files remain:
cd dist && for i in `ls *.zip`; do unzip $i; done && rm *.zip && cd ..
Finally, upload the package distribution archive to PyPI:
python -m twine upload dist/*
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 Distributions
Hashes for rbcl-1.0.1-cp311-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5076914e7bf623d6e5d464faebb15521d8040887872a2a32ffa72417b5a4dafa |
|
MD5 | 00f2ac1dda3b19f7458a8ab8b87e7423 |
|
BLAKE2b-256 | f4a31f2ed97b596cea83262fd26c398f290eb1fbe8a60c57e7742c739ec9751b |
Hashes for rbcl-1.0.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83b36a6230ba46ac6b5c16a44fe2713f997297fcf5b515907c0e9c7dbc1265af |
|
MD5 | a9efad5266c0794bc608257a72309460 |
|
BLAKE2b-256 | e14fab87197c76fe4f2204983a9cf73ed0e336f978852edd1148baeefc40ee44 |
Hashes for rbcl-1.0.1-cp311-abi3-macosx_10_10_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc849acb88e123c1c80ccffd6062d8467cb7cc39e525578078b9137ec7c335ae |
|
MD5 | 88fb9fa19ce4b021e50f8da306853780 |
|
BLAKE2b-256 | 909ef848741bce45b3a9649251353630fbd5651725ae0673b038ecc61739f987 |
Hashes for rbcl-1.0.1-cp310-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eefa29543e19b245820dddbb813304182066c516960acbbfb77910e74c78d1fc |
|
MD5 | 59de828baac9566f9a69f44c4d782741 |
|
BLAKE2b-256 | be9be6eafbfaca01ca27f1293d654a1a01f7037f91ffd5567012237ff9872ef7 |
Hashes for rbcl-1.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7cfd4dd903decc2b22353128eed9887275d628c30c9259ac5d35c20fe04bf3c |
|
MD5 | 1675e00c87d2988623623f8f557d84d6 |
|
BLAKE2b-256 | 77cb98758f497ac1766c68fc368b68b4b3bb88ce6be683ebd2731a719f92d6d3 |
Hashes for rbcl-1.0.1-cp310-abi3-macosx_10_10_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52a0e2127c899849cb566185b1970b098b8bff1746c2ee3d048fe493f10967dc |
|
MD5 | 61dac2fd33efe8f78c2567cc8df6f1c2 |
|
BLAKE2b-256 | 27a97870a0d364a2a3eee170e3cf3a72bb6e5c342da2813f6f941485e0eb7333 |
Hashes for rbcl-1.0.1-cp39-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 926738780b5602ccebec140cedf160c55fe76ab2ca0a3870726053c2b2baa8ad |
|
MD5 | 6d77e76d0f86a8dd85295d8dec4d1899 |
|
BLAKE2b-256 | 4f76af322e0078ce3bdded44fed3cf7e3aecc2a8836fd7dfdc5ece6d1f5b8922 |
Hashes for rbcl-1.0.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53e6f1c0d87c543cb9da13129ff11defc98da4fbb8d187812c0d4c50cf2bdec2 |
|
MD5 | bc1ea4d1547e09a17a335f2249a45516 |
|
BLAKE2b-256 | f95111b16c06fe41ce0ebc6eb448a56205733886bc891afa184938872ce634ab |
Hashes for rbcl-1.0.1-cp39-abi3-macosx_10_10_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fd2e45429bd2a7b1fe6b00922d403ba46b10c2a16be00c77a528edab5351cdc |
|
MD5 | c27d37634d372b6c3680406fe747bd96 |
|
BLAKE2b-256 | 84202d69831055960348c61bfcef431fb0661434926df75ae896900a8c320e71 |
Hashes for rbcl-1.0.1-cp39-abi3-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9eeb433d2f36e2f0bb6e5b42ef863045a676da3f700e04b8dd2c79b752942b9f |
|
MD5 | 60883f715d93f2eccc84b33d57c079aa |
|
BLAKE2b-256 | 14b97a3dfa00601072289f7355a8159adc185056ded21b088c199734dec5540d |
Hashes for rbcl-1.0.1-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5673d5ef568a277dcf0caeaf3d8a5ce82eeb957782b30edc6ce8eb5c83955b3 |
|
MD5 | ef346f0c697dca3f4359da2cf25e2cb9 |
|
BLAKE2b-256 | 8f684c07b57e405f02bae88d9830652a634e087a93c8effbceeda3912cc537e5 |
Hashes for rbcl-1.0.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ff5fc79ff4410541bdb25a63c8d9c51e62a96d05475af5096f1fed1089eae7f |
|
MD5 | eea4ce00be967d648f9e0a804e958a4f |
|
BLAKE2b-256 | 2ec09abbc77eb4a54f4b39bbf679d83013cac21b9c10b47a720560215bd3f73f |
Hashes for rbcl-1.0.1-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0c9ff0ff550840a82f88386a63d5a7411390787fac7b8e179ac4a54cae58220 |
|
MD5 | c223f8b4f62b4cc7def75a6c4918d76f |
|
BLAKE2b-256 | bc45ca428a791a54bfe883c6fbe28364bc5b79cf55861b5d0a40a5232427b06d |
Hashes for rbcl-1.0.1-cp37-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16931b2b4c07f23dfa2a6574406456e4049edf58bee6b908a69613b9d9c72cce |
|
MD5 | 8920efb267c5159b7e9da34a5e527242 |
|
BLAKE2b-256 | 7983fbbeeca2bc1f7126cbf506be56119094a008f262431d62131094e7be8070 |
Hashes for rbcl-1.0.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac7a67a7287b8587340bcfe160f81404de26234e17d173894c5f1d61f2ca35a9 |
|
MD5 | cb1420e91dfc99f289705600d15a309f |
|
BLAKE2b-256 | 8175166058c8145996a5c19c86e2e781e4305f7fc33dcbba33fc6942454dfe70 |
Hashes for rbcl-1.0.1-cp37-abi3-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b1451516c86c175ade770212cab2c68fbd51b6e7305a794e33dae153b1cf8bf |
|
MD5 | 62fc7d07c5ccf85416ea2f1e052a2eae |
|
BLAKE2b-256 | 4c49346d783c66b210031da9c389731aa03efeb283a8d158220244fbfa2cb7e1 |