Skip to main content

Python binding to the Ristretto group operations in NaCl.

Project description

RbCl

Ristretto group Python binding to libsodium

RbCl supports Python 2.7 and 3.5+ as well as PyPy 2.6+.

import rbcl.bindings as lib

x = lib.crypto_core_ristretto255_random()
assert lib.crypto_core_ristretto255_is_valid_point(x)

y = lib.crypto_core_ristretto255_from_hash(b'\xF0'*64)
assert lib.crypto_core_ristretto255_is_valid_point(y)

z1 = lib.crypto_core_ristretto255_add(x, y)
z2 = lib.crypto_core_ristretto255_add(y, x)
assert z1 == z2  # Assert that point addition commutes (in L)

s1 = lib.crypto_core_ristretto255_scalar_random()
s2 = lib.crypto_core_ristretto255_scalar_random()
w1 = lib.crypto_scalarmult_ristretto255(s1, lib.crypto_scalarmult_ristretto255(s2, x))
w2 = lib.crypto_scalarmult_ristretto255(s2, lib.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
sodium_bin2hex
sodium_hex2bin
sodium_base642bin
sodium_base64_encoded_len
sodium_bin2base64
sodium_pad
sodium_unpad

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 Nth Party]

# 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.1.1*

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.1.2.tar.gz (45.0 MB view hashes)

Uploaded Source

Built Distributions

rbcl-0.1.2-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl (597.6 kB view hashes)

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

rbcl-0.1.2-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl (597.9 kB view hashes)

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

rbcl-0.1.2-cp37-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl (597.2 kB view hashes)

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

rbcl-0.1.2-cp36-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl (597.2 kB view hashes)

Uploaded CPython 3.6+ manylinux: glibc 2.5+ x86-64

rbcl-0.1.2-cp35-abi3-win_amd64.whl (112.9 kB view hashes)

Uploaded CPython 3.5+ Windows x86-64

rbcl-0.1.2-cp35-abi3-win32.whl (105.1 kB view hashes)

Uploaded CPython 3.5+ Windows x86

rbcl-0.1.2-cp35-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl (597.2 kB view hashes)

Uploaded CPython 3.5+ manylinux: glibc 2.5+ x86-64

rbcl-0.1.2-cp35-abi3-macosx_10_9_x86_64.whl (256.9 kB view hashes)

Uploaded CPython 3.5+ macOS 10.9+ x86-64

rbcl-0.1.2-cp27-cp27mu-manylinux_2_5_x86_64.manylinux1_x86_64.whl (600.5 kB view hashes)

Uploaded CPython 2.7mu manylinux: glibc 2.5+ x86-64

rbcl-0.1.2-cp27-cp27m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (600.5 kB view hashes)

Uploaded CPython 2.7m manylinux: glibc 2.5+ 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