Skip to content

Commit 25fcdd7

Browse files
committed
Add some np stubs.
1 parent 555da34 commit 25fcdd7

4 files changed

Lines changed: 25 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ combined with asynchronous evaluation of the associated protocols.
2121
See `demos` for Python programs and Jupyter notebooks with lots of example code. Click the "launch binder" badge above to view the entire
2222
repository and try out the Jupyter notebooks from the `demos` directory in the cloud, without any install.
2323

24-
The [MPyC homepage](https://www.win.tue.nl/~berry/mpyc/) has some more info and background.
24+
The [MPyC homepage](https://berry.win.tue.nl/mpyc/) has some more info and background.
2525

2626
## Installation
2727

demos/OneWayHashChainsExplained.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@
134134
"\n",
135135
"Using function $f$, we will now generate one-way hash chains in a secure way, such that the initial seed value $x_0$ as well as all other values on the chain will be secret-shared when the program is run in a multiparty setting. Moreover, we will also traverse the so-generated hash chain in the reverse order, operating on secret-shared values throughout the entire process. \n",
136136
"\n",
137-
"The traversal of the hash chain in reverse corresponds to the way a hash chain is used in the Lamport identification scheme, first revealing $x_{n-1}$, then $x_{n-2}$, and so on, until $x_0$ is revealed at the end. To reverse one-way hash chain efficiently, we use algorithms for [optimal binary pebbling](https://www.win.tue.nl/~berry/pebbling/). This way, we will only use at most $\\lceil k/2\\rceil$ hashes (applications of $f$) in any identification round, while limiting the storage to $k+1$ hash values at any time. \n",
137+
"The traversal of the hash chain in reverse corresponds to the way a hash chain is used in the Lamport identification scheme, first revealing $x_{n-1}$, then $x_{n-2}$, and so on, until $x_0$ is revealed at the end. To reverse one-way hash chain efficiently, we use algorithms for [optimal binary pebbling](https://berry.win.tue.nl/pebbling/). This way, we will only use at most $\\lceil k/2\\rceil$ hashes (applications of $f$) in any identification round, while limiting the storage to $k+1$ hash values at any time. \n",
138138
"\n",
139-
"We basically copy the [Python code for binary pebbling](https://www.win.tue.nl/~berry/pebbling/src/python/BinaryPebbling.html), which makes judicious use of [Python generators](https://docs.python.org/tutorial/classes.html#generators). The hash function is replaced with the MPyC one-way function `f()` defined above:"
139+
"We basically copy the [Python code for binary pebbling](https://berry.win.tue.nl/pebbling/src/python/BinaryPebbling.html), which makes judicious use of [Python generators](https://docs.python.org/tutorial/classes.html#generators). The hash function is replaced with the MPyC one-way function `f()` defined above:"
140140
]
141141
},
142142
{

mpyc/numpy.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,27 @@ def _item_shape(shape, key):
163163

164164
if np.lib.NumpyVersion(np.__version__) < '1.24.0':
165165
logging.warning(f'NumPy {np.__version__} not (fully) supported. Upgrade to NumPy 1.24+.')
166+
167+
if np.lib.NumpyVersion(np.__version__) < '2.0.0':
168+
np.concat = np.concatenate
169+
np.pow = np.power
170+
171+
if np.lib.NumpyVersion(np.__version__) < '2.1.0':
172+
def _(x, /, *, axis=None, dtype=None, out=None, include_initial=False):
173+
if include_initial:
174+
x = np.insert(x, 0, 0, axis=axis) # TODO: insert for secure arrays
175+
return np.cumsum(x, axis=axis, dtype=dtype, out=out)
176+
177+
np.cumulative_sum = _
178+
179+
def _(x, /, *, axis=None, dtype=None, out=None, include_initial=False):
180+
if include_initial:
181+
x = np.insert(x, 0, 1, axis=axis) # TODO: insert for secure arrays
182+
return np.cumprod(x, axis=axis, dtype=dtype, out=out)
183+
184+
np.cumulative_prod = _
185+
186+
166187
except ImportError:
167188
del _matmul_shape
168189
del _item_shape

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ requires-python = '>=3.10'
4141
documentation = 'https://mpyc.readthedocs.io'
4242
discussions = 'https://github.com/lschoe/mpyc/discussions'
4343
'release notes' = 'https://github.com/lschoe/mpyc/releases'
44-
homepage = 'https://www.win.tue.nl/~berry/mpyc/'
44+
homepage = 'https://berry.win.tue.nl/mpyc/'
4545
repository = 'https://github.com/lschoe/mpyc'

0 commit comments

Comments
 (0)