lschoe / mpyc

MPyC: Multiparty Computation in Python
MIT License
367 stars 76 forks source link

Does mpyc provide ORAM ? #27

Closed YuXinFan closed 2 years ago

YuXinFan commented 3 years ago

I write a program that needs to access an array by secret index. Does MPyC contain ORAM implementation?

lschoe commented 3 years ago

Oh, yes, the module mpyc.seclists provides a simple implementation of ORAM. The performance should be reasonable for lists of up to a couple dozen elements, maybe even a few hundred elements.

For usage examples, you can take a look at the unittests in mpyc/tests/test_seclists.py. One of the tests is as follows:

   for a in [secint(3)]*3 + [secint(4)]*4:
       s[a] += 1
    self.assertEqual(mpc.run(mpc.output(list(s))), [0, 0, 0, 3, 4, 0, 0])

So this is a secure frequency count. The list s is updated 7 times, but it remains hidden which entries of s are incremented, of course, until we open everything in the last line.

Have a look and let me know if you've any questions.