Skip to content

Commit

Permalink
Restructing package
Browse files Browse the repository at this point in the history
  • Loading branch information
swansonk14 committed May 15, 2019
1 parent 325e6b4 commit 38bd7fd
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 40 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Damgard-Jurik

An implementation of the [Damgard-Jurik](https://people.csail.mit.edu/rivest/voting/papers/DamgardJurikNielsen-AGeneralizationOfPailliersPublicKeySystemWithApplicationsToElectronicVoting.pdf) multi-authority, homomorphic encryption cryptosystem.
An implementation of the threshold variant of the [Damgard-Jurik](https://people.csail.mit.edu/rivest/voting/papers/DamgardJurikNielsen-AGeneralizationOfPailliersPublicKeySystemWithApplicationsToElectronicVoting.pdf) homomorphic encryption cryptosystem.

## Table of Contents

Expand All @@ -14,18 +14,24 @@ An implementation of the [Damgard-Jurik](https://people.csail.mit.edu/rivest/vot

Requires Python 3.6+.

```bash
pip install damgard-jurik
```

Alternatively, the code can be cloned and installed locally as follows.

```bash
git clone https://github.com/cryptovoting/damgard-jurik.git
cd damgard-jurik
pip install -e damgard_jurik
pip install -e .
```
*Note that the `-e` flag will instruct pip to install the package as "editable". That is, when changes are made to any part of the package during development, those changes will immediately be available system-wide on the activated python environment.*

All requirements for this package should be added to `setup.py`.

## Public and Private Keys

In the multi-authority variant of Damgard-Jurik implemented in this repository, a key pair consists of single public key along with a private key that has been split into multiple components using [Shamir's secret sharing](https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing). The public key encrypts messages while the shares of the private key all contribute a portion of the decryption without ever requiring reconstruction of the private key. Thus, trust is distributed among the holders of the private key shares.
In the threshold variant of Damgard-Jurik implemented in this repository, a key pair consists of single public key along with a private key that has been split into multiple components using [Shamir's secret sharing](https://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing). The public key encrypts messages while the shares of the private key all contribute a portion of the decryption without ever requiring reconstruction of the private key. Thus, trust is distributed among the holders of the private key shares.

In this implementation, the public key is a `PublicKey` object with an encrypt function while the private key shares are `PrivateKeyShare` objects with a decrypt function that performs a partial decryption using that share of the private key. A `PrivateKeyRing` object holds a set of `PrivateKeyShare`s and contains a decrypt function that calls each `PrivateKeyShare`'s decrypt function and combines the results to obtain the final decryption.

Expand Down
3 changes: 3 additions & 0 deletions damgard_jurik/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python3

from damgard_jurik.crypto import EncryptedNumber, PrivateKeyRing, PrivateKeyShare, PublicKey, keygen
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
crypto.py
Boucher, Govedič, Saowakon, Swanson 2019
Contains an implementation of the Damgard-Jurik threshold decryption scheme.
Contains an implementation of the threshold decryption variant of the Damgard-Jurik cryptosystem.
"""
from functools import lru_cache
Expand Down
6 changes: 0 additions & 6 deletions damgard_jurik/damgard_jurik/__init__.py

This file was deleted.

File renamed without changes.
27 changes: 0 additions & 27 deletions damgard_jurik/setup.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env python3
"""
crypto.py
shamir.py
Boucher, Govedič, Saowakon, Swanson 2019
Implementation of Shamir secret sharing.
Contains an implementation of Shamir's secret sharing.
"""
from secrets import randbelow
from typing import List, Tuple
Expand Down
File renamed without changes.
34 changes: 34 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
"""
setup.py
Boucher, Govedič, Saowakon, Swanson 2019
Setup script for installation.
"""
import setuptools


with open('README.md') as f:
long_description = f.read()


setuptools.setup(
name='damgard-jurik',
version='0.0.2',
author='Nicholas Boucher, Luka Govedič, Pasapol Saowakon, Kyle Swanson',
author_email='[email protected]',
description='Homomorphic encryption using the threshold variant of the Damgard-Jurik cryptosystem.',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/cryptovoting/damgard-jurik',
packages=setuptools.find_packages(),
install_requires=[
'gmpy2'
],
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
]
)
2 changes: 1 addition & 1 deletion tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
test.py
Boucher, Govedič, Saowakon, Swanson 2019
Unit tests for crypto.
Contains unit tests for the damgard-jurik package.
"""
from secrets import randbelow
Expand Down

0 comments on commit 38bd7fd

Please sign in to comment.