Skip to content

Commit

Permalink
Merge pull request #263 from fjarri/interfacing
Browse files Browse the repository at this point in the history
Interfacing with Rust
  • Loading branch information
fjarri committed May 27, 2021
2 parents 2ef43a6 + 503a1c6 commit 7b7fdfa
Show file tree
Hide file tree
Showing 86 changed files with 4,461 additions and 6,575 deletions.
43 changes: 0 additions & 43 deletions .circleci/config.yml
Expand Up @@ -4,10 +4,6 @@ workflows:
version: 2
build_test_deploy:
jobs:
- pipenv_install_35:
filters:
tags:
only: /.*/
- pipenv_install_36:
filters:
tags:
Expand All @@ -16,10 +12,6 @@ workflows:
filters:
tags:
only: /.*/
- pip_install_35:
filters:
tags:
only: /.*/
- pip_install_36:
filters:
tags:
Expand All @@ -28,13 +20,6 @@ workflows:
filters:
tags:
only: /.*/
- run_tests_35:
filters:
tags:
only: /.*/
requires:
- pipenv_install_35
- pip_install_35
- run_tests_36:
filters:
tags:
Expand All @@ -54,39 +39,34 @@ workflows:
tags:
only: /.*/
requires:
- run_tests_35
- run_tests_36
- run_tests_37
- doctests_36:
filters:
tags:
only: /.*/
requires:
- run_tests_35
- run_tests_36
- run_tests_37
- notebook_tests_36:
filters:
tags:
only: /.*/
requires:
- run_tests_35
- run_tests_36
- run_tests_37
- reencryption_memory_profile_36:
filters:
tags:
only: /.*/
requires:
- run_tests_35
- run_tests_36
- run_tests_37
- reencryption_benchmark_36:
filters:
tags:
only: /.*/
# requires: # Commented this section to speed up the build
# - run_tests_35
# - run_tests_36
# - run_tests_37
- test_deploy:
Expand Down Expand Up @@ -119,11 +99,6 @@ workflows:
branches:
ignore: /.*/

python_35_base: &python_35_base
working_directory: ~/pyUmbral-35
docker:
- image: circleci/python:3.5

python_36_base: &python_36_base
working_directory: ~/pyUmbral-36
docker:
Expand Down Expand Up @@ -190,12 +165,6 @@ commands:

jobs:

pipenv_install_35:
<<: *python_35_base
steps:
- pipenv_install:
python_version: "3.5"

pipenv_install_36:
<<: *python_36_base
steps:
Expand All @@ -208,11 +177,6 @@ jobs:
- pipenv_install:
python_version: "3.7"

pip_install_35:
<<: *python_35_base
steps:
- pip_install

pip_install_36:
<<: *python_36_base
steps:
Expand All @@ -223,13 +187,6 @@ jobs:
steps:
- pip_install

run_tests_35:
<<: *python_35_base
parallelism: 4
steps:
- run_tests:
python_version: "3.5"

run_tests_36:
<<: *python_36_base
parallelism: 4
Expand Down
8 changes: 8 additions & 0 deletions .coveragerc
Expand Up @@ -3,3 +3,11 @@ omit =
setup.py,
*__init__.py
parallel=True

[report]
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover

# Exclude abstract methods
@abstractmethod
5 changes: 0 additions & 5 deletions Pipfile
Expand Up @@ -5,13 +5,8 @@ name = "pypi"

[packages]
setuptools = "*"
# Third Party
cryptography = ">=2.3"
pynacl = "*"
pysha3 = "*"
# NuCypher
bytestring-splitter = "*"
constant-sorrow = ">=0.1.0a7"

[dev-packages]
bumpversion = "*"
Expand Down
1,119 changes: 628 additions & 491 deletions Pipfile.lock

Large diffs are not rendered by default.

67 changes: 32 additions & 35 deletions README.rst
Expand Up @@ -62,19 +62,18 @@ Additionally, users that delegate access to their data (like Alice, in this exam

.. code-block:: python
from umbral import pre, keys, signing
from umbral import SecretKey, PublicKey
# Generate Umbral keys for Alice.
alices_private_key = keys.UmbralPrivateKey.gen_key()
alices_public_key = alices_private_key.get_pubkey()
alices_secret_key = SecretKey.random()
alices_public_key = PublicKey.from_secret_key(alices_secret_key)
alices_signing_key = keys.UmbralPrivateKey.gen_key()
alices_verifying_key = alices_signing_key.get_pubkey()
alices_signer = signing.Signer(private_key=alices_signing_key)
alices_signing_key = SecretKey.random()
alices_verifying_key = PublicKey.from_secret_key(alices_signing_key)
# Generate Umbral keys for Bob.
bobs_private_key = keys.UmbralPrivateKey.gen_key()
bobs_public_key = bobs_private_key.get_pubkey()
bobs_secret_key = SecretKey.random()
bobs_public_key = PublicKey.from_secret_key(bobs_secret_key)
**Encryption**
Expand All @@ -89,14 +88,14 @@ Alice can open the capsule and decrypt the ciphertext with her private key.

.. code-block:: python
from umbral import encrypt, decrypt_original
# Encrypt data with Alice's public key.
plaintext = b'Proxy Re-Encryption is cool!'
ciphertext, capsule = pre.encrypt(alices_public_key, plaintext)
capsule, ciphertext = encrypt(alices_public_key, plaintext)
# Decrypt data with Alice's private key.
cleartext = pre.decrypt(ciphertext=ciphertext,
capsule=capsule,
decrypting_key=alices_private_key)
cleartext = decrypt_original(alices_secret_key, capsule, ciphertext)
**Re-Encryption Key Fragments**
Expand All @@ -107,13 +106,15 @@ which are next sent to N proxies or *Ursulas*.

.. code-block:: python
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 = pre.generate_kfrags(delegating_privkey=alices_private_key,
signer=alices_signer,
receiving_pubkey=bobs_public_key,
threshold=10,
N=20)
kfrags = generate_kfrags(delegating_sk=alices_secret_key,
receiving_pk=bobs_public_key,
signing_sk=alices_signing_key,
threshold=10,
num_kfrags=20)
**Re-Encryption**
Expand All @@ -127,17 +128,13 @@ Bob must gather at least ``threshold`` cfrags in order to activate the capsule.

.. code-block:: python
# Several Ursulas perform re-encryption, and Bob collects the resulting `cfrags`.
# He must gather at least `threshold` `cfrags` in order to activate the capsule.
capsule.set_correctness_keys(delegating=alices_public_key,
receiving=bobs_public_key,
verifying=alices_verifying_key)
from umbral import reencrypt
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
# 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**
Expand All @@ -147,14 +144,14 @@ and then decrypts the re-encrypted ciphertext.

.. code-block:: python
# Bob activates and opens the capsule
for cfrag in cfrags:
capsule.attach_cfrag(cfrag)
from umbral import decrypt_reencrypted
bob_cleartext = pre.decrypt(ciphertext=ciphertext,
capsule=capsule,
decrypting_key=bobs_private_key)
assert bob_cleartext == plaintext
bob_cleartext = pre.decrypt_reencrypted(decrypting_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.

Expand All @@ -171,7 +168,7 @@ To install pyUmbral, simply use ``pip``:
$ pip3 install umbral
Alternatively, you can checkout the repo and install it from there.
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:

Expand Down

0 comments on commit 7b7fdfa

Please sign in to comment.