• Stars
    star
    284
  • Rank 144,744 (Top 3 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created over 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NuCypher's reference implementation of Umbral (threshold proxy re-encryption) using OpenSSL and Cryptography.io

pyUmbral

PyPI Package latest release CircleCI build status Commits since latest release Documentation Status Discord

pyUmbral is the reference implementation of the Umbral threshold proxy re-encryption scheme. It is open-source, built with Python, and uses OpenSSL and Cryptography.io.

Using Umbral, Alice (the data owner) can delegate decryption rights to Bob for any ciphertext intended to her, through a re-encryption process performed by a set of semi-trusted proxies or Ursulas. When a threshold of these proxies participate by performing re-encryption, Bob is able to combine these independent re-encryptions and decrypt the original message using his private key.

pyUmbral is the cryptographic engine behind nucypher, a proxy re-encryption network to empower privacy in decentralized systems.

Usage

Key Generation

As in any public-key cryptosystem, users need a pair of public and private keys. Additionally, users that delegate access to their data (like Alice, in this example) need a signing keypair.

from umbral import SecretKey, Signer

# Generate Umbral keys for Alice.
alices_secret_key = SecretKey.random()
alices_public_key = alices_secret_key.public_key()

alices_signing_key = SecretKey.random()
alices_signer = Signer(alices_signing_key)
alices_verifying_key = alices_signing_key.public_key()

# Generate Umbral keys for Bob.
bobs_secret_key = SecretKey.random()
bobs_public_key = bobs_secret_key.public_key()

Encryption

Now let's encrypt data with Alice's public key. Invocation of pre.encrypt returns both the ciphertext and a capsule. Note that anyone with Alice's public key can perform this operation.

Since data was encrypted with Alice's public key, Alice can open the capsule and decrypt the ciphertext with her private key.

from umbral import encrypt, decrypt_original

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

# Decrypt data with Alice's private key.
cleartext = decrypt_original(alices_secret_key, capsule, ciphertext)

Re-Encryption Key Fragments

When Alice wants to grant Bob access to open her encrypted messages, she creates re-encryption key fragments, or "kfrags", which are next sent to N proxies or Ursulas.

from umbral import generate_kfrags

# Alice generates "M of N" re-encryption key fragments (or "KFrags") for Bob.
# In this example, 10 out of 20.
kfrags = generate_kfrags(delegating_sk=alices_secret_key,
                         receiving_pk=bobs_public_key,
                         signer=alices_signer,
                         threshold=10,
                         shares=20)

Re-Encryption

Bob asks several Ursulas to re-encrypt the capsule so he can open it. Each Ursula performs re-encryption on the capsule using the kfrag provided by Alice, obtaining this way a "capsule fragment", or cfrag.

Bob collects the resulting cfrags from several Ursulas. Bob must gather at least threshold cfrags in order to activate the capsule.

from umbral import reencrypt

# Several Ursulas perform re-encryption, and Bob collects the resulting `cfrags`.
cfrags = list()           # Bob's cfrag collection
for kfrag in kfrags[:10]:
    cfrag = pre.reencrypt(capsule=capsule, kfrag=kfrag)
    cfrags.append(cfrag)    # Bob collects a cfrag

Decryption by Bob

Finally, Bob activates the capsule by attaching at least threshold cfrags, and then decrypts the re-encrypted ciphertext.

from umbral import decrypt_reencrypted

bob_cleartext = pre.decrypt_reencrypted(receiving_sk=bobs_secret_key,
                                        delegating_pk=alices_public_key,
                                        capsule=capsule,
                                        cfrags=cfrags,
                                        ciphertext=ciphertext)
assert bob_cleartext == plaintext

See more detailed usage examples in the docs directory.

Quick Installation

To install pyUmbral, simply use pip:

$ pip3 install umbral

Alternatively, you can checkout the repo and install it from there. 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: https://docs.pipenv.org/.

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. https://github.com/nucypher/umbral-doc/blob/master/umbral-doc.pdf

Support & Contribute

Security

If you identify vulnerabilities with _any_ nucypher code, please email [email protected] with relevant information to your findings. We will work with researchers to coordinate vulnerability disclosure between our partners and users to ensure successful mitigation of vulnerabilities.

Throughout the reporting process, we expect researchers to honor an embargo period that may vary depending on the severity of the disclosure. This ensures that we have the opportunity to fix any issues, identify further issues (if any), and inform our users.

Sometimes vulnerabilities are of a more sensitive nature and require extra precautions. We are happy to work together to use a more secure medium, such as Signal. Email [email protected] and we will coordinate a communication channel that we're both comfortable with.

More Repositories

1

zerodb

*This project is no longer actively maintained. If you'd like to become the maintainer, please let us know.* ZeroDB is an end-to-end encrypted database. Data can be stored and queried on untrusted database servers without ever exposing the encryption key. Clients can execute remote queries against the encrypted data without downloading all of it or suffering an excessive performance hit.
Python
1,556
star
2

nucypher

Threshold Access Control (TACo) runtimes for the Threshold Network
Python
691
star
3

nufhe

NuCypher fully homomorphic encryption (NuFHE) library implemented in Python
Python
439
star
4

zerodb-server

ZeroDB server and client-side example of using it
Python
135
star
5

whitepaper

Privacy layer for blockchain and decentralized applications based on proxy re-encryption
TeX
66
star
6

rust-umbral

Umbral implementation in Rust
Rust
50
star
7

goUmbral

Umbral implementation in Golang
Go
41
star
8

constantSorrow

Special Value Constants for Python. I am the man of constant sorrow; I've seen special values as ints, all my days.
Python
34
star
9

nucypher-pre-python

NuCypher proxy re-encryption library in Python
C
28
star
10

umbral-doc

Documentation of the Umbral PRE cryptosystem
TeX
27
star
11

Sputnik

Sputnik is an assembly language and interpreter for Fully Homomorphic Encryption
Python
27
star
12

zerodb-afgh-pre

AFGH Proxy re-encryption for ZeroDB
Python
21
star
13

NuBLS

NuBLS is pure Rust implementation of BLS signatures with nifty threshold protocols
Rust
19
star
14

nucypher-kms-ethereum

Ethereum (solidity) code for nucypher-kms
Python
18
star
15

kafka-as-module-oss

NuCypher for Kafka. Start building from this module (it fetches the appropriate branch from Kafka repository)
Java
18
star
16

nucypher-contracts

Ethereum contracts supporting TACo applications on the Threshold Network.
Python
16
star
17

taco-web

🌮 A TypeScript client for TACo (Threshold Access Control)
TypeScript
14
star
18

protocol

Upstream research, development and discussion relating to the NuCypher protocol and economic design
Jupyter Notebook
13
star
19

numerology

Numerology: Optimized ECC arithmetic library for secp256k1 in Solidity
JavaScript
11
star
20

TFHE.jl

Implementation of TFHE with Julia
Julia
11
star
21

telegram-fetcher

Script to fetch info of all users in Telegram channel
Python
11
star
22

slides

Overview presentation slides
TeX
9
star
23

nucypher-monitor

NuCypher network intelligence crawler and web dashboard
Python
7
star
24

mining-paper

TeX
7
star
25

validator-profiles

Profiles for validators on the NuCypher Network
7
star
26

nube

Rust
7
star
27

DarkIntegers.jl

A modulo arithmetic toolbox for integers and polynomials
Julia
7
star
28

zerodb-js

Python
6
star
29

nucypher-core

Core structures for Nucypher network in Rust
Rust
6
star
30

bytestringSplitter

Among the simplest imaginable ways to serialize: concatenate and split.
Python
6
star
31

wcef-hackathon-2018

Guidelines for hackathon at WCEF 2018
5
star
32

mock-net

NuCypher MockNet - deprecated in favor of testnet: https://github.com/nucypher/nucypher
Python
5
star
33

nucypher-crypto-oss

Realizations of proxy re-encryption for ElGamal and BBS98
Java
4
star
34

pystunnel

Python library and command line utility to control a stunnel instance.
Python
4
star
35

zerodb-whitepaper

Description of how zerodb works and what security properties it has
TeX
4
star
36

nuit

NuCypher Staking UI
JavaScript
4
star
37

DarkCurves.jl

A DarkIntegers-based library for working with elliptic curves
Julia
3
star
38

Sunscreen_public

Secure, Private, Flexible Smart Contracts
3
star
39

nucypher-ts-demo

Demo for nucypher/nucypher-ts
TypeScript
3
star
40

SGFHE.jl

A Julia implementation of Shuhong Gao's FHE scheme
Julia
3
star
41

hadoop-oss

Open source edition of NuCypher for Hadoop
Java
3
star
42

nucypher-ops

Python
3
star
43

vehicle-data-exchange

Python
3
star
44

ATxM

Automatic Transaction Machine 🏧 🔁
Python
3
star
45

t-merkle-distributor

Rewards distribution of Threshold token
JavaScript
2
star
46

nucypher-porter

Gateway to TACo nodes of the threshold network
Python
2
star
47

zerodb-benchmarks

Benchmarks for zerodb
Python
2
star
48

tacobot

Python
2
star
49

HEAAN.jl

Implementation of HEAAN in Julia
Julia
2
star
50

LogProof.jl

Prototype implementation of Short Discrete Log Proofs (https://eprint.iacr.org/2019/057)
Julia
2
star
51

s3storage

Storage with Amazon S3
Python
1
star
52

kafka-oss

Open source edition of NuCypher for Kafka. See 0.11.0-encrypted branch. Build starts from kafka-as-module-oss
Java
1
star
53

nucypher-community-wrapper

HTML wrapper for community maintained nucypher applications.
HTML
1
star
54

taco-spy

Python
1
star
55

Curve25519.jl

Curve25519 (Ristretto) implementation in Julia
Julia
1
star