Skip to content

Commit

Permalink
Minor edits.
Browse files Browse the repository at this point in the history
  • Loading branch information
lschoe committed Feb 22, 2024
1 parent d4c4dae commit 62256f4
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ By running `python -m mpyc` instead you even get this REPL with the MPyC runtime

- Directory `demos\.config` contains configuration info used to run MPyC with multiple parties.
The file `gen.bat` shows how to generate fresh key material for SSL. To generate SSL key material of your own, first run
`pip install cryptography` (alternatively, run `pip install pyOpenSSL`).
`pip install cryptography`.

Copyright © 2018-2024 Berry Schoenmakers
2 changes: 2 additions & 0 deletions demos/aes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Demo Threshold AES cipher.
See np_aes.py for a reimplementation of this demo using secure arrays.
The demo performs an AES encryption followed by an AES decryption
for a 128-bit AES key and a 256-bit AES key, cf. the examples in
Appendices C.1 and C.3 of the Advanced Encryption Standard (FIPS 197).
Expand Down
2 changes: 2 additions & 0 deletions demos/bnnmnist.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Demo Binarized Neural Network (Multilayer Perceptron) MNIST classifier.
See np_bnnmnist.py for a reimplementation of this demo using secure arrays.
MPyC demo accompanying the paper 'Fast Secure Comparison for Medium-Sized
Integers and Its Application in Binarized Neural Networks' by Mark Abspoel,
Niek J. Bouman, Berry Schoenmakers, and Niels de Vreede, Cryptographer's
Expand Down
2 changes: 2 additions & 0 deletions demos/cnnmnist.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Demo Convolutional Neural Network (CNN) MNIST classifier.
See np_cnnmnist.py for a reimplementation of this demo using secure arrays.
The MNIST dataset of handwritten digits consists of a training set of
60,000 images and a test set of 10,000 images. The training images have been
used in the clear to obtain a highly reliable CNN classifier. The demo
Expand Down
2 changes: 2 additions & 0 deletions demos/id3gini.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Demo decision tree learning using ID3.
See np_id3gini.py for a reimplementation of this demo using secure arrays.
This demo implements Protocol 4.1 from the paper 'Practical Secure Decision
Tree Learning in a Teletreatment Application' by Sebastiaan de Hoogh, Berry
Schoenmakers, Ping Chen, and Harm op den Akker, which appeared at the 18th
Expand Down
2 changes: 2 additions & 0 deletions demos/lpsolver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Demo Linear Programming (LP) solver, using secure integer arithmetic.
See np_lpsolver.py for a reimplementation of this demo using secure arrays.
The LP solver returns a solution to the following problem:
Given m x n matrix A, length-m vector b >= 0, and length-n vector c.
Expand Down
2 changes: 2 additions & 0 deletions demos/lpsolverfxp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Demo Linear Programming (LP) solver, using secure fixed-point arithmetic.
See np_lpsolverfxp.py for a reimplementation of this demo using secure arrays.
See the demo lpsolver.py for background and explanation.
Unlike the lpsolver.py demo which is based on exact (hence deterministic) secure
Expand Down
2 changes: 2 additions & 0 deletions demos/onewayhashchains.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Demo Threshold One-Way Hash Chains.
See np_onewayhashchains.py for a reimplementation of this demo using secure arrays.
This MPyC demo shows how to generate and reverse one-way hash chains in a multiparty setting.
The seed for a hash chain, which serves as the private key, is generated jointly at random such
that no party learns any information about it. Subsequently, the hash chain is built and
Expand Down
12 changes: 6 additions & 6 deletions mpyc/mpctools.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def accumulate(x, f=operator.add, initial=_no_value):
the accumulated results over all (nonempty) prefixes of the given iterable x.
The applications of f are arranged such that the maximum depth is logarithmic
in the number of elements of x, at the cost of increasing the total number of
applications of f by a logarithmic factor as well.
in the number of elements of x, potentially at the cost of increasing the total
number of applications of f by a logarithmic factor as well.
In contrast, Python's itertools.accumulate() higher-order function arranges
the applications of f in a linear fashion, as in general it cannot be assumed
Expand All @@ -62,8 +62,8 @@ def accumulate(x, f=operator.add, initial=_no_value):
x.insert(0, initial)
n = len(x)
if runtime.options.no_prss and n >= 32:
# Minimize f-complexity of acc(0, n).
# For n=2^k, k>=0: f-complexity=2n - 2 - log2 n calls, f-depth=max(2 log2 n - 1, 0) rounds.
# Minimize f-complexity of acc(0, n) a la Brent-Kung.
# For n=2^k, k>=0: f-complexity=2n-2-k calls, f-depth=max(2k-2, k) rounds.
def acc(i, j):
h = (i + j)//2
if i < h:
Expand All @@ -74,8 +74,8 @@ def acc(i, j):
acc(h, j)
x[j-1] = f(a, x[j-1])
else:
# Minimize f-depth of acc(0, n)
# For n=2^k, k>=0: f-complexity=(n/2) log2 n calls, f-depth=log2 n rounds.
# Minimize f-depth of acc(0, n) a la Sklansky.
# For n=2^k, k>=0: f-complexity=(n/2)k calls, f-depth=k rounds.
def acc(i, j):
h = (i + j)//2
if i < h:
Expand Down

0 comments on commit 62256f4

Please sign in to comment.