Skip to main content

Python library that provides wrappers around the Ristretto group operations in libsodium.

Project description

rbcl

Ristretto group Python binding to libsodium

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

rbcl supports Python 3.7, 3.8 and 3.9.

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  # Assert that point addition commutes (in L)

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  # Assert that point multiplication (by a scalar) is repeated addition (in L)

The following bindings are made available:

Constructors

crypto_core_ristretto255_random()
crypto_core_ristretto255_from_hash(h)
crypto_core_ristretto255_is_valid_point(p)

Scalar arithmetic

crypto_core_ristretto255_scalar_add(s1, s2)
crypto_core_ristretto255_scalar_sub(s1, s2)
crypto_core_ristretto255_scalar_mul(s1, s2)  # NOT scalar mulitplication of a point!
crypto_core_ristretto255_scalar_complement(s)
crypto_core_ristretto255_scalar_invert(s)
crypto_core_ristretto255_scalar_negate(s)
crypto_core_ristretto255_scalar_reduce(s)
crypto_core_ristretto255_scalar_random()

Point arithmetic

crypto_core_ristretto255_add(p, q)
crypto_core_ristretto255_sub(p, q)
crypto_scalarmult_ristretto255(p, s)
crypto_scalarmult_ristretto255_base(s)

Constants

crypto_scalarmult_ristretto255_bytes
crypto_scalarmult_ristretto255_scalarbytes
crypto_core_ristretto255_bytes
crypto_core_ristretto255_scalarbytes
crypto_core_ristretto255_hashbytes
crypto_core_ristretto255_nonreducedscalarbytes

Helpers

randombytes
randombytes_buf_deterministic

Manual installation

# Build as a wheel and install
python setup.py bdist_wheel
python -m pip install -f wheelhouse --no-index rbcl
python -m nose

Publishing (for Maintainers Only)

# Package source distribution
python setup.py sdist

# Run wheel-builder.yml and save/download artifacts locally, e.g. in ./dist
# Then, upload to PyPi
twine upload dist/rbcl-0.2.0*

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 ../rbcl/sodium_ffi.py && make html

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

rbcl-0.2.0.tar.gz (9.9 kB view hashes)

Uploaded Source

Built Distributions

rbcl-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (712.8 kB view hashes)

Uploaded CPython 3.9+ manylinux: glibc 2.17+ x86-64

rbcl-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (713.1 kB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ x86-64

rbcl-0.2.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (712.4 kB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ x86-64

rbcl-0.2.0-cp36-abi3-win_amd64.whl (102.9 kB view hashes)

Uploaded CPython 3.6+ Windows x86-64

rbcl-0.2.0-cp36-abi3-win32.whl (94.6 kB view hashes)

Uploaded CPython 3.6+ Windows x86

rbcl-0.2.0-cp36-abi3-macosx_10_10_universal2.whl (173.1 kB view hashes)

Uploaded CPython 3.6+ macOS 10.10+ universal2 (ARM64, x86-64)

rbcl-0.2.0-cp36-abi3-macosx_10_9_x86_64.whl (244.8 kB view hashes)

Uploaded CPython 3.6+ macOS 10.9+ x86-64

rbcl-0.2.0-cp36-abi3-macosx_10_9_universal2.whl (173.4 kB view hashes)

Uploaded CPython 3.6+ macOS 10.9+ universal2 (ARM64, x86-64)

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