Skip to main content

TNO MPC Lab - MPyC - Secure Exponentiation

The TNO MPC lab consists of generic software components, procedures, and functionalities developed and maintained on a regular basis to facilitate and aid in the development of MPC solutions. The lab is a cross-project initiative allowing us to integrate and reuse previously developed MPC functionalities to boost the development of new protocols and solutions.

The package tno.mpc.mpyc.exponentiation is part of the TNO Python Toolbox.

The package contains a generic extension to MPyC that allows you to securely compute $a^{[x]}$, where $a$ is a non-negative, plain-text base (floating point or integer) and $x$ is a secure number (SecFxp or SecInt).

Limitations in (end-)use: the content of this software package may solely be used for applications that comply with international export control laws.
This implementation of cryptographic software has not been audited. Use at your own risk.

Documentation

Documentation of the tno.mpc.mpyc.exponentiation package can be found here.

Install

Easily install the tno.mpc.mpyc.exponentiation package using pip:

$ python -m pip install tno.mpc.mpyc.exponentiation

Note:

A significant performance improvement can be achieved by installing the GMPY2 library.

$ python -m pip install 'tno.mpc.mpyc.exponentiation[gmpy]'

If you wish to run the tests you can use:

$ python -m pip install 'tno.mpc.mpyc.exponentiation[tests]'

Usage

Minimal example

example.py

import math

from mpyc.runtime import mpc

from tno.mpc.mpyc.exponentiation import secure_pow


async def main(base=math.e, x=[-1.5, 2.3, 4.5]):
    async with mpc:
        stype = mpc.SecFxp()
        sec_x = (
            [stype(xx, integral=False) for xx in x] if isinstance(x, list) else stype(x)
        )
        result = secure_pow(base, sec_x)
        revealed_result = await mpc.output(result)
    plain_result = [base ** xx for xx in x] if isinstance(x, list) else base ** x
    print(f"Result of secure exponentiation is {revealed_result}")
    print(f"In the plain we would have gotten  {plain_result}")
    diff = (
        [abs(sec - plain) for sec, plain in zip(revealed_result, plain_result)]
        if isinstance(x, list)
        else abs(revealed_result - plain_result)
    )
    print(f"The absolute difference is {diff}")


if __name__ == "__main__":
    mpc.run(main())

Release files for tno.mpc.mpyc.exponentiation 1.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for tno.mpc.mpyc.exponentiation 1.6.2
File Interpreter ABI Platform
tno.mpc.mpyc.exponentiation-1.6.2-py3-none-any.whl Python 3 none any Details

Release files / tno.mpc.mpyc.exponentiation-1.6.2-py3-none-any.whl

Download URL tno.mpc.mpyc.exponentiation-1.6.2-py3-none-any.whl
Size 23.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6fcda747d1b6d730c45d7cf5925b7bb64e4ea156278db503b7334b1aa353e456
BLAKE2b-256 checksum
How to use checksums
3717a819460c40214a7b18ba12db84728f055791c20205a3fd87c49b996a90c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

1.6.2 This release

1 release file

1.4.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page