Skip to main content

Nucypher's Umbral Proxy Re-Encryption Implementation

Project description


pyUmbral is a python implementation of David Nuñez’s threshold proxy re-encryption scheme: Umbral. Implemented with OpenSSL and, pyUmbral is a referential and open-source cryptography library extending the traditional cryptological narrative of “Alice and Bob” by introducing a new actor, Ursula, who has the ability to take secrets encrypted for Alice and re-encrypt them for Bob.


Key Generation

from umbral import pre, keys, signing

# Generate Umbral keys for Alice.
alices_private_key = keys.UmbralPrivateKey.gen_key()
alices_public_key = alices_private_key.get_pubkey()

alices_signing_key = keys.UmbralPrivateKey.gen_key()
alices_verifying_key = alices_signing_key.get_pubkey()
alices_signer = signing.Signer(private_key=alices_signing_key)

# Generate Umbral keys for Bob.
bobs_private_key = keys.UmbralPrivateKey.gen_key()
bobs_public_key = bobs_private_key.get_pubkey()


# Encrypt data with Alice's public key.
plaintext = b'Proxy Re-encryption is cool!'
ciphertext, capsule = pre.encrypt(alices_public_key, plaintext)

# Decrypt data with Alice's private key.
cleartext = pre.decrypt(ciphertext=ciphertext,

Split Re-Encryption Keys

# Alice generates "M of N" split re-encryption keys for Bob.
# In this example, 10 out of 20.
kfrags = pre.split_rekey(delegating_privkey=alices_private_key,


# Several Ursulas perform re-encryption, and Bob collects the resulting `cfrags`.
# He must gather at least `threshold` `cfrags` in order to activate the capsule.


cfrags = list()           # Bob's cfrag collection
for kfrag in kfrags[:10]:
  cfrag = pre.reencrypt(kfrag=kfrag, capsule=capsule)
  cfrags.append(cfrag)    # Bob collects a cfrag

Decryption by Bob

# Bob activates and opens the capsule
for cfrag in cfrags:

bob_cleartext = pre.decrypt(ciphertext=ciphertext,
assert bob_cleartext == plaintext

See more detailed usage examples in the docs directory.

Quick Installation

The NuCypher team uses pipenv for managing pyUmbral’s dependencies. The recommended installation procedure is as follows:

$ sudo pip3 install pipenv
$ pipenv install

Post-installation, you can activate the project virtual environment in your current terminal session by running pipenv shell.

For more information on pipenv, find the official documentation here:

Academic Whitepaper

The Umbral scheme academic whitepaper and cryptographic specifications are available on GitHub.

“Umbral: A Threshold Proxy Re-Encryption Scheme” by David Nuñez

OFAC Sanctions Disclaimer

By using this software, you hereby affirm you are not an individual or entity subject to economic sanctions administered by the U.S. Government or any other applicable authority, including but not limited to, sanctioned party lists administered by the U.S. Treasury Department’s Office of Foreign Assets Control (OFAC), the U.S. State Department, and the U.S. Commerce Department. You further affirm you are not located in, or ordinarily resident in, any country, territory or region subject to comprehensive economic sanctions administered by OFAC, which are subject to change but currently include Cuba, Iran, North Korea, Syria and the Crimea region.

Project details

Download files

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

Files for umbral, version 0.1.0a4
Filename, size File type Python version Upload date Hashes
Filename, size umbral-0.1.0a4-py3-none-any.whl (32.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size umbral-0.1.0a4.tar.gz (24.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page