Skip to content

Python binding to the Ristretto group operations in libsodium

License

Notifications You must be signed in to change notification settings

wyatt-howe/rbcl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

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)

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

About

Python binding to the Ristretto group operations in libsodium

Resources

License

Stars

Watchers

Forks

Packages

No packages published