Ristretto group Python binding to libsodium
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:
crypto_core_ristretto255_random()
crypto_core_ristretto255_from_hash(h)
crypto_core_ristretto255_is_valid_point(p)
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()
crypto_core_ristretto255_add(p, q)
crypto_core_ristretto255_sub(p, q)
crypto_scalarmult_ristretto255(p, s)
crypto_scalarmult_ristretto255_base(s)
crypto_scalarmult_ristretto255_bytes crypto_scalarmult_ristretto255_scalarbytes crypto_core_ristretto255_bytes crypto_core_ristretto255_scalarbytes crypto_core_ristretto255_hashbytes crypto_core_ristretto255_nonreducedscalarbytes
randombytes randombytes_buf_deterministic
# Build as a wheel and install
python setup.py bdist_wheel
python -m pip install -f wheelhouse --no-index rbcl
python -m nose
# 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*
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