Git Product home page Git Product logo

oblif's Introduction

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

oblif's People

Contributors

meilof avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

uvm-plaid hamzazf

oblif's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.