Package: rbcl
Python library that bundleslibsodiumand provides wrappers for its Ristretto group functions.Installation and UsageThis library is available as apackage on PyPI:python-mpipinstallrbclThe library can be imported in the usual ways:importrbclfromrbclimport*ExamplesA few usage examples are presented below:>>>fromrbclimport*>>>x=crypto_core_ristretto255_random()>>>assertcrypto_core_ristretto255_is_valid_point(x)>>>y=crypto_core_ristretto255_from_hash(b'\xF0'*64)>>>assertcrypto_core_ristretto255_is_valid_point(y)>>>z1=crypto_core_ristretto255_add(x,y)>>>z2=crypto_core_ristretto255_add(y,x)>>>assertz1==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))>>>assertw1==w2# Multiplication of a point by a scalar is repeated addition.This library exports Python wrappers forconstructors,point arithmetic functions, andscalar arithmetic functions.Development, Build, and Manual Installation InstructionsAll development and installation dependencies are managed usingsetuptoolsand are fully specified insetup.cfg. Theextras_requireoption 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(assuming that the library has already been built successfully):python-mpipinstall.[docs,lint]Building from SourceThe library can be built manually from sourcewithin Linux and macOSusing the sequence of commands below:python-mpipinstall.[build]python-mbuild--sdist--wheel.Developing the library further in a local environment and/or building the library from source requireslibsodium. The steppython-mbuild--sdist--wheel.in the above attempts to automatically locate a copy of the libsodium source archivesrc/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-Osrc/rbcl/libsodium.tar.gzhttps://github.com/jedisct1/libsodium/releases/download/1.0.18-RELEASE/libsodium-1.0.18.tar.gzThe 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 DevelopmentBeforedocumentation can be generatedortests can be executed, it is necessary torun the build processand then to use the command below to move the compiled libsodium shared/dynamic library file into its designated location (so that the module filesrc/rbcl/rbcl.pyis able to import it):cpbuild/lib*/rbcl/_sodium.pysrc/rbclManual InstallationOnce the package isbuilt, it can be installed manually using the command below:python-mpipinstall-fdist.--upgradeDocumentationOnce the libsodium shared library file is compiled and moved into its designated location (as described inthe relevant subsection above), the documentation can be generated automatically from the source files usingSphinx:python-mpipinstall.[docs]cddocssphinx-apidoc-f-E--templatedir=_templates-o_source..../src/rbcl/_sodium_build.py&&makehtmlTesting and ConventionsBefore 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 inthe relevant subsection above).All unit tests are executed and their coverage is measured when usingpytest(seepyproject.tomlfor configuration details):python-mpipinstall.[test]python-mpytestAlternatively, all unit tests are included in the module itself and can be executed usingdoctest:pythonsrc/rbcl/rbcl.py-vStyle conventions are enforced usingPylint:python-mpipinstall.[lint]python-mpylintsrc/rbclsrc/rbcl/_sodium.tmplsrc/rbcl/_sodium_build.py--disable=duplicate-codeContributionsIn 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-mpipinstall.[publish]Ensure that the correct version number appears insetup.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 anautomation rulethat activates and sets as the default all tagged versions. Create and push a tag for this version (replacing?.?.?with the version number):gittag?.?.?gitpushorigin?.?.?Remove any old build/distribution files. Then, package the source into a distribution archive:rm-rfbuilddistsrc/*.egg-infopython-mbuild--sdist.Next, navigate to the appropriate GitHub Actions run of the workflow defined inlint-test-cover-docs-build-upload.yml. Click on the workflow and scroll down to theArtifactspanel. Download the archive files to thedistdirectory. Unzip all the archive files so that only the*.whlfiles remain:cddist&&foriin`ls*.zip`;dounzip$i;done&&rm*.zip&&cd..Finally, upload the package distribution archive toPyPI:python-mtwineuploaddist/*