Skip to main content

Python interface to the Jubjub elliptic curve used in Zcash Protocol

Project description

pyjubjub

Python bindings to rust code that implements the Jubjub elliptic curve and RedDSA, a Schnorr-based signature scheme that supports key re-randomization, which is defined in the Zcash Protocol. RedDSA on the Jubjub curve is known as RedJubjub.

RedJubjub on the Jubjub elliptic curve plays the same role as ed25519 on the elliptic curve Curve25519.

Details

There are various Rust implementations of Jubjub, we use what is inside the version of librustzcash used by the Hush full node, which is an older version of librustzcash used in the zcashd Zcash full node. The current version of zcashd librustzcash has many changes to support Halo2/Orchard that we do not need for Jubjub. We do not use the jubjub crate from Zebra, the Zcash full node written in Rust.

The file src/lib.rs in this repo is https://git.hush.is/hush/librustzcash/src/branch/master/sapling-crypto/src/redjubjub.rs with python bindings provided by pyo3 from https://github.com/PyO3/pyo3

In theory this code is compatible with the Sapling zaddrs which use the Jubjub elliptic curve in the following cryptocoins: Hush, DragonX, Zcash, Ycash, Pirate and probably others. Testing is needed to verify this.

Compiling

Currently this code has only been tested with rust 1.63.0 .

Setup python environment:

    virtualenv venv
    source venv/bin/activate

Install maturin via pip install maturin

After changing code, compile Rust and Python module:

    maturin develop -r

The -r builds a release optimized version. You can leave it off if you want, but the current tests are ~50X slower without it.

Example Use

This code is still HIGHLY EXPERIMENTAL and UNTESTED. Don't say we didn't warn you.

import pyjubjub
privkey = pyjubjub.new_privkey()
pubkey = pyjubjub.get_pubkey(privkey)

Tests

To run tests:

python test.py

Installing

This is not yet available on PyPI

Requirements

pyjubjub requires Python 3.8 or higher

License

GPLv3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyjubjub-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl (235.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

File details

Details for the file pyjubjub-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pyjubjub-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 40e7ef24e9254188f1bbee4b8305d597e0d3bb9e64c30cc82d8a9b11aea86424
MD5 e73440308839a72afa6ba5905f668ce0
BLAKE2b-256 667fd4a7d5712439d1f7fb4ed2c0957c019d0e006e298356cfac31bc86413b56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page