Skip to main content

Bytecode transformations to produce data-oblivious code

Project description

oblif

Documentation Status

See documentation here!

Oblif is a library that lets you write data-oblivious code in a non-data-oblivious way. For example:

from mpyc.runtime import mpc

def test(x):
    return 1 if x==5 else 0

mpc.run(mpc.start())
print("test(5) is", mpc.run(mpc.output(test(type(5)))))
mpc.run(mpc.shutdown())
2021-05-08 13:56:22,858 Start MPyC runtime v0.7.4
Traceback (most recent call last):
    File "test-mpyc.py", line 14, in <module>
    print("test(5) is", mpc.run(mpc.output(test(type(5)))))
  File "test-mpyc.py", line 6, in test
    return 1 if x==5 else 0
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mpyc-0.7.4-py3.8.egg/mpyc/sectypes.py", line 50, in __bool__
TypeError: cannot use secure type in Boolean expressions

But

from mpyc.runtime import mpc
from oblif.decorator import oblif

@oblif
def test(x):
    return 1 if x==5 else 0

mpc.run(mpc.start())
type=mpc.SecInt()
type.ifelse = lambda self, ifval, elseval: ifval if ifval is elseval else mpc.if_else(self, ifval, elseval)
type.__deepcopy__ = lambda self, memo: self

print("test(5) is", mpc.run(mpc.output(test(type(5)))))

mpc.run(mpc.shutdown())

gives

2021-05-08 13:58:47,387 Start MPyC runtime v0.7.4
test(5) is 1
2021-05-08 13:58:47,394 Stop MPyC runtime -- elapsed time: 0:00:00.006167

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

oblif-0.3.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file oblif-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: oblif-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.0

File hashes

Hashes for oblif-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c064523f5a6494eb2e9e80e773a63cbca2a2743f8e74bc84d62fc00354198c8
MD5 4c1b5e655133770f507fd827cafe4be5
BLAKE2b-256 edb4ec2f3cc96b5b9488e747cc8d6f3e821863ca9e9ced4b3c84468c63922a05

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page