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 Distribution

pyjubjub-0.0.1.tar.gz (563.5 kB view details)

Uploaded Source

Built Distribution

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

pyjubjub-0.0.1-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.0.1.tar.gz.

File metadata

  • Download URL: pyjubjub-0.0.1.tar.gz
  • Upload date:
  • Size: 563.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.8.1

File hashes

Hashes for pyjubjub-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a7b1061aef68eb19864550c0164518bd6657ae03b8878cce386371bfd19374e2
MD5 32c70f91ad458952ec0e937ee7d0a0a3
BLAKE2b-256 1f12af2cce8a41a8a98567f394e8286ab3a5c20aa8da438f6f49bfe5a28feb8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyjubjub-0.0.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 df6c2769051240b865a400fab251b7403a47f67bd7666d24dffc28dc75c61aa4
MD5 f2f6b9b0700323558c30fc937c05b29a
BLAKE2b-256 8c4879c254544451486f82eaa5a328b963fd17cfd442e7e770fac67771f6c78a

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